wppaste
WordPress

getid3_id3v2::Analyze(): bool

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

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.

Return value

bool

Performance profile

How much work a call to getid3_id3v2::Analyze() 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 how much data it finds.

Instructions
27–155

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What one call costs · 7 distinct outcomes

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

WhenInstructionsCalls it makes
always27–30->fseek(), ->fread()
!$id3v2_majorversion && $id3v2_majorversion == 2 && empty($value) && empty($thisfile_id3v2_flags) && !$sizeofframes && !isset($value)107–124->fseek(), ->fread(), ord(), ord(), ord(), ::getid3_lib()
!$id3v2_majorversion && $id3v2_majorversion == 2 && empty($value) && empty($thisfile_id3v2_flags) && !$sizeofframes && isset($thisfile_id3v2_flags) && $thisfile_id3v2_flags && !isset($value)120–135->fseek(), ->fread(), ord(), ord(), ord(), ::getid3_lib(), ->fread()
!$id3v2_majorversion && $id3v2_majorversion == 2 && empty($thisfile_id3v2_flags) && !$sizeofframes && !isset($value)121–139->fseek(), ->fread(), ord(), ord(), ord(), ::getid3_lib(), preg_match()
!$id3v2_majorversion && $id3v2_majorversion == 2 && empty($value) && empty($thisfile_id3v2_flags) && !$sizeofframes && isset($value)122–140->fseek(), ->fread(), ord(), ord(), ord(), ::getid3_lib(), array_unique()
!$id3v2_majorversion && $id3v2_majorversion == 2 && empty($thisfile_id3v2_flags) && !$sizeofframes && isset($thisfile_id3v2_flags) && $thisfile_id3v2_flags && !isset($value)134–149->fseek(), ->fread(), ord(), ord(), ord(), ::getid3_lib(), ->fread(), preg_match()
!$id3v2_majorversion && $id3v2_majorversion == 2 && empty($thisfile_id3v2_flags) && !$sizeofframes136–155->fseek(), ->fread(), ord(), ord(), ord(), ::getid3_lib(), array_unique(), preg_match()

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-dev103827–15588
8.5103827–15588
8.4103827–15588134 fewer instructions than PHP 8.3
8.3117230–16388
8.2117230–163884 more instructions than PHP 8.1
8.1116830–163881 fewer instruction than PHP 7.4
7.4116930–16388

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 · 17

Show all 17

Source code

	public function Analyze() {		$info = &$this->getid3->info; 		//    Overall tag structure:		//        +-----------------------------+		//        |      Header (10 bytes)      |		//        +-----------------------------+		//        |       Extended Header       |		//        | (variable length, OPTIONAL) |		//        +-----------------------------+		//        |   Frames (variable length)  |		//        +-----------------------------+		//        |           Padding           |		//        | (variable length, OPTIONAL) |		//        +-----------------------------+		//        | Footer (10 bytes, OPTIONAL) |		//        +-----------------------------+ 		//    Header		//        ID3v2/file identifier      "ID3"		//        ID3v2 version              $04 00		//        ID3v2 flags                (%ab000000 in v2.2, %abc00000 in v2.3, %abcd0000 in v2.4.x)		//        ID3v2 size             4 * %0xxxxxxx  		// shortcuts		$info['id3v2']['header'] = true;		$thisfile_id3v2                  = &$info['id3v2'];		$thisfile_id3v2['flags']         =  array();		$thisfile_id3v2_flags            = &$thisfile_id3v2['flags'];  		$this->fseek($this->StartingOffset);		$header = $this->fread(10);		if (substr($header, 0, 3) == 'ID3'  &&  strlen($header) == 10) { 			$thisfile_id3v2['majorversion'] = ord($header[3]);			$thisfile_id3v2['minorversion'] = ord($header[4]); 			// shortcut			$id3v2_majorversion = &$thisfile_id3v2['majorversion']; 		} else { 			unset($info['id3v2']);			return false; 		} 		if ($id3v2_majorversion > 4) { // this script probably won't correctly parse ID3v2.5.x and above (if it ever exists) 			$this->error('this script only parses up to ID3v2.4.x - this tag is ID3v2.'.$id3v2_majorversion.'.'.$thisfile_id3v2['minorversion']);			return false; 		} 		$id3_flags = ord($header[5]);		switch ($id3v2_majorversion) {			case 2:				// %ab000000 in v2.2				$thisfile_id3v2_flags['unsynch']     = (bool) ($id3_flags & 0x80); // a - Unsynchronisation				$thisfile_id3v2_flags['compression'] = (bool) ($id3_flags & 0x40); // b - Compression				break; 			case 3:				// %abc00000 in v2.3				$thisfile_id3v2_flags['unsynch']     = (bool) ($id3_flags & 0x80); // a - Unsynchronisation				$thisfile_id3v2_flags['exthead']     = (bool) ($id3_flags & 0x40); // b - Extended header				$thisfile_id3v2_flags['experim']     = (bool) ($id3_flags & 0x20); // c - Experimental indicator				break; 			case 4:				// %abcd0000 in v2.4				$thisfile_id3v2_flags['unsynch']     = (bool) ($id3_flags & 0x80); // a - Unsynchronisation				$thisfile_id3v2_flags['exthead']     = (bool) ($id3_flags & 0x40); // b - Extended header				$thisfile_id3v2_flags['experim']     = (bool) ($id3_flags & 0x20); // c - Experimental indicator				$thisfile_id3v2_flags['isfooter']    = (bool) ($id3_flags & 0x10); // d - Footer present				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.