Page MenuHomePhabricator

Logspam from TwnMainPage: Undefinex index: [group id] in multiple locations
Closed, ResolvedPublic

Description

[10-Apr-2019 07:18:24 UTC] PHP Notice: Undefined index: etherpad-lite in /srv/mediawiki/tags/2019-04-03_21:01:50/extensions/TwnMainPage/ProjectHandler.php on line 61
[10-Apr-2019 07:18:24 UTC] PHP Notice: Undefined index: out-freecol in /srv/mediawiki/tags/2019-04-03_21:01:50/extensions/TwnMainPage/ProjectHandler.php on line 62
[10-Apr-2019 07:18:24 UTC] PHP Notice: Undefined index: ajapaik in /srv/mediawiki/tags/2019-04-03_21:01:50/extensions/TwnMainPage/specials/SpecialTwnMainPage.php on line 230

Diagnosis:

  • Code does not take into account that cached stats might not be available.

Expected results:

  • Graceful fallback without logspam.

Impact:

  • Logspam. Probably does not affect display or behavior.

Test plan:

  • Manual test: Truncate the stats table, load the main page, assure that notices appear before the fix and don't appear after the fix

Event Timeline

abi_ moved this task from Backlog to In Progress on the User-abi_ board.

I setup TwnMainPage extension, setup two projects locally - Etherpad-lite and MathJax and tried to reproduce the issue. Deleted the data from the translate_groupstats table, and reloaded the main page. I'm having trouble reproducing the issue.

SpecialTwnMainPage->projectSelector > MessageGroupStats::forLanguage > MessageGroupStats::forLanguageInternal > MessageGroupStats::forItemInternal which then runs the following code - $stats[$id][$code] = self::getUnknownStats() because $flag is set to FLAG_CACHE_ONLY. This populates the array with null values and hence we should not be seeing these notices at all.

See - https://github.com/wikimedia/mediawiki-extensions-Translate/blob/454c23e9c02a4d5980035aa1926a701acc713198/utils/MessageGroupStats.php#L437-L440

Are these notices a one off occurrence or have they been happening regularly? I cannot see how these would occur unless there was some sort of caching discrepancy.

Reviewed the logs on the server for translatewiki.net and noticed that these errors occurred last on,

  1. 19-Apr-2019 14:18:12 UTC
  2. 10-Apr-2019 07:18:24 UTC (Same as the time this issue was created)

I could not find the logs for March, and Feb, would like to see the pattern for these during that timeperiod as well.

In case it might be useful, last server reboot was on the 30th of March, 2019

$ who -b
system boot  2019-03-30 00:43

It seems I had misdiagnosed the issue. By inspecting code, the cause seems to be coming from https://github.com/wikimedia/mediawiki-extensions-Translate/blob/master/utils/MessageGroupStats.php#L109 which returns unknown stats, but in the wrong format (not keyed by group id) when language is invalid. You should be able to reproduce by adding ?uselang=something when requesting the main page.

Change 508121 had a related patch set uploaded (by Abijeet Patro; owner: Abijeet Patro):
[mediawiki/extensions/Translate@master] Fix notice appearing on TwnMainPage due to invalid return format

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

It seems I had misdiagnosed the issue. By inspecting code, the cause seems to be coming from https://github.com/wikimedia/mediawiki-extensions-Translate/blob/master/utils/MessageGroupStats.php#L109 which returns unknown stats, but in the wrong format (not keyed by group id) when language is invalid. You should be able to reproduce by adding ?uselang=something when requesting the main page.

I should have noticed that. Thanks.

I've pushed a fix for this. When an invalid language is passed to MessageGroupStats::forLanguage the data will be returned in the same format as a valid language.

See image below,

T220583-1.png (725×1 px, 541 KB)

abi_ moved this task from Under Review to Done on the User-abi_ board.
abi_ removed a project: Patch-For-Review.

Change 508121 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Fix notice appearing on TwnMainPage due to invalid return format

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