wppaste
WordPress

getid3_apetag::Analyze(): bool

Source
wp-includes/ID3/module.tag.apetag.php:38

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_apetag::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
Moderate

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
811

Executed per call on PHP 8.5. The body compiles to 811.

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.

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev81181185
8.581181185
8.48118118557 fewer instructions than PHP 8.3
8.3868868855 fewer instructions than PHP 8.2
8.2873873851 more instruction than PHP 8.1
8.187287285
7.487287285

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

Source code

	public function Analyze() {		$info = &$this->getid3->info; 		if (!getid3_lib::intValueSupported($info['filesize'])) {			$this->warning('Unable to check for APEtags because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB');			return false;		}		if (PHP_INT_MAX == 2147483647) {			// https://github.com/JamesHeinrich/getID3/issues/439			$this->warning('APEtag flags may not be parsed correctly on 32-bit PHP');		} 		$id3v1tagsize     = 128;		$apetagheadersize = 32;		$lyrics3tagsize   = 10; 		if ($this->overrideendoffset == 0) { 			$this->fseek(0 - $id3v1tagsize - $apetagheadersize - $lyrics3tagsize, SEEK_END);			$APEfooterID3v1 = $this->fread($id3v1tagsize + $apetagheadersize + $lyrics3tagsize); 			//if (preg_match('/APETAGEX.{24}TAG.{125}$/i', $APEfooterID3v1)) {			if (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $id3v1tagsize - $apetagheadersize, 8) == 'APETAGEX') { 				// APE tag found before ID3v1				$info['ape']['tag_offset_end'] = $info['filesize'] - $id3v1tagsize; 			//} elseif (preg_match('/APETAGEX.{24}$/i', $APEfooterID3v1)) {			} elseif (substr($APEfooterID3v1, strlen($APEfooterID3v1) - $apetagheadersize, 8) == 'APETAGEX') { 				// APE tag found, no ID3v1				$info['ape']['tag_offset_end'] = $info['filesize']; 			} 		} else { 			$this->fseek($this->overrideendoffset - $apetagheadersize);			if ($this->fread(8) == 'APETAGEX') {				$info['ape']['tag_offset_end'] = $this->overrideendoffset;			} 		}		if (!isset($info['ape']['tag_offset_end'])) { 			// APE tag not found			unset($info['ape']);			return false; 		} 		// shortcut		$thisfile_ape = &$info['ape']; 		$this->fseek($thisfile_ape['tag_offset_end'] - $apetagheadersize);		$APEfooterData = $this->fread(32);		if (!($thisfile_ape['footer'] = $this->parseAPEheaderFooter($APEfooterData))) {			$this->error('Error parsing APE footer at offset '.$thisfile_ape['tag_offset_end']);			return false;		} 		if (isset($thisfile_ape['footer']['flags']['header']) && $thisfile_ape['footer']['flags']['header']) {			$this->fseek($thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize'] - $apetagheadersize);			$thisfile_ape['tag_offset_start'] = $this->ftell();			$APEtagData = $this->fread($thisfile_ape['footer']['raw']['tagsize'] + $apetagheadersize);		} else {			$thisfile_ape['tag_offset_start'] = $thisfile_ape['tag_offset_end'] - $thisfile_ape['footer']['raw']['tagsize'];			$this->fseek($thisfile_ape['tag_offset_start']);			$APEtagData = $this->fread($thisfile_ape['footer']['raw']['tagsize']);		}		$info['avdataend'] = $thisfile_ape['tag_offset_start']; 		if (isset($info['id3v1']['tag_offset_start']) && ($info['id3v1']['tag_offset_start'] < $thisfile_ape['tag_offset_end'])) {			$this->warning('ID3v1 tag information ignored since it appears to be a false synch in APEtag data');			unset($info['id3v1']);			foreach ($info['warning'] as $key => $value) {				if ($value == 'Some ID3v1 fields do not use NULL characters for padding') {					unset($info['warning'][$key]);					sort($info['warning']);					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.apetag.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.