Make WordPress Core

Ticket #54285: 54285.diff

File 54285.diff, 17.5 KB (added by sabbirshouvo, 4 years ago)

adopt enhancements from the main repository of the library

  • src/wp-includes/ID3/getid3.lib.php

    diff --git a/src/wp-includes/ID3/getid3.lib.php b/src/wp-includes/ID3/getid3.lib.php
    index 8514e9781f..c409e8c9ac 100644
    a b class getid3_lib 
    427427         * @return string
    428428         */
    429429        public static function Dec2Bin($number) {
     430                $bytes = array(); // Prevent undefined Array Error
    430431                while ($number >= 256) {
    431432                        $bytes[] = (($number / 256) - (floor($number / 256))) * 256;
    432433                        $number = floor($number / 256);
    class getid3_lib 
    664665                //   $foo = array('path'=>array('to'=>'array('my'=>array('file.txt'))));
    665666                // or
    666667                //   $foo['path']['to']['my'] = 'file.txt';
    667                 $ArrayPath = ltrim($ArrayPath, $Separator);
     668                $ArrayPath     = ltrim($ArrayPath, $Separator);
     669                $ReturnedArray = array(); // Prevent undefined Array Error
    668670                if (($pos = strpos($ArrayPath, $Separator)) !== false) {
    669671                        $ReturnedArray[substr($ArrayPath, 0, $pos)] = self::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
    670672                } else {
    class getid3_lib 
    17341736         * @return float|bool
    17351737         */
    17361738        public static function getFileSizeSyscall($path) {
    1737                 $filesize = false;
     1739                $filesize    = false;
     1740                $commandline = null; // Prevent undefined variable Error
    17381741
    17391742                if (GETID3_OS_ISWINDOWS) {
    17401743                        if (class_exists('COM')) { // From PHP 5.3.15 and 5.4.5, COM and DOTNET is no longer built into the php core.you have to add COM support in php.ini:
  • src/wp-includes/ID3/getid3.php

    diff --git a/src/wp-includes/ID3/getid3.php b/src/wp-includes/ID3/getid3.php
    index 5cb3c036c0..424a7fb36e 100644
    a b abstract class getid3_handler 
    22242224         * @throws getid3_exception
    22252225         */
    22262226        public function saveAttachment($name, $offset, $length, $image_mime=null) {
     2227                $fp_dest = null; // Prevent undefined variable Error
     2228                $dest    = null; // Prevent undefined variable Error
     2229
    22272230                try {
    22282231
    22292232                        // do not extract at all
  • src/wp-includes/ID3/module.audio-video.asf.php

    diff --git a/src/wp-includes/ID3/module.audio-video.asf.php b/src/wp-includes/ID3/module.audio-video.asf.php
    index fce923c027..679fde6b30 100644
    a b class getid3_asf extends getid3_handler 
    9393                $offset = 0;
    9494                $thisfile_asf_streambitratepropertiesobject = array();
    9595                $thisfile_asf_codeclistobject = array();
     96                $StreamPropertiesObjectData = array(); // Prevent undefined Array Error
    9697
    9798                for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $thisfile_asf_headerobject['headerobjects']; $HeaderObjectsCounter++) {
    9899                        $NextObjectGUID = substr($ASFHeaderData, $offset, 16);
  • src/wp-includes/ID3/module.audio-video.flv.php

    diff --git a/src/wp-includes/ID3/module.audio-video.flv.php b/src/wp-includes/ID3/module.audio-video.flv.php
    index 7e684072e3..07c8681e86 100644
    a b class getid3_flv extends getid3_handler 
    161161                                                $info['flv']['video']['videoCodec'] = $LastHeaderByte & 0x07;
    162162
    163163                                                $FLVvideoHeader = $this->fread(11);
     164                                                $PictureSizeEnc = array(); // Prevent undefined Array Error
    164165
    165166                                                if ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H264) {
    166167                                                        // this code block contributed by: moysevichØgmail*com
  • src/wp-includes/ID3/module.audio-video.matroska.php

    diff --git a/src/wp-includes/ID3/module.audio-video.matroska.php b/src/wp-includes/ID3/module.audio-video.matroska.php
    index a285108590..128e614e2c 100644
    a b class getid3_matroska extends getid3_handler 
    224224         *
    225225         * @var bool
    226226         */
    227         public static $hide_clusters    = true;
     227        public $hide_clusters    = true;
    228228
    229229        /**
    230230         * True to parse the whole file, not only header [default: FALSE].
    231231         *
    232232         * @var bool
    233233         */
    234         public static $parse_whole_file = false;
     234        public $parse_whole_file = false;
    235235
    236236        /*
    237237         * Private parser settings/placeholders.
    class getid3_matroska extends getid3_handler 
    586586                                        $info['matroska']['segment'][0]['length'] = $top_element['length'];
    587587
    588588                                        while ($this->getEBMLelement($element_data, $top_element['end'])) {
    589                                                 if ($element_data['id'] != EBML_ID_CLUSTER || !self::$hide_clusters) { // collect clusters only if required
     589                                                if ($element_data['id'] != EBML_ID_CLUSTER || !$this->hide_clusters) { // collect clusters only if required
    590590                                                        $info['matroska']['segments'][] = $element_data;
    591591                                                }
    592592                                                switch ($element_data['id']) {
    class getid3_matroska extends getid3_handler 
    618618                                                                                                $this->warning('seek_entry[target_id] unexpectedly not set at '.$seek_entry['offset']);
    619619                                                                                                break;
    620620                                                                                        }
    621                                                                                         if (($seek_entry['target_id'] != EBML_ID_CLUSTER) || !self::$hide_clusters) { // collect clusters only if required
     621                                                                                        if (($seek_entry['target_id'] != EBML_ID_CLUSTER) || !$this->hide_clusters) { // collect clusters only if required
    622622                                                                                                $info['matroska']['seek'][] = $seek_entry;
    623623                                                                                        }
    624624                                                                                        break;
    class getid3_matroska extends getid3_handler 
    905905                                                                break;
    906906
    907907                                                        case EBML_ID_CUES: // A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non "live" streams.
    908                                                                 if (self::$hide_clusters) { // do not parse cues if hide clusters is "ON" till they point to clusters anyway
     908                                                                if ($this->hide_clusters) { // do not parse cues if hide clusters is "ON" till they point to clusters anyway
    909909                                                                        $this->current_offset = $element_data['end'];
    910910                                                                        break;
    911911                                                                }
    class getid3_matroska extends getid3_handler 
    12461246                                                                        }
    12471247                                                                        $this->current_offset = $subelement['end'];
    12481248                                                                }
    1249                                                                 if (!self::$hide_clusters) {
     1249                                                                if (!$this->hide_clusters) {
    12501250                                                                        $info['matroska']['cluster'][] = $cluster_entry;
    12511251                                                                }
    12521252
    12531253                                                                // check to see if all the data we need exists already, if so, break out of the loop
    1254                                                                 if (!self::$parse_whole_file) {
     1254                                                                if (!$this->parse_whole_file) {
    12551255                                                                        if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) {
    12561256                                                                                if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) {
    12571257                                                                                        if (count($info['matroska']['track_data_offsets']) == count($info['matroska']['tracks']['tracks'])) {
  • src/wp-includes/ID3/module.audio-video.quicktime.php

    diff --git a/src/wp-includes/ID3/module.audio-video.quicktime.php b/src/wp-includes/ID3/module.audio-video.quicktime.php
    index 1cf1c0590b..bada8fa0fd 100644
    a b getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE_ 
    2323
    2424class getid3_quicktime extends getid3_handler
    2525{
    26 
     26        /** audio-video.quicktime
     27         * return all parsed data from all atoms if true, otherwise just returned parsed metadata
     28         *
     29         * @var bool
     30         */
    2731        public $ReturnAtomData        = true;
     32       
     33        /** audio-video.quicktime
     34         * return all parsed data from all atoms if true, otherwise just returned parsed metadata
     35         *
     36         * @var bool
     37         */
    2838        public $ParseAllPossibleAtoms = false;
    2939
    3040        /**
    class getid3_quicktime extends getid3_handler 
    728738                                        $atom_structure['flags']['play_on_open'] = (bool) $atom_structure['play_on_open_flag'];
    729739                                        $atom_structure['flags']['slide_show']   = (bool) $atom_structure['slide_show_flag'];
    730740
    731                                         $ptv_lookup[0] = 'normal';
    732                                         $ptv_lookup[1] = 'double';
    733                                         $ptv_lookup[2] = 'half';
    734                                         $ptv_lookup[3] = 'full';
    735                                         $ptv_lookup[4] = 'current';
     741                                        $ptv_lookup = array(
     742                                                0 => 'normal',
     743                                                1 => 'double',
     744                                                2 => 'half',
     745                                                3 => 'full',
     746                                                4 => 'current'
     747                                        );
    736748                                        if (isset($ptv_lookup[$atom_structure['display_size_raw']])) {
    737749                                                $atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']];
    738750                                        } else {
    $this->warning('incomplete/incorrect handling of "stsd" with Parrot metadata in 
    17211733                                                                        'unknown_data'   => array(),
    17221734                                                                        'debug_list'     => '',      // Used to debug variables stored as comma delimited strings
    17231735                                                        );
     1736                                                        $debug_structure = array();
    17241737                                                        $debug_structure['debug_items'] = array();
    17251738                                                        // Can start loop here to decode all sensor data in 32 Byte chunks:
    17261739                                                        foreach (str_split($atom_SENSOR_data, 32) as $sensor_key => $sensor_data) {
  • src/wp-includes/ID3/module.audio-video.riff.php

    diff --git a/src/wp-includes/ID3/module.audio-video.riff.php b/src/wp-includes/ID3/module.audio-video.riff.php
    index cdf553386b..fbc180c4f5 100644
    a b class getid3_riff extends getid3_handler 
    5656                $thisfile_riff_video       = &$thisfile_riff['video'];
    5757                $thisfile_riff_WAVE        = array();
    5858
     59                $Original                                 = array();
    5960                $Original['avdataoffset'] = $info['avdataoffset'];
    6061                $Original['avdataend']    = $info['avdataend'];
    6162
    class getid3_riff extends getid3_handler 
    307308                                        $thisfile_riff_WAVE_bext_0['coding_history'] =         explode("\r\n", trim(substr($thisfile_riff_WAVE_bext_0['data'], 601)));
    308309                                        if (preg_match('#^([0-9]{4}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_date'], $matches_bext_date)) {
    309310                                                if (preg_match('#^([0-9]{2}).([0-9]{2}).([0-9]{2})$#', $thisfile_riff_WAVE_bext_0['origin_time'], $matches_bext_time)) {
     311                                                        $bext_timestamp = array();
    310312                                                        list($dummy, $bext_timestamp['year'], $bext_timestamp['month'],  $bext_timestamp['day'])    = $matches_bext_date;
    311313                                                        list($dummy, $bext_timestamp['hour'], $bext_timestamp['minute'], $bext_timestamp['second']) = $matches_bext_time;
    312314                                                        $thisfile_riff_WAVE_bext_0['origin_date_unix'] = gmmktime($bext_timestamp['hour'], $bext_timestamp['minute'], $bext_timestamp['second'], $bext_timestamp['month'], $bext_timestamp['day'], $bext_timestamp['year']);
    class getid3_riff extends getid3_handler 
    733735                                }
    734736                                if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strh'][0]['data'])) {
    735737                                        if (is_array($thisfile_riff['AVI ']['hdrl']['strl']['strh'])) {
     738                                                $thisfile_riff_raw_strf_strhfccType_streamindex = null;
    736739                                                for ($i = 0; $i < count($thisfile_riff['AVI ']['hdrl']['strl']['strh']); $i++) {
    737740                                                        if (isset($thisfile_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'])) {
    738741                                                                $strhData = $thisfile_riff['AVI ']['hdrl']['strl']['strh'][$i]['data'];
    class getid3_riff extends getid3_handler 
    15141517
    15151518                $RIFFchunk = false;
    15161519                $FoundAllChunksWeNeed = false;
     1520                $LISTchunkParent = null;
     1521                $LISTchunkMaxOffset = null;
    15171522
    15181523                try {
    15191524                        $this->fseek($startoffset);
    class getid3_riff extends getid3_handler 
    20762081         */
    20772082        public static function ParseBITMAPINFOHEADER($BITMAPINFOHEADER, $littleEndian=true) {
    20782083
     2084                $parsed                                    = array();
    20792085                $parsed['biSize']          = substr($BITMAPINFOHEADER,  0, 4); // number of bytes required by the BITMAPINFOHEADER structure
    20802086                $parsed['biWidth']         = substr($BITMAPINFOHEADER,  4, 4); // width of the bitmap in pixels
    20812087                $parsed['biHeight']        = substr($BITMAPINFOHEADER,  8, 4); // height of the bitmap in pixels. If biHeight is positive, the bitmap is a 'bottom-up' DIB and its origin is the lower left corner. If biHeight is negative, the bitmap is a 'top-down' DIB and its origin is the upper left corner
  • src/wp-includes/ID3/module.audio.flac.php

    diff --git a/src/wp-includes/ID3/module.audio.flac.php b/src/wp-includes/ID3/module.audio.flac.php
    index 1cea4364c2..4680099f94 100644
    a b class getid3_flac extends getid3_handler 
    402402        public function parsePICTURE() {
    403403                $info = &$this->getid3->info;
    404404
     405                $picture                                   = array(); // Prevent undefined Array Error
    405406                $picture['typeid']         = getid3_lib::BigEndian2Int($this->fread(4));
    406407                $picture['picturetype']    = self::pictureTypeLookup($picture['typeid']);
    407408                $picture['image_mime']     = $this->fread(getid3_lib::BigEndian2Int($this->fread(4)));
  • src/wp-includes/ID3/module.audio.mp3.php

    diff --git a/src/wp-includes/ID3/module.audio.mp3.php b/src/wp-includes/ID3/module.audio.mp3.php
    index 26b28068f8..884a6d9bdd 100644
    a b class getid3_mp3 extends getid3_handler 
    5555                        $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
    5656                }
    5757
     58                $CurrentDataLAMEversionString = null;
    5859                if (((isset($info['id3v2']['headerlength']) && ($info['avdataoffset'] > $info['id3v2']['headerlength'])) || (!isset($info['id3v2']) && ($info['avdataoffset'] > 0) && ($info['avdataoffset'] != $initialOffset)))) {
    5960
    6061                        $synchoffsetwarning = 'Unknown data before synch ';
    class getid3_mp3 extends getid3_handler 
    12731274                $LongMPEGbitrateLookup        = array();
    12741275                $LongMPEGpaddingLookup        = array();
    12751276                $LongMPEGfrequencyLookup      = array();
     1277                $Distribution                             = array();
    12761278                $Distribution['bitrate']      = array();
    12771279                $Distribution['frequency']    = array();
    12781280                $Distribution['layer']        = array();
    class getid3_mp3 extends getid3_handler 
    15581560                                                $pct_data_scanned = 0;
    15591561                                                for ($current_segment = 0; $current_segment < $max_scan_segments; $current_segment++) {
    15601562                                                        $frames_scanned_this_segment = 0;
     1563                                                        $scan_start_offset = array();
    15611564                                                        if ($this->ftell() >= $info['avdataend']) {
    15621565                                                                break;
    15631566                                                        }
    class getid3_mp3 extends getid3_handler 
    18871890                        return false;
    18881891                }
    18891892
     1893                $MPEGrawHeader                                  = array();
    18901894                $MPEGrawHeader['synch']         = (getid3_lib::BigEndian2Int(substr($Header4Bytes, 0, 2)) & 0xFFE0) >> 4;
    18911895                $MPEGrawHeader['version']       = (ord($Header4Bytes[1]) & 0x18) >> 3; //    BB
    18921896                $MPEGrawHeader['layer']         = (ord($Header4Bytes[1]) & 0x06) >> 1; //      CC
  • src/wp-includes/ID3/module.audio.ogg.php

    diff --git a/src/wp-includes/ID3/module.audio.ogg.php b/src/wp-includes/ID3/module.audio.ogg.php
    index fe092d9d94..47c10c392c 100644
    a b class getid3_ogg extends getid3_handler 
    529529         */
    530530        public function ParseOggPageHeader() {
    531531                // http://xiph.org/ogg/vorbis/doc/framing.html
     532                $oggheader = array();
    532533                $oggheader['page_start_offset'] = $this->ftell(); // where we started from in the file
    533534
    534535                $filedata = $this->fread($this->getid3->fread_buffer_size());
  • src/wp-includes/ID3/module.tag.apetag.php

    diff --git a/src/wp-includes/ID3/module.tag.apetag.php b/src/wp-includes/ID3/module.tag.apetag.php
    index 26be982c73..040d457c5d 100644
    a b class getid3_apetag extends getid3_handler 
    360360                // http://www.uni-jena.de/~pfk/mpp/sv8/apeheader.html
    361361
    362362                // shortcut
     363                $headerfooterinfo                = array();
    363364                $headerfooterinfo['raw'] = array();
    364365                $headerfooterinfo_raw = &$headerfooterinfo['raw'];
    365366
    class getid3_apetag extends getid3_handler 
    389390                // "Note: APE Tags 1.0 do not use any of the APE Tag flags.
    390391                // All are set to zero on creation and ignored on reading."
    391392                // http://wiki.hydrogenaud.io/index.php?title=Ape_Tags_Flags
     393                $flags                                          = array();
    392394                $flags['header']            = (bool) ($rawflagint & 0x80000000);
    393395                $flags['footer']            = (bool) ($rawflagint & 0x40000000);
    394396                $flags['this_is_header']    = (bool) ($rawflagint & 0x20000000);
  • src/wp-includes/ID3/module.tag.id3v1.php

    diff --git a/src/wp-includes/ID3/module.tag.id3v1.php b/src/wp-includes/ID3/module.tag.id3v1.php
    index 16dcf253b6..144c9a8374 100644
    a b class getid3_id3v1 extends getid3_handler 
    3939
    4040                        $info['avdataend'] = $info['filesize'] - 128;
    4141
     42                        $ParsedID3v1                    = array();
    4243                        $ParsedID3v1['title']   = $this->cutfield(substr($id3v1tag,   3, 30));
    4344                        $ParsedID3v1['artist']  = $this->cutfield(substr($id3v1tag,  33, 30));
    4445                        $ParsedID3v1['album']   = $this->cutfield(substr($id3v1tag,  63, 30));
  • src/wp-includes/ID3/module.tag.id3v2.php

    diff --git a/src/wp-includes/ID3/module.tag.id3v2.php b/src/wp-includes/ID3/module.tag.id3v2.php
    index 85dd7a147a..5769e2e90f 100644
    a b class getid3_id3v2 extends getid3_handler 
    345345                                }
    346346                                if (($frame_size <= strlen($framedata)) && ($this->IsValidID3v2FrameName($frame_name, $id3v2_majorversion))) {
    347347
    348                                         unset($parsedFrame);
     348                                        $parsedFrame                                    = array();
    349349                                        $parsedFrame['frame_name']      = $frame_name;
    350350                                        $parsedFrame['frame_flags_raw'] = $frame_flags;
    351351                                        $parsedFrame['data']            = substr($framedata, 0, $frame_size);
    class getid3_id3v2 extends getid3_handler 
    13691369                                $this->warning('Invalid text encoding byte ('.$frame_textencoding.') in frame "'.$parsedFrame['frame_name'].'" - defaulting to ISO-8859-1 encoding');
    13701370                                $frame_textencoding_terminator = "\x00";
    13711371                        }
    1372 
     1372                        $frame_imagetype = null;
     1373                        $frame_mimetype = null;
    13731374                        if ($id3v2_majorversion == 2 && strlen($parsedFrame['data']) > $frame_offset) {
    13741375                                $frame_imagetype = substr($parsedFrame['data'], $frame_offset, 3);
    13751376                                if (strtolower($frame_imagetype) == 'ima') {
  • src/wp-includes/ID3/module.tag.lyrics3.php

    diff --git a/src/wp-includes/ID3/module.tag.lyrics3.php b/src/wp-includes/ID3/module.tag.lyrics3.php
    index b2375057e7..c8b2cf6305 100644
    a b class getid3_lyrics3 extends getid3_handler 
    3333                }
    3434
    3535                $this->fseek((0 - 128 - 9 - 6), SEEK_END);          // end - ID3v1 - "LYRICSEND" - [Lyrics3size]
     36                $lyrics3offset = null;
     37                $lyrics3version = null;
     38                $lyrics3size   = null;
    3639                $lyrics3_id3v1 = $this->fread(128 + 9 + 6);
    3740                $lyrics3lsz    = (int) substr($lyrics3_id3v1, 0, 6); // Lyrics3size
    3841                $lyrics3end    = substr($lyrics3_id3v1,  6,   9); // LYRICSEND or LYRICS200