Page MenuHomePhabricator

Approved Revs extension uses deprecated hook ArticleAfterFetchContentObject (cause CI builds to fail)
Closed, ResolvedPublic

Description

This patch to Approved Revs failed Jenkins tests:

https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/ApprovedRevs/+/552813/

The main error message seemed to be:

Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/workspace/src/tests/selenium/specs/rollback.js)

The patch only got merged in because @Jdforrester-WMF manually overrode Jenkins.

I doubt it was that specific change that caused the problem - rather, I'm guessing that something else in Approved Revs is leading to a Jenkins error. The last patch to Approved Revs (other than i18n additions) was on September 30, so maybe some change to Jenkins validation (or Selenium testing specifically?) between now and then led to this.

By the way, Approved Revs contains no JavaScript code.

Event Timeline

In short the build failure comes from ApprovedRevs using a deprecated mediawiki hook: ArticleAfterFetchContentObject.


The build failure comes from the mediawiki/core Selenium tests:

INFO:backend.DevWebServer:[Mon Nov 25 16:27:21 2019] 127.0.0.1:52826 [200]: //api.php?format=json
INFO:backend.DevWebServer:[Mon Nov 25 16:27:21 2019] PHP Deprecated:  Use of ArticleAfterFetchContentObject hook (used in ApprovedRevsHooks::showBlankIfUnapproved) was deprecated in MediaWiki 1.32. [Called from Hooks::run in /workspace/src/includes/Hooks.php at line 202] in /workspace/src/includes/debug/MWDebug.php on line 333
INFO:backend.DevWebServer:[Mon Nov 25 16:27:21 2019] 127.0.0.1:52828 [200]: //index.php?action=edit&vehidebetadialog=1&hidewelcomedialog=1&title=BeforeEach-name-0.3203669110149663-I%C3%B1t%C3%ABrn%C3%A2ti%C3%B4n%C3%A0liz%C3%A6ti%C3%B8n


[0-1] 
	Video location: /workspace/log/Page-should-be-re-creatable.mp4 

	ffmpeg exited with code 255 /workspace/log/Page-should-be-re-creatable.mp4
[0-1] Error in "Page should be editable @daily"
Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/workspace/src/tests/selenium/specs/page.js)
[0-1] 
	Video location: /workspace/log/Page-should-be-editable-%40daily.mp4 

	ffmpeg exited with code 255 /workspace/log/Page-should-be-editable-%40daily.mp4
[0-1] Error in ""after each" hook for "should be editable @daily""
Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

And:

INFO:backend.DevWebServer:[Mon Nov 25 16:37:24 2019] PHP Deprecated:  Use of ArticleAfterFetchContentObject hook (used in ApprovedRevsHooks::showBlankIfUnapproved) was deprecated in MediaWiki 1.32. [Called from Hooks::run in /workspace/src/includes/Hooks.php at line 202] in /workspace/src/includes/debug/MWDebug.php on line 333
INFO:backend.DevWebServer:[Mon Nov 25 16:37:24 2019] 127.0.0.1:34510 [200]: /index.php/Main_Page
[0-2] Error in "Rollback with confirmation "before all" hook for "should offer rollback options for admin users""
Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/workspace/src/tests/selenium/specs/rollback.js)
[0-2] Error in "Rollback without confirmation "before all" hook for "should perform rollback via POST request without asking the user to confirm""
Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/workspace/src/tests/selenium/specs/rollback.js)

We run the CI builds including MediaWiki core file includes/DevelopmentSettings.php which causes deprecation to be turned to warning :

includes/DevelopmentSettings.php
// Use of wfWarn() should cause tests to fail
$wgDevelopmentWarnings = true;

Those messages show up with a stacktrace in the MediaWiki error log which is attached to the build (mw-error.log) which has:

mw-error.log
2019-11-25 16:27:21 9586f12bc731 wikidb: [a604d7dd89f82bb98a31e2b6] /index.php?action=edit&vehidebetadialog=1&hidewelcomedialog=1&title=BeforeEach-name-0.3203669110149663-I%C3%B1t%C3%ABrn%C3%A2ti%C3%B4n%C3%A0liz%C3%A6ti%C3%B8n   ErrorException from line 333 of /workspace/src/includes/debug/MWDebug.php: PHP Deprecated: Use of ArticleAfterFetchContentObject hook (used in ApprovedRevsHooks::showBlankIfUnapproved) was deprecated in MediaWiki 1.32. [Called from Hooks::run in /workspace/src/includes/Hooks.php at line 202]
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /workspace/src/includes/debug/MWDebug.php(333): trigger_error(string, integer)
#2 /workspace/src/includes/debug/MWDebug.php(265): MWDebug::sendMessage(string, array, string, integer)
#3 /workspace/src/includes/GlobalFunctions.php(1046): MWDebug::deprecated(string, string, string, integer)
#4 /workspace/src/includes/Hooks.php(169): wfDeprecated(string, string)
#5 /workspace/src/includes/Hooks.php(202): Hooks::callHook(string, array, array, string)
#6 /workspace/src/includes/page/Article.php(500): Hooks::run(string, array, string)
#7 /workspace/src/includes/page/Article.php(579): Article->fetchRevisionRecord()
#8 /workspace/src/includes/EditPage.php(637): Article->getRevisionFetched()
#9 /workspace/src/includes/actions/EditAction.php(60): EditPage->edit()
#10 /workspace/src/includes/MediaWiki.php(514): EditAction->show()
#11 /workspace/src/includes/MediaWiki.php(304): MediaWiki->performAction(Article, Title)
#12 /workspace/src/includes/MediaWiki.php(967): MediaWiki->performRequest()
#13 /workspace/src/includes/MediaWiki.php(530): MediaWiki->main()
#14 /workspace/src/index.php(46): MediaWiki->run()
#15 {main}
2019-11-25 16:37:24 9586f12bc731 wikidb: [711cb74509c11ad9aff4628c] /index.php/Main_Page   ErrorException from line 333 of /workspace/src/includes/debug/MWDebug.php: PHP Deprecated: Use of ArticleAfterFetchContentObject hook (used in ApprovedRevsHooks::showBlankIfUnapproved) was deprecated in MediaWiki 1.32. [Called from Hooks::run in /workspace/src/includes/Hooks.php at line 202]
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /workspace/src/includes/debug/MWDebug.php(333): trigger_error(string, integer)
#2 /workspace/src/includes/debug/MWDebug.php(265): MWDebug::sendMessage(string, array, string, integer)
#3 /workspace/src/includes/GlobalFunctions.php(1046): MWDebug::deprecated(string, string, string, integer)
#4 /workspace/src/includes/Hooks.php(169): wfDeprecated(string, string)
#5 /workspace/src/includes/Hooks.php(202): Hooks::callHook(string, array, array, string)
#6 /workspace/src/includes/page/Article.php(500): Hooks::run(string, array, string)
#7 /workspace/src/includes/page/Article.php(734): Article->fetchRevisionRecord()
#8 /workspace/src/includes/actions/ViewAction.php(63): Article->view()
#9 /workspace/src/includes/MediaWiki.php(514): ViewAction->show()
#10 /workspace/src/includes/MediaWiki.php(304): MediaWiki->performAction(Article, Title)
#11 /workspace/src/includes/MediaWiki.php(967): MediaWiki->performRequest()
#12 /workspace/src/includes/MediaWiki.php(530): MediaWiki->main()
#13 /workspace/src/index.php(46): MediaWiki->run()
#14 {main}
hashar renamed this task from Approved Revs extension fails Jenkins tests to Approved Revs extension uses deprecated hook ArticleAfterFetchContentObject (cause CI builds to fail).Nov 26 2019, 9:57 AM
hashar edited projects, added ci-test-error; removed Jenkins.

The hook documentation (docs/hooks.txt) says ArticleRevisionViewCustom should be used instead:

ArticleAfterFetchContentObject

DEPRECATED since 1.32, use ArticleRevisionViewCustom to control output. After fetching content of an article from the database.

&$articlethe article (object) being loaded from the database
&$contentthe content of the article, as a Content object

ArticleRevisionViewCustom

Allows custom rendering of an article's content.
Note that it is preferable to implement proper handing for a custom data type using the ContentHandler facility.

$revisioncontent of the page, as a RevisionRecord object, or null if the revision could not be loaded. May also be a fake that wraps content supplied by an extension.
$titletitle of the page
$oldidthe requested revision id, or 0 for the current revision.
$outputa ParserOutput object
That has been deprecated with 1.32.0 by 4835a75ec56444c61c5d0cfbc9e98ceb420fc513
Yaron_Koren claimed this task.

@hashar - okay, thanks, that was very helpful. I knew about the changeover to ArticleRevisionViewCustom (I actually created the mediawiki.org page for that hook!), but I wasn't expecting that change to Jenkins behavior. Anyway, I just checked in a fix for this to Approved Revs.