# Logspam from TwnMainPage: Undefinex index: [group id] in multiple locationsClosed, ResolvedPublicActions

Assigned To
 abi_
Authored By
 Nikerabbit Apr 10 2019, 7:44 AM2019-04-10 07:44:39 (UTC+0)
Referenced Files
 F28932535: T220583-1.png May 5 2019, 5:05 PM2019-05-05 17:05:18 (UTC+0)
Subscribers

# 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

Restricted Application added a subscriber: Aklapper. Apr 10 2019, 7:44 AM
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.

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,

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

Marking as done, since it has been verified by Niklas on Translatewiki.net

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