Page MenuHomePhabricator

PHP error "Undefined index: Q…" from ArticlePlaceholder hook on SpecialSearch
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

Request ID: GBocAAABD

message
PHP Notice: Undefined index: Q70972
PHP Notice: Undefined index: Q13202722
...

#0 /srv/mediawiki/php-1.32.0-wmf.24/extensions/ArticlePlaceholder/includes/ItemNotabilityFilter.php(86): MWExceptionHandler::handleError(integer, string, string, integer, array, array)
#1 /srv/mediawiki/php-1.32.0-wmf.24/extensions/ArticlePlaceholder/includes/SearchHookHandler.php(238): ArticlePlaceholder\ItemNotabilityFilter->getNotableEntityIds(array)
#2 /srv/mediawiki/php-1.32.0-wmf.24/extensions/ArticlePlaceholder/includes/SearchHookHandler.php(182): ArticlePlaceholder\SearchHookHandler->renderTermSearchResults(array)
#3 /srv/mediawiki/php-1.32.0-wmf.24/extensions/ArticlePlaceholder/includes/SearchHookHandler.php(170): ArticlePlaceholder\SearchHookHandler->addToSearch(SpecialSearch, OutputPage, string)
#4 /srv/mediawiki/php-1.32.0-wmf.24/includes/Hooks.php(174): ArticlePlaceholder\SearchHookHandler::onSpecialSearchResultsAppend(SpecialSearch, OutputPage, string)
#5 /srv/mediawiki/php-1.32.0-wmf.24/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#6 /srv/mediawiki/php-1.32.0-wmf.24/includes/specials/SpecialSearch.php(479): Hooks::run(string, array)
#7 /srv/mediawiki/php-1.32.0-wmf.24/includes/specials/SpecialSearch.php(190): SpecialSearch->showResults(string)
#8 /srv/mediawiki/php-1.32.0-wmf.24/includes/specialpage/SpecialPage.php(569): SpecialSearch->execute(NULL)

Impact

Unknown. The code is expecting an array with certain fields, these are missing.

The code is not expecting this, and unfortunately PHP continues regardless assuming any unknown key of the array is null. It is unclear whether in such case the correct behaviour is for the code to follow the true-branch, the false-branch, or something else entirely.

Notes

Last 30 days:

  • Domains: test.wikipedia.org, wikidata.org, test2.wikipedia.org.

Logstash showing last 7 day occurrences: https://logstash.wikimedia.org/goto/f36478eb9f0a83a8c5549374af5b53e4

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Was first seen on 1.32.0-wmf.24, but may've been older due to limited log retention. Impact currently unknown. Unhandled/Implicit code conditions are sometimes innocent, other times it may be cause for cascading problems that themselves might not be logged due to being "the wrong thing, but succeeding at being wrong without errors" - type of code paths being invoked.

Triaging as Meta given limited to test wikis (for now).

This likely has to do with the switch to using cirrus / elastic for the search mechanism here instead of using our wb_terms table.

So it looks like ItemNotabilityFilter::selectPagePropsPage must be failing to select any page props for the given items.
As a result getPagePropsByItem returns an array of values without the given item id having a key.
getNotableEntityIds then assumes that all entities that we enquired about will have an entry in the returned array.


Looking specifically at a couple of error instances i spotted on bn.wikipedia.org:
https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2018.10.20/mediawiki/?id=AWaPoc2mN-apXXYu4qqy
https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2018.10.19/mediawiki/?id=AWaNNjeE00on8STvZ6qi

These refer to 2 keys / entity ids missing, Q56258025 and Q56508858

Looking at these on wikidata they are both redirects.
https://www.wikidata.org/w/index.php?title=Q56258025
https://www.wikidata.org/w/index.php?title=Q56508858

The redirect creation date however was far from the time of the error...

Looking at the error the page props are correctly been moved to the next entity.

mysql:research@analytics-store.eqiad.wmnet [wikidatawiki]> select * from page_props where pp_page = 56196493;
Empty set (0.02 sec)

mysql:research@analytics-store.eqiad.wmnet [wikidatawiki]> select * from page_props where pp_page = 13271670;
+----------+-----------------+-----------------------------+------------+
| pp_page  | pp_propname     | pp_value                    | pp_sortkey |
+----------+-----------------+-----------------------------+------------+
| 13271670 | page_image_free | Humayun_Ahmed_13Nov2010.jpg |       NULL |
| 13271670 | wb-claims       | 52                          |         52 |
| 13271670 | wb-identifiers  | 20                          |         20 |
| 13271670 | wb-sitelinks    | 11                          |         11 |
+----------+-----------------+-----------------------------+------------+
4 rows in set (0.01 sec)

My theroy is that the search takes some time to update, so for a time it could still return an old item ID that is now a redirect and thus has no page props.

We could:

  • Just ignore items like this, ignore keys that do not exist in the array returned by the get page props method.
  • Add some redirect resolving stuff into the mix here at some point, so that we get the pages props for the ID that our ID redirects to.
Addshore added a subscriber: Lydia_Pintscher.

@Lydia_Pintscher I guess this decision lies in your hands now. Which of the 2 options above would you like?
Option 1 would mean that after a redirect has happened it might take a bit of time for that entity to show up as an article placeholder suggestio. (Discovery-ARCHIVED would probably be able to let us know how quickly the index updates for this)
Option 2 would add a little bit of extra run time to generate the list, but should be totally fine.

Addshore moved this task from Inbox to Small Code Fixes on the [DEPRECATED] wdwb-tech board.

Still seen.

Request ID: XJ1gwApAAC4AADrz5ZIAAABC

PHP Notice: Undefined index: Q157…


#0 /srv/mediawiki/php-1.33.0-wmf.23/extensions/ArticlePlaceholder/includes/ItemNotabilityFilter.php(85): MWExceptionHandler::handleError(integer, string, string, integer, array, array)
#1 /srv/mediawiki/php-1.33.0-wmf.23/extensions/ArticlePlaceholder/includes/SearchHookHandler.php(238): ArticlePlaceholder\ItemNotabilityFilter->getNotableEntityIds(array)
#2 /srv/mediawiki/php-1.33.0-wmf.23/extensions/ArticlePlaceholder/includes/SearchHookHandler.php(182): ArticlePlaceholder\SearchHookHandler->renderTermSearchResults(array)
#3 /srv/mediawiki/php-1.33.0-wmf.23/extensions/ArticlePlaceholder/includes/SearchHookHandler.php(170): ArticlePlaceholder\SearchHookHandler->addToSearch(SpecialSearch, OutputPage, string)
#4 /srv/mediawiki/php-1.33.0-wmf.23/includes/Hooks.php(174): ArticlePlaceholder\SearchHookHandler::onSpecialSearchResultsAppend(SpecialSearch, OutputPage, string)
#5 /srv/mediawiki/php-1.33.0-wmf.23/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#6 /srv/mediawiki/php-1.33.0-wmf.23/includes/specials/SpecialSearch.php(490): Hooks::run(string, array)
#7 /srv/mediawiki/php-1.33.0-wmf.23/includes/specials/SpecialSearch.php(176): SpecialSearch->showResults(string)
#8 /srv/mediawiki/php-1.33.0-wmf.23/includes/specialpage/SpecialPage.php(569): SpecialSearch->execute(NULL)
#9 /srv/mediawiki/php-1.33.0-wmf.23/includes/specialpage/SpecialPageFactory.php(558): SpecialPage->run(NULL)
#10 /srv/mediawiki/php-1.33.0-wmf.23/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#11 /srv/mediawiki/php-1.33.0-wmf.23/includes/MediaWiki.php(867): MediaWiki->performRequest()
#12 /srv/mediawiki/php-1.33.0-wmf.23/includes/MediaWiki.php(517): MediaWiki->main()
#13 /srv/mediawiki/php-1.33.0-wmf.23/index.php(42): MediaWiki->run()

Still seen, several hundred times per day. User impact remains undetermined and unknown.

  • Request: GET /w/index.php?title=Special%3ASearch&search= … &go=OK
  • ID: XN-hfApAADoAACZ-PJ4AAAFJ
PHP Notice: Undefined index: Q22668172
0 /srv/mediawiki/php-1.34.0-wmf.5/extensions/ArticlePlaceholder/includes/ItemNotabilityFilter.php(85): MWExceptionHandler::handleError(integer, string, string, integer, array, array)
#1 /srv/mediawiki/php-1.34.0-wmf.5/extensions/ArticlePlaceholder/includes/SearchHookHandler.php(238): ArticlePlaceholder\ItemNotabilityFilter->getNotableEntityIds(array)
#2 /srv/mediawiki/php-1.34.0-wmf.5/extensions/ArticlePlaceholder/includes/SearchHookHandler.php(182): ArticlePlaceholder\SearchHookHandler->renderTermSearchResults(array)
#3 /srv/mediawiki/php-1.34.0-wmf.5/extensions/ArticlePlaceholder/includes/SearchHookHandler.php(170): ArticlePlaceholder\SearchHookHandler->addToSearch(SpecialSearch, OutputPage, string)
#4 /srv/mediawiki/php-1.34.0-wmf.5/includes/Hooks.php(174): ArticlePlaceholder\SearchHookHandler::onSpecialSearchResultsAppend(SpecialSearch, OutputPage, string)
#5 /srv/mediawiki/php-1.34.0-wmf.5/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#6 /srv/mediawiki/php-1.34.0-wmf.5/includes/specials/SpecialSearch.php(477): Hooks::run(string, array)
#7 /srv/mediawiki/php-1.34.0-wmf.5/includes/specials/SpecialSearch.php(173): SpecialSearch->showResults(string)
#8 /srv/mediawiki/php-1.34.0-wmf.5/includes/specialpage/SpecialPage.php(570): SpecialSearch->execute(NULL)
#9 /srv/mediawiki/php-1.34.0-wmf.5/includes/specialpage/SpecialPageFactory.php(575): SpecialPage->run(NULL)
#10 /srv/mediawiki/php-1.34.0-wmf.5/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#11 /srv/mediawiki/php-1.34.0-wmf.5/includes/MediaWiki.php(865): MediaWiki->performRequest()
#12 /srv/mediawiki/php-1.34.0-wmf.5/includes/MediaWiki.php(515): MediaWiki->main()
#13 /srv/mediawiki/php-1.34.0-wmf.5/index.php(42): MediaWiki->run()

Next steps:

  • ArticlePlaceholder behaviour to be changed to skip missing/incomplete results for an input ID: 5 Story Points
  • Investigate problems with the CirrusSearch/ElasticSearch index: 8h
Krinkle renamed this task from PHP error from ArticlePlaceholder hook on SpecialSearch to PHP error "Undefined index: Q…" from ArticlePlaceholder hook on SpecialSearch.Jun 5 2019, 9:53 AM
Krinkle added a subscriber: hashar.

Change 514462 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/ArticlePlaceholder@master] Do not check for item ids that are not found in page_props table

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

Change 514462 merged by jenkins-bot:
[mediawiki/extensions/ArticlePlaceholder@master] Do not check for item ids that are not found in page_props table

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

Change 516496 had a related patch set uploaded (by Krinkle; owner: Ladsgroup):
[mediawiki/extensions/ArticlePlaceholder@wmf/1.34.0-wmf.8] Do not check for item ids that are not found in page_props table

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

Change 516496 merged by jenkins-bot:
[mediawiki/extensions/ArticlePlaceholder@wmf/1.34.0-wmf.8] Do not check for item ids that are not found in page_props table

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

Mentioned in SAL (#wikimedia-operations) [2019-06-12T18:13:18Z] <krinkle@deploy1001> Synchronized php-1.34.0-wmf.8/extensions/ArticlePlaceholder/includes/: T207235 / rEARPa42aa1599a13 (duration: 00m 49s)

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:08 PM