Page MenuHomePhabricator

wfEscapeWikiText() emits error "PHP Notice: Array to string conversion" on Special:Search
Closed, ResolvedPublic

Description

message
[{exception_id}] {exception_url}   ErrorException from line 1591 of /srv/mediawiki/php-1.35.0-wmf.5/includes/GlobalFunctions.php: PHP Notice: Array to string conversion
trace
#0 /srv/mediawiki/php-1.35.0-wmf.5/includes/GlobalFunctions.php(1591): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 [internal function]: wfEscapeWikiText(array)
#2 /srv/mediawiki/php-1.35.0-wmf.5/includes/Status.php(295): array_map(string, array)
#3 /srv/mediawiki/php-1.35.0-wmf.5/includes/Status.php(198): Status->getErrorMessage(array, NULL)
#4 /srv/mediawiki/php-1.35.0-wmf.5/includes/Status.php(322): Status->getWikiText(string, boolean, NULL)
#5 /srv/mediawiki/php-1.35.0-wmf.5/includes/specials/SpecialSearch.php(411): Status->getHTML(string)
#6 /srv/mediawiki/php-1.35.0-wmf.5/includes/specials/SpecialSearch.php(179): SpecialSearch->showResults(string)
#7 /srv/mediawiki/php-1.35.0-wmf.5/includes/specialpage/SpecialPage.php(575): SpecialSearch->execute(NULL)
#8 /srv/mediawiki/php-1.35.0-wmf.5/includes/specialpage/SpecialPageFactory.php(607): SpecialPage->run(NULL)
#9 /srv/mediawiki/php-1.35.0-wmf.5/includes/MediaWiki.php(298): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#10 /srv/mediawiki/php-1.35.0-wmf.5/includes/MediaWiki.php(967): MediaWiki->performRequest()
#11 /srv/mediawiki/php-1.35.0-wmf.5/includes/MediaWiki.php(530): MediaWiki->main()
#12 /srv/mediawiki/php-1.35.0-wmf.5/index.php(46): MediaWiki->run()
#13 /srv/mediawiki/w/index.php(3): require(string)
#14 {main}

Original report from translatewiki.net:

#0 /www/dev.translatewiki.net/docroot/w/includes/GlobalFunctions.php(1591): MWExceptionHandler::handleError(8, 'Array to string...', '/www/dev.transl...', 1591, Array)
#1 [internal function]: wfEscapeWikiText(Array)
#2 /www/dev.translatewiki.net/docroot/w/includes/Status.php(295): array_map('wfEscapeWikiTex...', Array)
#3 /www/dev.translatewiki.net/docroot/w/includes/Status.php(198): Status->getErrorMessage(Array, NULL)
#4 /www/dev.translatewiki.net/docroot/w/includes/Status.php(322): Status->getWikiText('search-error', false, NULL)
#5 /www/dev.translatewiki.net/docroot/w/includes/specials/SpecialSearch.php(411): Status->getHTML('search-error')
#6 /www/dev.translatewiki.net/docroot/w/includes/specials/SpecialSearch.php(179): SpecialSearch->showResults('{{Doc viewed}} ...')
#7 /www/dev.translatewiki.net/docroot/w/includes/specialpage/SpecialPage.php(575): SpecialSearch->execute(NULL)
#8 /www/dev.translatewiki.net/docroot/w/includes/specialpage/SpecialPageFactory.php(607): SpecialPage->run(NULL)
#9 /www/dev.translatewiki.net/docroot/w/includes/MediaWiki.php(298): MediaWiki\\Special\\SpecialPageFactory->executePath(Object(Title), Object(RequestContext))
#10 /www/dev.translatewiki.net/docroot/w/includes/MediaWiki.php(967): MediaWiki->performRequest()
#11 /www/dev.translatewiki.net/docroot/w/includes/MediaWiki.php(530): MediaWiki->main()
#12 /www/dev.translatewiki.net/docroot/w/index.php(46): MediaWiki->run()
#13 {main}

Details

Request ID
XcSQ-wpAIC8AAHZhBJQAAABI
Request URL
https://www.wikidata.org/w/index.php?search=https%20%20%20exampleofadomain.com%20xxxxxxxxxxx%20xxx%20xx%20xx%20xx%20xxx%200000000000000000000%20xxxxxxxx%20xxxxx%200x%200F%200Fxxx.xxxxxx.xxx%200xxxxxx%200xxxxxxx%200xxx-xxxxx-xxxx-xxxxxxx%2000xxxxxxx%200xxxx%2000xxx%200xxxx%2000xx%200xhxxxx%200x%200x%200xxxx.xxxxxxxxx.xxx%200xxxxxx%200x0000%200x00%200xxxxxx-xxx-xx-xxx-xxxxxx-xxxx.xxxx%2000xxx%200xxxxxxxxx-xxx.&profile=default&fulltext=0&ns0=0
Related Gerrit Patches:
mediawiki/core : masterDo not run wfEscapeWikiText on array in Status class
mediawiki/extensions/CirrusSearch : masterDon't pass arrays into Status i18n messages

Event Timeline

Restricted Application added a project: Discovery-Search. · View Herald TranscriptNov 6 2019, 5:54 PM
Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald Transcript

Also happening on production (rarely though) according to Logstash.

Krinkle renamed this task from "PHP Notice: Array to string conversion" on long search request to wfEscapeWikiText() emits error "PHP Notice: Array to string conversion" on Special:Search.Nov 7 2019, 9:40 PM
Krinkle added a subscriber: mmodell.
Krinkle updated the task description. (Show Details)Nov 7 2019, 9:48 PM
Krinkle changed the subtype of this task from "Task" to "Production Error".
Krinkle set Request URL to https://www.wikidata.org/w/index.php?search=https%20%20%20exampleofadomain.com%20xxxxxxxxxxx%20xxx%20xx%20xx%20xx%20xxx%200000000000000000000%20xxxxxxxx%20xxxxx%200x%200F%200Fxxx.xxxxxx.xxx%200xxxxxx%200xxxxxxx%200xxx-xxxxx-xxxx-xxxxxxx%2000xxxxxxx%200xxxx%2000xxx%200xxxx%2000xx%200xhxxxx%200x%200x%200xxxx.xxxxxxxxx.xxx%200xxxxxx%200x0000%200x00%200xxxxxx-xxx-xx-xxx-xxxxxx-xxxx.xxxx%2000xxx%200xxxxxxxxx-xxx.&profile=default&fulltext=0&ns0=0.Nov 7 2019, 9:50 PM
Krinkle set Request ID to XcSQ-wpAIC8AAHZhBJQAAABI.
Krinkle updated the task description. (Show Details)
Krinkle set Phatality ID to bda020904ad2ea6d7fc999d78b9eb14cba130279a9d4fc32055268c77a830d7f.
Krinkle added a subscriber: Krinkle.

wfEscapeWikiText is called for each parameter of the given parameter list for a message, but it is possible to do more complex parameter params as only strings. Using Message::listParam for example produce an array which cannot be work on with` wfEscapeWikiText`

Failing:
$status = Status::newGood();
$status->error( 'lastmodifiedat', 'first', Message::numParam( 5 ) );
echo $status->getHTML( 'internalerror_info' );

=> Internal error: This page was last edited on first, at Array.

Works:
$status = Status::newGood();
$status->error( 'lastmodifiedat', 'first', '5' );
echo $status->getHTML( 'internalerror_info' );

=> Internal error: This page was last edited on first, at 5.

This can happen on every code path formatting the error text and not passing a message object on error.

Also happening on production (rarely though) according to Logstash.

Not rarely, although the rate is not huge: https://logstash.wikimedia.org/goto/aea2cb6ac106291659dd50190cf3f7f3

Change 552335 had a related patch set uploaded (by EBernhardson; owner: EBernhardson):
[mediawiki/extensions/CirrusSearch@master] Don't pass arrays into Status i18n messages

https://gerrit.wikimedia.org/r/552335

EBernhardson triaged this task as Medium priority.
EBernhardson moved this task from needs triage to Current work on the Discovery-Search board.

Change 552335 merged by jenkins-bot:
[mediawiki/extensions/CirrusSearch@master] Don't pass arrays into Status i18n messages

https://gerrit.wikimedia.org/r/552335

I am seeing ATM errors:

/wiki/Special:Search?search=<search string>&ns0=1   ErrorException from line 1591 of /srv/mediawiki/php-1.35.0-wmf.5/includes/GlobalFunctions.php: PHP Notice: Array to string conversion

Such as: https://logstash.wikimedia.org/goto/ba65dd4317ecfef44eac4372c9c13a62

Could you confirm they are the same origin, and will be fixed after wmf8 gets deployed, and not different kind of errors with the same error message?

I am seeing ATM errors:

/wiki/Special:Search?search=<search string>&ns0=1   ErrorException from line 1591 of /srv/mediawiki/php-1.35.0-wmf.5/includes/GlobalFunctions.php: PHP Notice: Array to string conversion

Such as: https://logstash.wikimedia.org/goto/ba65dd4317ecfef44eac4372c9c13a62
Could you confirm they are the same origin, and will be fixed after wmf8 gets deployed, and not different kind of errors with the same error message?

These have the same error signature, essentially bots sending excessively long search queries. They will be covered by the fix.

Thank you for checking!

TJones closed this task as Resolved.Nov 27 2019, 4:40 PM

Change 553519 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Do not run wfEscapeWikiText on array in Status class

https://gerrit.wikimedia.org/r/553519

Change 553519 merged by jenkins-bot:
[mediawiki/core@master] Do not run wfEscapeWikiText on array in Status class

https://gerrit.wikimedia.org/r/553519