wppaste
WordPress

getid3_id3v2::ParseID3v2Frame( array $parsedFrame ): bool

Source
wp-includes/ID3/module.tag.id3v2.php:569

Compatibility

WordPress
core
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$parsedFramearray

Return value

bool

Performance profile

How much work a call to getid3_id3v2::ParseID3v2Frame() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Light

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
156–302

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 4052.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What one call costs · 10 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost getid3_id3v2::ParseID3v2Frame() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!empty($parsedFrame) && !$id3v2_majorversion && empty($value) && !isset($parsedFrame) && $id3v2_majorversion != 2 && $id3v2_majorversion != 3156–168->FrameNameLongLookup(), ->FrameNameShortLookup()
!empty($parsedFrame) && empty($value) && !isset($parsedFrame) && $id3v2_majorversion != 2 && $id3v2_majorversion != 3 && !$i && !$frame_offset213–232->FrameNameLongLookup(), ->FrameNameShortLookup(), explode(), ord(), ord()
!empty($parsedFrame) && empty($value) && !isset($parsedFrame) && $id3v2_majorversion != 2 && $id3v2_majorversion != 3 && !$frame_offset220–238->FrameNameLongLookup(), ->FrameNameShortLookup(), explode(), ::getid3_lib(), ::getid3_lib()
!empty($parsedFrame) && empty($value) && !isset($parsedFrame) && $id3v2_majorversion != 2 && $id3v2_majorversion != 3 && !$frame_offset228–246->FrameNameLongLookup(), ->FrameNameShortLookup(), explode(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib()
!empty($parsedFrame) && empty($value) && !isset($parsedFrame) && $id3v2_majorversion != 2 && $id3v2_majorversion != 3 && !$frame_offset236–254->FrameNameLongLookup(), ->FrameNameShortLookup(), explode(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib()
!empty($parsedFrame) && empty($value) && !isset($parsedFrame) && $id3v2_majorversion != 2 && $id3v2_majorversion != 3266–267->FrameNameLongLookup(), ->FrameNameShortLookup(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib()
!empty($parsedFrame) && empty($value) && !isset($parsedFrame) && $id3v2_majorversion != 2 && $id3v2_majorversion != 3 && !$i && $frame_offset271–280->FrameNameLongLookup(), ->FrameNameShortLookup(), explode(), ord(), ord(), ::getid3_lib(), ::getid3_lib(), ->warning()
!empty($parsedFrame) && empty($value) && !isset($parsedFrame) && $id3v2_majorversion != 2 && $id3v2_majorversion != 3 && $frame_offset279–286->FrameNameLongLookup(), ->FrameNameShortLookup(), explode(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->warning()
!empty($parsedFrame) && empty($value) && !isset($parsedFrame) && $id3v2_majorversion != 2 && $id3v2_majorversion != 3 && $frame_offset287–294->FrameNameLongLookup(), ->FrameNameShortLookup(), explode(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->warning()
!empty($parsedFrame) && empty($value) && !isset($parsedFrame) && $id3v2_majorversion != 2 && $id3v2_majorversion != 3 && $frame_offset295–302->FrameNameLongLookup(), ->FrameNameShortLookup(), explode(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ::getid3_lib(), ->warning()

This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev4052156–302361
8.54052156–302361
8.44052156–302361784 fewer instructions than PHP 8.3
8.34836156–329361
8.24836156–3293614 fewer instructions than PHP 8.1
8.14840156–3293615 fewer instructions than PHP 7.4
7.44845156–329361

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 26

Show all 26

Used by · 1

Source code

	public function ParseID3v2Frame(&$parsedFrame) { 		// shortcuts		$info = &$this->getid3->info;		$id3v2_majorversion = $info['id3v2']['majorversion']; 		$parsedFrame['framenamelong']  = $this->FrameNameLongLookup($parsedFrame['frame_name']);		if (empty($parsedFrame['framenamelong'])) {			unset($parsedFrame['framenamelong']);		}		$parsedFrame['framenameshort'] = $this->FrameNameShortLookup($parsedFrame['frame_name']);		if (empty($parsedFrame['framenameshort'])) {			unset($parsedFrame['framenameshort']);		} 		if ($id3v2_majorversion >= 3) { // frame flags are not part of the ID3v2.2 standard			if ($id3v2_majorversion == 3) {				//    Frame Header Flags				//    %abc00000 %ijk00000				$parsedFrame['flags']['TagAlterPreservation']  = (bool) ($parsedFrame['frame_flags_raw'] & 0x8000); // a - Tag alter preservation				$parsedFrame['flags']['FileAlterPreservation'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x4000); // b - File alter preservation				$parsedFrame['flags']['ReadOnly']              = (bool) ($parsedFrame['frame_flags_raw'] & 0x2000); // c - Read only				$parsedFrame['flags']['compression']           = (bool) ($parsedFrame['frame_flags_raw'] & 0x0080); // i - Compression				$parsedFrame['flags']['Encryption']            = (bool) ($parsedFrame['frame_flags_raw'] & 0x0040); // j - Encryption				$parsedFrame['flags']['GroupingIdentity']      = (bool) ($parsedFrame['frame_flags_raw'] & 0x0020); // k - Grouping identity 			} elseif ($id3v2_majorversion == 4) {				//    Frame Header Flags				//    %0abc0000 %0h00kmnp				$parsedFrame['flags']['TagAlterPreservation']  = (bool) ($parsedFrame['frame_flags_raw'] & 0x4000); // a - Tag alter preservation				$parsedFrame['flags']['FileAlterPreservation'] = (bool) ($parsedFrame['frame_flags_raw'] & 0x2000); // b - File alter preservation				$parsedFrame['flags']['ReadOnly']              = (bool) ($parsedFrame['frame_flags_raw'] & 0x1000); // c - Read only				$parsedFrame['flags']['GroupingIdentity']      = (bool) ($parsedFrame['frame_flags_raw'] & 0x0040); // h - Grouping identity				$parsedFrame['flags']['compression']           = (bool) ($parsedFrame['frame_flags_raw'] & 0x0008); // k - Compression				$parsedFrame['flags']['Encryption']            = (bool) ($parsedFrame['frame_flags_raw'] & 0x0004); // m - Encryption				$parsedFrame['flags']['Unsynchronisation']     = (bool) ($parsedFrame['frame_flags_raw'] & 0x0002); // n - Unsynchronisation				$parsedFrame['flags']['DataLengthIndicator']   = (bool) ($parsedFrame['frame_flags_raw'] & 0x0001); // p - Data length indicator 				// Frame-level de-unsynchronisation - ID3v2.4				if ($parsedFrame['flags']['Unsynchronisation']) {					$parsedFrame['data'] = $this->DeUnsynchronise($parsedFrame['data']);				} 				if ($parsedFrame['flags']['DataLengthIndicator']) {					$parsedFrame['data_length_indicator'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4), 1);					$parsedFrame['data']                  =                           substr($parsedFrame['data'], 4);				}			} 			//    Frame-level de-compression			if ($parsedFrame['flags']['compression']) {				$parsedFrame['decompressed_size'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], 0, 4));				if (!function_exists('gzuncompress')) {					$this->warning('gzuncompress() support required to decompress ID3v2 frame "'.$parsedFrame['frame_name'].'"');				} else {					if ($decompresseddata = @gzuncompress(substr($parsedFrame['data'], 4))) {					//if ($decompresseddata = @gzuncompress($parsedFrame['data'])) {						$parsedFrame['data'] = $decompresseddata;						unset($decompresseddata);					} else {						$this->warning('gzuncompress() failed on compressed contents of ID3v2 frame "'.$parsedFrame['frame_name'].'"');					}				}			}		} 		if (!empty($parsedFrame['flags']['DataLengthIndicator'])) {			if ($parsedFrame['data_length_indicator'] != strlen($parsedFrame['data'])) {				$this->warning('ID3v2 frame "'.$parsedFrame['frame_name'].'" should be '.$parsedFrame['data_length_indicator'].' bytes long according to DataLengthIndicator, but found '.strlen($parsedFrame['data']).' bytes of data');			}		} 		if (isset($parsedFrame['datalength']) && ($parsedFrame['datalength'] == 0)) { 			$warning = 'Frame "'.$parsedFrame['frame_name'].'" at offset '.$parsedFrame['dataoffset'].' has no data portion';			switch ($parsedFrame['frame_name']) {				case 'WCOM':					$warning .= ' (this is known to happen with files tagged by RioPort)';					break;

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/ID3/module.tag.id3v2.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.