Page MenuHomePhabricator

Error: Cannot unset string offsets (in includes/Media/GIFHandler.php)
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
  • mwversion: 1.46.0-wmf.22
  • timestamp: 2026-04-06T01:26:23.125Z
  • phpversion: 8.3.30
  • reqId: 2039edbc-c335-4e67-8e73-28ca6b149bac
  • Find reqId in Logstash
normalized_message
[{reqId}] {exception_url}   Error: Cannot unset string offsets
FrameLocationCall
from/srv/mediawiki/php-1.46.0-wmf.22/includes/Media/GIFHandler.php(78)
#0/srv/mediawiki/php-1.46.0-wmf.22/includes/FileRepo/File/File.php(865)MediaWiki\Media\GIFHandler->getCommonMetaArray(MediaWiki\FileRepo\File\OldLocalFile)
#1/srv/mediawiki/php-1.46.0-wmf.22/includes/Api/ApiQueryImageInfo.php(628)MediaWiki\FileRepo\File\File->getCommonMetaArray()
#2/srv/mediawiki/php-1.46.0-wmf.22/includes/Api/ApiQueryImageInfo.php(262)MediaWiki\Api\ApiQueryImageInfo::getInfo(MediaWiki\FileRepo\File\OldLocalFile, array, MediaWiki\Api\ApiResult, null, array)
#3/srv/mediawiki/php-1.46.0-wmf.22/includes/Api/ApiQuery.php(735)MediaWiki\Api\ApiQueryImageInfo->execute()
#4/srv/mediawiki/php-1.46.0-wmf.22/includes/Api/ApiMain.php(2059)MediaWiki\Api\ApiQuery->execute()
#5/srv/mediawiki/php-1.46.0-wmf.22/includes/Api/ApiMain.php(964)MediaWiki\Api\ApiMain->executeAction()
#6/srv/mediawiki/php-1.46.0-wmf.22/includes/Api/ApiMain.php(935)MediaWiki\Api\ApiMain->executeActionWithErrorHandling()
#7/srv/mediawiki/php-1.46.0-wmf.22/includes/Api/ApiEntryPoint.php(138)MediaWiki\Api\ApiMain->execute()
#8/srv/mediawiki/php-1.46.0-wmf.22/includes/MediaWikiEntryPoint.php(180)MediaWiki\Api\ApiEntryPoint->execute()
#9/srv/mediawiki/php-1.46.0-wmf.22/api.php(30)MediaWiki\MediaWikiEntryPoint->run()
#10/srv/mediawiki/w/api.php(3)require(string)
#11{main}
Impact
Notes

Details

Request URL
https://el.wikipedia.org/w/api.php?action=query&format=*&iilimit=*&iiprop=*&prop=*&titles=*
Related Changes in Gerrit:

Event Timeline

BPirkle subscribed.

I suspect that MediaWiki Interfaces was tagged because the entry point is api.php, but the actual issue seems to be in /Media/GIFHandler.

Please retag us if I'm mis-triaging.

I suspect that MediaWiki Interfaces was tagged because the entry point is api.php, but the actual issue seems to be in /Media/GIFHandler.

Please retag us if I'm mis-triaging.

Thank you @BPirkle. I was flailing.

Change #1269598 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/core@master] Media: Check to return array from GIFHandler::getCommonMetaArray

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

Umherirrender renamed this task from Error: Cannot unset string offsets to Error: Cannot unset string offsets (in includes/Media/GIFHandler.php).Apr 9 2026, 7:20 PM

Change #1269598 merged by jenkins-bot:

[mediawiki/core@master] Media: Check to return array from GIFHandler::getCommonMetaArray

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

"The 'metadata' key could be an string,"

I was curious why this would suddenly happen. It seems that this is triggered by file Mannlicher-Schoenauer_1903_drawing.gif on Commons which seems to be a pretty old file, so why do we suddenly have this error ?

I've looked at the db data and it's img_metadata field looks like:

a:3:{s:10:"frameCount";i:1;s:6:"looped";b:0;s:8:"duration";d:0;}

A normal frame (that is also still php serialized, as modern serialization is in json) looks like:

a:4:{s:10:"frameCount";i:1;s:6:"looped";b:0;s:8:"duration";d:0;s:8:"metadata";a:1:{s:15:"_MW_GIF_VERSION";i:1;}}

I suspect this is a bug in loadMetadataFromString, which isn't able to handle very old GIF metadata entries.

A wait, it's fetching the metadata for an old version.. (OldLocalFile)

I found this on commons:

a:4:{s:5:"width";i:1000;s:6:"height";i:285;s:8:"metadata";s:358:" <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> <cc:Work rdf:about=""> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:title/> </cc:Work> </rdf:RDF> ";s:7:"version";i:2;}

One of the revisions of the image is an SVG instead of a GIF, and the metadata for that revision does indeed have a string metadata subelement.
There are 498879 old revisions and 637897 current revisions of SVG in this format, so that structure is common for SVGs

Strange that it used the GIFHandler for an old file record that is marked in the DB as being of type SVG for that version. That means it initialized the handler based on the current revisions' mime type, instead of the old file's mime type. Don't remember if that is expected...

Actually doing the same request on Commons against the api DOES work.

https://commons.wikimedia.org/wiki/Special:ApiSandbox#action=query&format=json&prop=imageinfo&titles=File%3AMannlicher-Schoenauer_1903_drawing.gif%7CFile%3AM1903xf.jpg%20&formatversion=2&iiprop=archivename%7Cbadfile%7Cbitdepth%7Ccanonicaltitle%7Ccomment%7Ccommonmetadata%7Cdimensions%7Cextmetadata%7Cmediatype%7Cmetadata%7Cmime%7Cparsedcomment%7Csha1%7Csize%7Cthumbmime%7Ctimestamp%7Cuploadwarning%7Curl%7Cuser%7Cuserid&iilimit=max

Fails:

https://el.wikipedia.org/wiki/Special:ApiSandbox#action=query&format=json&prop=imageinfo&titles=File%3AMannlicher-Schoenauer_1903_drawing.gif%7CFile%3AM1903xf.jpg%20&formatversion=2&iiprop=archivename%7Cbadfile%7Cbitdepth%7Ccanonicaltitle%7Ccomment%7Ccommonmetadata%7Cdimensions%7Cextmetadata%7Cmediatype%7Cmetadata%7Cmime%7Cparsedcomment%7Csha1%7Csize%7Cthumbmime%7Ctimestamp%7Cuploadwarning%7Curl%7Cuser%7Cuserid&iilimit=max

so it might be a ForeignDbRepo problem ????

Maybe this is due to changes related to T28741 ? In the new file/filerevision situation, we only allow a single filetype for all of the revisions of one file entry... and el.wikipedia might be switched over already to read from the new tables T416548 and then ForeignDbRepo would read using the new tables as well, detect gif type, and initialize the GIFHandler for the file revision, which is then unable to read out the SVG specific metadata of that revision ?

One comment to old file says "Now it is an SVG file.", so this is really a svg file uploaded with the file extensions ".gif", it was reverted on the same day and uploaded to https://commons.wikimedia.org/wiki/File:Mannlicher-Schoenauer_1903_drawing.svg instead.

The commons api reports the mime type for the old version correct as "image/svg+xml", while the elwiki api reports "image/gif" (maybe based on file extensions).
Similiar problems with mime type can happen on redirects as well, see T419860.

But should be handled in a new task, as this error is fixed, it just shows no metadata in that situation now. Not sure if there was a master plan for situation like this within the new schema design.