Page MenuHomePhabricator

MediaModerationPhotoDNAServiceProvider provides false to FileBackend::getFileContents causing a PHP Notice
Closed, ResolvedPublic2 Estimated Story PointsBUG REPORT

Description

Error details
message
[{reqId}] {exception_url}   PHP Notice: Undefined offset: 0
trace
from /srv/mediawiki/php-1.42.0-wmf.10/includes/libs/filebackend/FileBackend.php(1020)
#0 /srv/mediawiki/php-1.42.0-wmf.10/includes/libs/filebackend/FileBackend.php(1020): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.42.0-wmf.10/extensions/MediaModeration/src/Services/MediaModerationPhotoDNAServiceProvider.php(210): FileBackend->getFileContents(array)
#2 /srv/mediawiki/php-1.42.0-wmf.10/extensions/MediaModeration/src/Services/MediaModerationPhotoDNAServiceProvider.php(125): MediaWiki\Extension\MediaModeration\Services\MediaModerationPhotoDNAServiceProvider->getThumbnailContents(ThumbnailImage)
#3 /srv/mediawiki/php-1.42.0-wmf.10/extensions/MediaModeration/src/Services/MediaModerationPhotoDNAServiceProvider.php(76): MediaWiki\Extension\MediaModeration\Services\MediaModerationPhotoDNAServiceProvider->getRequest(LocalFile)
#4 /srv/mediawiki/php-1.42.0-wmf.10/extensions/MediaModeration/maintenance/scanFilesInScanTable.php(97): MediaWiki\Extension\MediaModeration\Services\MediaModerationPhotoDNAServiceProvider->check(LocalFile)
#5 /srv/mediawiki/php-1.42.0-wmf.10/maintenance/includes/MaintenanceRunner.php(703): MediaWiki\Extension\MediaModeration\Maintenance\ScanFilesInScanTable->execute()
#6 /srv/mediawiki/php-1.42.0-wmf.10/maintenance/run.php(51): MediaWiki\Maintenance\MaintenanceRunner->run()
#7 /srv/mediawiki/multiversion/MWScript.php(158): require_once(string)
#8 {main}
Steps to replicate
  1. Install the MediaModeration extension
  2. Run the scanFilesInScanTable.php maintenance script provided by MediaModeration
  3. Inspect the server logs

What happens: Several warnings appear about an undefined offest 0.
What should happen: These should be handled such that no php notice is created.

Notes

Seems to be because a value of false is being provided to FileBackend::getFileContents as the value of the src key. This gets presumably converted to a 0 by PHP typecasting to a string.

Event Timeline

Dreamy_Jazz added a subscriber: kostajh.

This had 3,000 entries in Logstash when the script was run on testwiki. This suggests that it blocks running a scan on commonswiki.

Change 984293 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/MediaModeration@master] Check for false from ThumbnailImage::getStoragePath

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

Change 984324 had a related patch set uploaded (by Kosta Harlan; author: Dreamy Jazz):

[mediawiki/extensions/MediaModeration@wmf/1.42.0-wmf.10] Check for false from ThumbnailImage::getStoragePath

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

Change 984293 merged by jenkins-bot:

[mediawiki/extensions/MediaModeration@master] Check for false from ThumbnailImage::getStoragePath

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

Change 984324 merged by jenkins-bot:

[mediawiki/extensions/MediaModeration@wmf/1.42.0-wmf.10] Check for false from ThumbnailImage::getStoragePath

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

Mentioned in SAL (#wikimedia-operations) [2023-12-20T14:21:00Z] <lucaswerkmeister-wmde@deploy2002> Started scap: Backport for [[gerrit:984324|Check for false from ThumbnailImage::getStoragePath (T353758)]]

Mentioned in SAL (#wikimedia-operations) [2023-12-20T14:22:18Z] <lucaswerkmeister-wmde@deploy2002> kharlan and lucaswerkmeister-wmde: Backport for [[gerrit:984324|Check for false from ThumbnailImage::getStoragePath (T353758)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2023-12-20T14:30:39Z] <lucaswerkmeister-wmde@deploy2002> Finished scap: Backport for [[gerrit:984324|Check for false from ThumbnailImage::getStoragePath (T353758)]] (duration: 09m 38s)

Dreamy_Jazz changed the point value for this task from 1 to 2.

This will be difficult to effectively QA and cannot be done on betawikis. I propose that QA be skipped for this ticket and brought into the QA of T351399 (as this ticket adds a fix for the code added in that ticket).

I concur with Dreamy_Jazz's comment regarding QA and therefore am pushing this ticket to Done.