List of steps to reproduce (step by step, including full links if applicable):
- Ensure the LocalRepo is running with 'useJsonMetadata' => true. One possible way is to copy the $wgLocalFileRepo definition from Setup.php and adjust or copy the definition from wmf: https://gerrit.wikimedia.org/g/operations/mediawiki-config/+/5381dc89efa59889a7d21f2286f78a31fbb6bb0b/wmf-config/filebackend.php#233 and adjust
- Upload a new file or run maintenance\refreshImageMetadata.php --convert-to-json
- Delete a file with json metadata
- Visit action=query&list=filearchive&faprop=metadata, may with extra &faprefix=<your file> and it will get a php warning
What happens?:
No metadata are shown and a php notice is emitted (Notice: unserialize(): Error at offset 0 of 718 bytes)
Reason:
if ( $fld_metadata && $canViewFile ) { $file['metadata'] = $row->fa_metadata ? ApiQueryImageInfo::processMetaData( unserialize( $row->fa_metadata ), $result ) : null; }
The unserialize no longer works for JSON stored metadata. The code from LocalFile::loadMetadataFromDbFieldValue needs to be called
What should have happened instead?:
Metadata should be shown. If used together with 'useSplitMetadata' => true, the metadata may loaded from external source as well.
Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc:
The json metadata was build for T275268
The api part for non-deleted files prop=imageinfo is using File::getMetadataArray and is not effected