Page MenuHomePhabricator

PHP Warning: "Invalid argument supplied for foreach()" from ApiEchoMute.php
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error message
PHP Warning: Invalid argument supplied for foreach()
Stack Trace
#0 /srv/mediawiki/php-1.35.0-wmf.35/extensions/Echo/includes/api/ApiEchoMute.php(77): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.35.0-wmf.35/extensions/Echo/includes/api/ApiEchoMute.php(44): ApiEchoMute->lookupIds(NULL, string)
#2 /srv/mediawiki/php-1.35.0-wmf.35/includes/api/ApiMain.php(1584): ApiEchoMute->execute()
#3 /srv/mediawiki/php-1.35.0-wmf.35/includes/api/ApiMain.php(524): ApiMain->executeAction()
#4 /srv/mediawiki/php-1.35.0-wmf.35/includes/api/ApiMain.php(495): ApiMain->executeActionWithErrorHandling()
#5 /srv/mediawiki/php-1.35.0-wmf.35/api.php(84): ApiMain->execute()
Impact

Unsure. To be determined.

Notes

The API code in question was recently introduced by https://gerrit.wikimedia.org/r/592806, which makes it likely a regression from that commit (/cc @Catrope, @Tgr).

The mute and unmute parameters are optional and without a default, which means they are provided by ApiBase as null, which is not a valid iterable value. Depending on whether absence of these is intentional or not, it is quite likely that it happens to behave correctly for end-users since an empty array and null would both lead to the same code execution. In any case, the error should be fixed, silenced, worked around to remove it from from production error logs, which can currently impact deployments and alerts.

Event Timeline

Krinkle created this task.Jun 7 2020, 11:07 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 7 2020, 11:07 PM

Logstash and Gerrit both show with high confidence that it was definitely a regression from last week so retroactively tracking at T253023 for statistics, but not a train blocker anymore.

Tgr added a comment.Jun 8 2020, 11:44 AM

This happens because both the mute and unmmute list are iterated on but on practice only one of them will be present.

Change 604388 had a related patch set uploaded (by Gergő Tisza; owner: Gergő Tisza):
[mediawiki/extensions/Echo@master] Ensure an array is passed to ApiEchoMute::lookupIds()

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

Change 604388 merged by jenkins-bot:
[mediawiki/extensions/Echo@master] Ensure an array is passed to ApiEchoMute::lookupIds()

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

Tgr closed this task as Resolved.Jun 10 2020, 3:42 PM
Tgr claimed this task.

This was a DX issue, so we can skip QA / PM review.

Change 604848 had a related patch set uploaded (by Krinkle; owner: Gergő Tisza):
[mediawiki/extensions/Echo@wmf/1.35.0-wmf.36] Ensure an array is passed to ApiEchoMute::lookupIds()

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

Change 604848 abandoned by Jforrester:
Ensure an array is passed to ApiEchoMute::lookupIds()

Reason:
All prod is now running wmf.37.

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