Page MenuHomePhabricator

getid3: PHP Notice: Trying to access array offset on value of type null
Open, Needs TriagePublicPRODUCTION ERROR

Description

Error
labels.normalized_message
[{reqId}] {exception_url}   PHP Notice: Trying to access array offset on value of type null
FrameLocationCall
from/srv/mediawiki/php-1.44.0-wmf.3/vendor/james-heinrich/getid3/getid3/module.audio-video.mpeg.php(508)
#0/srv/mediawiki/php-1.44.0-wmf.3/vendor/james-heinrich/getid3/getid3/module.audio-video.mpeg.php(508)MWExceptionHandler::handleError(int, string, string, int, array)
#1/srv/mediawiki/php-1.44.0-wmf.3/vendor/james-heinrich/getid3/getid3/getid3.php(781)getid3_mpeg->Analyze()
#2/srv/mediawiki/php-1.44.0-wmf.3/extensions/TimedMediaHandler/includes/Handlers/ID3Handler/ID3Handler.php(39)getID3->analyze(string)
#3/srv/mediawiki/php-1.44.0-wmf.3/extensions/TimedMediaHandler/includes/Handlers/ID3Handler/ID3Handler.php(58)MediaWiki\TimedMediaHandler\Handlers\ID3Handler\ID3Handler->getID3(string)
#4/srv/mediawiki/php-1.44.0-wmf.3/includes/media/MediaHandler.php(243)MediaWiki\TimedMediaHandler\Handlers\ID3Handler\ID3Handler->getMetadata(Wikimedia\FileBackend\FSFile\FSFile, string)
#5/srv/mediawiki/php-1.44.0-wmf.3/includes/utils/MWFileProps.php(93)MediaHandler->getSizeAndMetadataWithFallback(Wikimedia\FileBackend\FSFile\FSFile, string)
#6/srv/mediawiki/php-1.44.0-wmf.3/includes/upload/UploadBase.php(585)MWFileProps->getPropsFromPath(string, string)
#7/srv/mediawiki/php-1.44.0-wmf.3/includes/upload/UploadFromChunks.php(464)UploadBase->verifyPartialFile()
#8/srv/mediawiki/php-1.44.0-wmf.3/includes/upload/UploadFromChunks.php(330)UploadFromChunks->verifyChunk()
#9/srv/mediawiki/php-1.44.0-wmf.3/includes/api/ApiUpload.php(387)UploadFromChunks->addChunk(string, int, int)
#10/srv/mediawiki/php-1.44.0-wmf.3/includes/api/ApiUpload.php(255)MediaWiki\Api\ApiUpload->getChunkResult(array)
#11/srv/mediawiki/php-1.44.0-wmf.3/includes/api/ApiUpload.php(172)MediaWiki\Api\ApiUpload->getContextResult()
#12/srv/mediawiki/php-1.44.0-wmf.3/includes/api/ApiMain.php(1975)MediaWiki\Api\ApiUpload->execute()
#13/srv/mediawiki/php-1.44.0-wmf.3/includes/api/ApiMain.php(943)MediaWiki\Api\ApiMain->executeAction()
#14/srv/mediawiki/php-1.44.0-wmf.3/includes/api/ApiMain.php(914)MediaWiki\Api\ApiMain->executeActionWithErrorHandling()
#15/srv/mediawiki/php-1.44.0-wmf.3/includes/api/ApiEntryPoint.php(153)MediaWiki\Api\ApiMain->execute()
#16/srv/mediawiki/php-1.44.0-wmf.3/includes/MediaWikiEntryPoint.php(200)MediaWiki\Api\ApiEntryPoint->execute()
#17/srv/mediawiki/php-1.44.0-wmf.3/api.php(44)MediaWiki\MediaWikiEntryPoint->run()
#18/srv/mediawiki/w/api.php(3)require(string)
#19{main}
Notes

64 of these since rolling 1.44.0-wmf.3 (T375662) to group1. Spitballing some tags here.

Details

Request URL
https://commons.wikimedia.org/w/api.php

Event Timeline

@brennen ah yes my old nemesis, getid3's MPEG parser

likely course of action:

  • check for upstream updates that might have cleaned this code up
  • if not, look in and follow the logic and make a patch for the bogus variable (possibly related to parsing a partial file chunk and not getting expected bytes, possibly not)
  • submit patch upstream and ask for maintainer to branch a release if possible
  • pull the updated release in composer.json and update TimedMediaHandler

I would not consider this very high priority right now while we're in crunch on Charts, but if it doesn't get cleaned up earlier it'll be on my tech debt list in late December and January.

Amusingly, Tim last touched that line in https://github.com/JamesHeinrich/getID3/commit/273e47678035658a6c1c6837448f1732026b77cb

https://github.com/JamesHeinrich/getID3/blame/143af33/getid3/module.audio-video.mpeg.php#L512

		if (!empty($info['mpeg']['video']['bitrate_mode']) && ($info['mpeg']['video']['bitrate_mode'] == 'vbr')) {
			$last_GOP_id = max(array_keys($FramesByGOP));
			$frames_in_last_GOP = count($FramesByGOP[$last_GOP_id]);
			$gopdata = &$info['mpeg']['group_of_pictures'][$last_GOP_id];
			$info['playtime_seconds'] = ($gopdata['time_code_hours'] * 3600) + ($gopdata['time_code_minutes'] * 60) + $gopdata['time_code_seconds'] + getid3_lib::SafeDiv($gopdata['time_code_pictures'] + $frames_in_last_GOP + 1, $info['mpeg']['video']['frame_rate']);
			if (!isset($info['video']['bitrate'])) {
				$overall_bitrate = getid3_lib::SafeDiv($info['avdataend'] - $info['avdataoffset'] * 8, $info['playtime_seconds']);
				$info['video']['bitrate'] = $overall_bitrate - (isset($info['audio']['bitrate']) ? $info['audio']['bitrate'] : 0);
			}
			unset($info['mpeg']['group_of_pictures']);
		}

I'm guessing $gopdata is null in this case, based on $info being in the guard condition to get in here...

The fact it is in chunked uploading code, we could be passing in bad data in the first place.