Page MenuHomePhabricator

ContentTranslation API: PHP Warning: min(): Array must contain at least one element
Closed, ResolvedPublicPRODUCTION ERROR

Description

Summmary

Content Translation extensions causes PHP warnings on an edge case when viewing Special:CXStats, despite the warnings, no functionality was affected.

Error

MediaWiki version: 1.35.0-wmf.30

message
PHP Warning: min(): Array must contain at least one element

Impact

Perhaps no user-facing impact. 1 of these in the wild since deploy of 1.35.0-wmf.30, URL returns:

9:31:24 brennen@inertia:~ ✵ curl 'https://gcr.wikipedia.org/w/api.php?action=query&format=json&list=contenttranslationlangtrend&target=gcr'
{"batchcomplete":"","query":{"contenttranslationlangtrend":{"translations":[{"count":0,"delta":0,"date":"2020-05-03"}],"drafts":[{"count":0,"delta":0,"date":"2020-05-03"}],"deletions":[{"count":0,"delta":0,"date":"2020-05-03"}]}}}

Looks well-formed, at any rate. Throws the warning every time.

QA plan

Affected projects: gcr.wikipedia.org
Pre-deployment testing: skip
Post-deployment testing:

Outcome

Content Translation produces less log spam

Details

Request ID
a0cb2d63-2108-411e-a834-66b25192af5b
Request URL
https://gcr.wikipedia.org/w/api.php?action=query&format=json&list=contenttranslationlangtrend&target=gcr
Stack Trace
exception.trace
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.35.0-wmf.30/extensions/ContentTranslation/api/ApiQueryContentTranslationLanguageTrend.php(59): min(array)
#2 /srv/mediawiki/php-1.35.0-wmf.30/extensions/ContentTranslation/api/ApiQueryContentTranslationLanguageTrend.php(46): ApiQueryContentTranslationLanguageTrend->addMissingDates(array, string)
#3 /srv/mediawiki/php-1.35.0-wmf.30/includes/api/ApiQuery.php(263): ApiQueryContentTranslationLanguageTrend->execute()
#4 /srv/mediawiki/php-1.35.0-wmf.30/includes/api/ApiMain.php(1580): ApiQuery->execute()
#5 /srv/mediawiki/php-1.35.0-wmf.30/includes/api/ApiMain.php(523): ApiMain->executeAction()
#6 /srv/mediawiki/php-1.35.0-wmf.30/includes/api/ApiMain.php(494): ApiMain->executeActionWithErrorHandling()
#7 /srv/mediawiki/php-1.35.0-wmf.30/api.php(84): ApiMain->execute()
#8 /srv/mediawiki/w/api.php(3): require(string)
#9 {main}

Event Timeline

brennen created this task.Apr 30 2020, 4:12 PM
Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald TranscriptApr 30 2020, 4:12 PM
brennen moved this task from Backlog to Logs/Train on the User-brennen board.Apr 30 2020, 4:13 PM

Change 595917 had a related patch set uploaded (by Nikerabbit; owner: Nikerabbit):
[mediawiki/extensions/ContentTranslation@master] Avoid PHP Warning: min(): Array must contain at least one element

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

Nikerabbit updated the task description. (Show Details)May 12 2020, 2:12 PM

Change 595917 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Avoid PHP Warning: min(): Array must contain at least one element

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

Pginer-WMF triaged this task as Medium priority.May 15 2020, 11:48 AM
Pginer-WMF moved this task from Needs Triage to Bugs on the ContentTranslation board.
Nikerabbit updated the task description. (Show Details)May 28 2020, 11:47 AM
Jpita added a subscriber: Jpita.Jun 10 2020, 6:00 AM

I get an error and blank page when i go to https://gcr.wikipedia.org/wiki/Special:CXStats

Looks like more work is needed. The frontend does not handle the current response {"batchcomplete":"","query":{"contenttranslationlangtrend":[]}}

Change 607275 had a related patch set uploaded (by Nikerabbit; owner: Nikerabbit):
[mediawiki/extensions/ContentTranslation@master] Handle missing stats gracefully in Special:CXSStats

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

Change 607275 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Handle missing stats gracefully in Special:CXStats

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

Jpita closed this task as Resolved.Jul 6 2020, 1:06 PM