Make WordPress Core


Ignore:
Timestamp:
09/14/2019 07:06:09 PM (7 years ago)
Author:
jorbin
Message:

Update getID3 library to fix issues with PHP7.4

Updates to trunk version that includes fixes for PHP7.4

Changelog:
​https://github.com/JamesHeinrich/getID3/compare/v1.9.14...00f3fbfd77e583099ca70a3cf0bc092e113d2b20

See: #47751,#47783.
Fixes: #48040.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ID3/module.audio.flac.php

    r32979 r46112  
    11<?php
     2
    23/////////////////////////////////////////////////////////////////
    34/// getID3() by James Heinrich <info@getid3.org>               //
    4 //  available at http://getid3.sourceforge.net                 //
    5 //            or http://www.getid3.org                         //
    6 //          also https://github.com/JamesHeinrich/getID3       //
    7 /////////////////////////////////////////////////////////////////
    8 // See readme.txt for more details                             //
     5//  available at https://github.com/JamesHeinrich/getID3       //
     6//            or https://www.getid3.org                        //
     7//            or http://getid3.sourceforge.net                 //
     8//  see readme.txt for more details                            //
    99/////////////////////////////////////////////////////////////////
    1010//                                                             //
    … …  
    2525        const syncword = 'fLaC';
    2626
     27        /**
     28         * @return bool
     29         */
    2730        public function Analyze() {
    2831                $info = &$this->getid3->info;
    … …  
    4245        }
    4346
     47        /**
     48         * @return bool
     49         */
    4450        public function parseMETAdata() {
    4551                $info = &$this->getid3->info;
    … …  
    4753                        $BlockOffset   = $this->ftell();
    4854                        $BlockHeader   = $this->fread(4);
    49                         $LBFBT         = getid3_lib::BigEndian2Int(substr($BlockHeader, 0, 1));
     55                        $LBFBT         = getid3_lib::BigEndian2Int(substr($BlockHeader, 0, 1));  // LBFBT = LastBlockFlag + BlockType
    5056                        $LastBlockFlag = (bool) ($LBFBT & 0x80);
    5157                        $BlockType     =        ($LBFBT & 0x7F);
    … …  
    5460
    5561                        if (($BlockOffset + 4 + $BlockLength) > $info['avdataend']) {
    56                                 $this->error('METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockTypeText.') at offset '.$BlockOffset.' extends beyond end of file');
     62                                $this->warning('METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockTypeText.') at offset '.$BlockOffset.' extends beyond end of file');
    5763                                break;
    5864                        }
    5965                        if ($BlockLength < 1) {
     66                                if ($BlockTypeText != 'reserved') {
     67                                        // probably supposed to be zero-length
     68                                        $this->warning('METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$BlockTypeText.') at offset '.$BlockOffset.' is zero bytes');
     69                                        continue;
     70                                }
    6071                                $this->error('METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$BlockLength.') at offset '.$BlockOffset.' is invalid');
    6172                                break;
    … …  
    168179
    169180                        if ($info['flac']['STREAMINFO']['audio_signature'] === str_repeat("\x00", 16)) {
    170                 $this->warning('FLAC STREAMINFO.audio_signature is null (known issue with libOggFLAC)');
     181                                $this->warning('FLAC STREAMINFO.audio_signature is null (known issue with libOggFLAC)');
    171182                        }
    172183                        else {
    … …  
    195206        }
    196207
    197         private function parseSTREAMINFO($BlockData) {
    198                 $info = &$this->getid3->info;
    199 
    200                 $info['flac']['STREAMINFO'] = array();
    201                 $streaminfo = &$info['flac']['STREAMINFO'];
    202 
     208
     209        /**
     210         * @param string $BlockData
     211         *
     212         * @return array
     213         */
     214        public static function parseSTREAMINFOdata($BlockData) {
     215                $streaminfo = array();
    203216                $streaminfo['min_block_size']  = getid3_lib::BigEndian2Int(substr($BlockData, 0, 2));
    204217                $streaminfo['max_block_size']  = getid3_lib::BigEndian2Int(substr($BlockData, 2, 2));
    … …  
    212225                $streaminfo['samples_stream']  = getid3_lib::Bin2Dec(substr($SRCSBSS, 28, 36));
    213226
    214                 $streaminfo['audio_signature'] = substr($BlockData, 18, 16);
    215 
    216                 if (!empty($streaminfo['sample_rate'])) {
     227                $streaminfo['audio_signature'] =                           substr($BlockData, 18, 16);
     228
     229                return $streaminfo;
     230        }
     231
     232        /**
     233         * @param string $BlockData
     234         *
     235         * @return bool
     236         */
     237        private function parseSTREAMINFO($BlockData) {
     238                $info = &$this->getid3->info;
     239
     240                $info['flac']['STREAMINFO'] = self::parseSTREAMINFOdata($BlockData);
     241
     242                if (!empty($info['flac']['STREAMINFO']['sample_rate'])) {
    217243
    218244                        $info['audio']['bitrate_mode']    = 'vbr';
    219                         $info['audio']['sample_rate']     = $streaminfo['sample_rate'];
    220                         $info['audio']['channels']        = $streaminfo['channels'];
    221                         $info['audio']['bits_per_sample'] = $streaminfo['bits_per_sample'];
    222                         $info['playtime_seconds']         = $streaminfo['samples_stream'] / $streaminfo['sample_rate'];
     245                        $info['audio']['sample_rate']     = $info['flac']['STREAMINFO']['sample_rate'];
     246                        $info['audio']['channels']        = $info['flac']['STREAMINFO']['channels'];
     247                        $info['audio']['bits_per_sample'] = $info['flac']['STREAMINFO']['bits_per_sample'];
     248                        $info['playtime_seconds']         = $info['flac']['STREAMINFO']['samples_stream'] / $info['flac']['STREAMINFO']['sample_rate'];
    223249                        if ($info['playtime_seconds'] > 0) {
    224250                                if (!$this->isDependencyFor('matroska')) {
    … …  
    237263        }
    238264
     265        /**
     266         * @param string $BlockData
     267         *
     268         * @return bool
     269         */
    239270        private function parseAPPLICATION($BlockData) {
    240271                $info = &$this->getid3->info;
    … …  
    247278        }
    248279
     280        /**
     281         * @param string $BlockData
     282         *
     283         * @return bool
     284         */
    249285        private function parseSEEKTABLE($BlockData) {
    250286                $info = &$this->getid3->info;
    … …  
    276312        }
    277313
     314        /**
     315         * @param string $BlockData
     316         *
     317         * @return bool
     318         */
    278319        private function parseVORBIS_COMMENT($BlockData) {
    279320                $info = &$this->getid3->info;
    … …  
    295336        }
    296337
     338        /**
     339         * @param string $BlockData
     340         *
     341         * @return bool
     342         */
    297343        private function parseCUESHEET($BlockData) {
    298344                $info = &$this->getid3->info;
    … …  
    347393
    348394        /**
    349         * Parse METADATA_BLOCK_PICTURE flac structure and extract attachment
    350         * External usage: audio.ogg
    351         */
     395         * Parse METADATA_BLOCK_PICTURE flac structure and extract attachment
     396         * External usage: audio.ogg
     397         *
     398         * @return bool
     399         */
    352400        public function parsePICTURE() {
    353401                $info = &$this->getid3->info;
    … …  
    381429        }
    382430
     431        /**
     432         * @param int $blocktype
     433         *
     434         * @return string
     435         */
    383436        public static function metaBlockTypeLookup($blocktype) {
    384437                static $lookup = array(
    … …  
    394447        }
    395448
     449        /**
     450         * @param int $applicationid
     451         *
     452         * @return string
     453         */
    396454        public static function applicationIDLookup($applicationid) {
    397455                // http://flac.sourceforge.net/id.html
    … …  
    424482        }
    425483
     484        /**
     485         * @param int $type_id
     486         *
     487         * @return string
     488         */
    426489        public static function pictureTypeLookup($type_id) {
    427490                static $lookup = array (
Note: See TracChangeset for help on using the changeset viewer.