Page MenuHomePhabricator

PHP Notice: A non well formed numeric value encountered
Closed, ResolvedPublic

Description

After uploading big_buck_bunny_720p_stereo.ogg (downloaded from http://download.blender.org/peach/bigbuckbunny_movies/) using async chunked uploading (with UploadWizard) and running php maintenance/runJobs.php --type=AssembleUploadChunks, I get the following warnings on the console, repeated several times:

PHP Notice:  A non well formed numeric value encountered in /var/www/html/w/extensions/TimedMediaHandler/handlers/OggHandler/File_Ogg/File/Ogg/Vorbis.php on line 188
PHP Notice:  A non well formed numeric value encountered in /var/www/html/w/extensions/TimedMediaHandler/handlers/OggHandler/File_Ogg/File/Ogg/Vorbis.php on line 189

The lines in question:

187 	function getSecondsFromGranulePos( $granulePos ){
188 		return (( '0x' . substr( $granulePos, 0, 8 ) ) * pow(2, 32)
189             + ( '0x' . substr( $granulePos, 8, 8 ) ))
190             / $this->_idHeader['audio_sample_rate'];
191 	}

Event Timeline

matmarex created this task.Mar 15 2017, 3:48 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 15 2017, 3:48 PM

I'm running PHP 7.1. It seems that PHP 7 and later no longer automatically casts strings containing hexadecimal numbers to actual numbers when trying to do math on them.

https://3v4l.org/BSbHl

Same problem in a couple other files:

Searching 585 files for "'0x'"

handlers/OggHandler/File_Ogg/File/Ogg/Flac.php:
   68:         return (( '0x' . substr( $granulePos, 0, 8 ) ) * pow(2, 32)
   69:               + ( '0x' . substr( $granulePos, 8, 8 ) ))

handlers/OggHandler/File_Ogg/File/Ogg/Opus.php:
   60:         return (( '0x' . substr( $granulePos, 0, 8 ) ) * pow(2, 32)
   61:             + ( '0x' . substr( $granulePos, 8, 8 ) )

handlers/OggHandler/File_Ogg/File/Ogg/Speex.php:
   46:             (( '0x' . substr( $this->_lastGranulePos, 0, 8 ) ) * pow(2, 32)
   47:             + ( '0x' . substr( $this->_lastGranulePos, 8, 8 ) ))
   51:             (( '0x' . substr( $this->_firstGranulePos, 0, 8 ) ) * pow(2, 32)
   52:             + ( '0x' . substr( $this->_firstGranulePos, 8, 8 ) ))

handlers/OggHandler/File_Ogg/File/Ogg/Vorbis.php:
  188: 		return (( '0x' . substr( $granulePos, 0, 8 ) ) * pow(2, 32)
  189:             + ( '0x' . substr( $granulePos, 8, 8 ) ))

10 matches across 4 files
matmarex moved this task from Unsorted to PHP 7 on the [DO NOT USE] NewPHP board.

(PHP 7 and 7.1 are affected, but 7 fails silently instead of printing a warning.)

Change 354964 had a related patch set uploaded (by TheDJ; owner: TheDJ):
[mediawiki/extensions/TimedMediaHandler@master] PHP7: Use intval to baseconvert instead of string casting

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

matmarex closed this task as Resolved.May 21 2017, 12:39 PM
matmarex assigned this task to TheDJ.
matmarex removed a project: Patch-For-Review.

Change 354964 merged by jenkins-bot:
[mediawiki/extensions/TimedMediaHandler@master] PHP7: Use intval to baseconvert instead of string casting

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