wppaste
WordPress

getid3_lyrics3::getLyrics3Data( int $endoffset, int $version, int $length ): bool

Source
wp-includes/ID3/module.tag.lyrics3.php:147

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

$endoffsetint
$versionint
$lengthint

Return value

bool

Performance profile

How much work a call to getid3_lyrics3::getLyrics3Data() 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
14–149

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

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 · 29 distinct outcomes

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

WhenInstructionsCalls it makes
!::getid3_lib()14::getid3_lib(), ->warning()
::getid3_lib() && $length16::getid3_lib(), ->fseek()
::getid3_lib() && !$length47–49::getid3_lib(), ->fseek(), ->fread(), ->error()
::getid3_lib() && !$length61–63::getid3_lib(), ->fseek(), ->fread(), ->ftell(), ->error()
::getid3_lib() && !$length63–93::getid3_lib(), ->fseek(), ->fread(), ->Lyrics3LyricsTimestampParse()
::getid3_lib() && !$length && isset($value)75–101::getid3_lib(), ->fseek(), ->fread(), ->Lyrics3LyricsTimestampParse(), ->warning()
::getid3_lib() && !$length && $version != 1 && $version != 276::getid3_lib(), ->fseek(), ->fread(), ->warning(), ->error()
::getid3_lib() && !$length && $version != 1 && $version == 2 && !isset($value)79–89::getid3_lib(), ->fseek(), ->fread()
::getid3_lib() && !$length && isset($value) && !$info && $value == "Some ID3v1 fields do not use NULL characters for padding"85–110::getid3_lib(), ->fseek(), ->fread(), ->Lyrics3LyricsTimestampParse(), ->warning(), sort()
::getid3_lib() && !$length && $version != 1 && $version == 288–99::getid3_lib(), ->fseek(), ->fread(), explode()
::getid3_lib() && !$length90–92::getid3_lib(), ->fseek(), ->fread(), ->warning(), ->ftell(), ->error()
::getid3_lib() && !$length && $version != 1 && $version == 2 && !isset($value)91–118::getid3_lib(), ->fseek(), ->fread(), ->warning()
17 further outcomes, up to 149 instructions
::getid3_lib() && !$length && $version != 1 && $version == 2 && isset($value)92–103::getid3_lib(), ->fseek(), ->fread(), explode(), ->Lyrics3LyricsTimestampParse()
::getid3_lib() && !$length92–122::getid3_lib(), ->fseek(), ->fread(), ->warning(), ->Lyrics3LyricsTimestampParse()
::getid3_lib() && !$length && $version != 1 && $version == 2100–107::getid3_lib(), ->fseek(), ->fread(), explode(), ->warning()
::getid3_lib() && !$length && $version != 1 && $version == 2 && !$info && $value == "Some ID3v1 fields do not use NULL characters for padding"101–106::getid3_lib(), ->fseek(), ->fread(), ->warning(), sort()
::getid3_lib() && !$length && $version != 1 && $version == 2 && isset($value)104–111::getid3_lib(), ->fseek(), ->fread(), explode(), ->Lyrics3LyricsTimestampParse(), ->warning()
::getid3_lib() && !$length && isset($value)104–130::getid3_lib(), ->fseek(), ->fread(), ->warning(), ->Lyrics3LyricsTimestampParse(), ->warning()
::getid3_lib() && !$length && $version != 1 && $version == 2 && !$info && $value == "Some ID3v1 fields do not use NULL characters for padding"110–116::getid3_lib(), ->fseek(), ->fread(), explode(), ->warning(), sort()
::getid3_lib() && !$length && $version != 1 && $version == 2 && isset($value) && !$info && $value == "Some ID3v1 fields do not use NULL characters for padding"114–120::getid3_lib(), ->fseek(), ->fread(), explode(), ->Lyrics3LyricsTimestampParse(), ->warning(), sort()
::getid3_lib() && !$length && isset($value) && !$info && $value == "Some ID3v1 fields do not use NULL characters for padding"114–139::getid3_lib(), ->fseek(), ->fread(), ->warning(), ->Lyrics3LyricsTimestampParse(), ->warning(), sort()
::getid3_lib() && !$length && $version != 1 && $version == 2117–128::getid3_lib(), ->fseek(), ->fread(), ->warning(), explode()
::getid3_lib() && !$length && $version != 1 && $version == 2120–126::getid3_lib(), ->fseek(), ->fread(), ->warning(), ->warning()
::getid3_lib() && !$length && $version != 1 && $version == 2 && isset($value)121–132::getid3_lib(), ->fseek(), ->fread(), ->warning(), explode(), ->Lyrics3LyricsTimestampParse()
::getid3_lib() && !$length && $version != 1 && $version == 2129–136::getid3_lib(), ->fseek(), ->fread(), ->warning(), explode(), ->warning()
::getid3_lib() && !$length && $version != 1 && $version == 2 && !$info && $value == "Some ID3v1 fields do not use NULL characters for padding"130–135::getid3_lib(), ->fseek(), ->fread(), ->warning(), ->warning(), sort()
::getid3_lib() && !$length && $version != 1 && $version == 2 && isset($value)133–140::getid3_lib(), ->fseek(), ->fread(), ->warning(), explode(), ->Lyrics3LyricsTimestampParse(), ->warning()
::getid3_lib() && !$length && $version != 1 && $version == 2 && !$info && $value == "Some ID3v1 fields do not use NULL characters for padding"139–145::getid3_lib(), ->fseek(), ->fread(), ->warning(), explode(), ->warning(), sort()
::getid3_lib() && !$length && $version != 1 && $version == 2 && isset($value) && !$info && $value == "Some ID3v1 fields do not use NULL characters for padding"143–149::getid3_lib(), ->fseek(), ->fread(), ->warning(), explode(), ->Lyrics3LyricsTimestampParse(), ->warning(), sort()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev30314–14928
8.530314–14928
8.430314–1492861 fewer instructions than PHP 8.3
8.336414–173285 fewer instructions than PHP 8.2
8.236916–173281 more instruction than PHP 8.1
8.136816–173282 fewer instructions than PHP 7.4
7.437016–17328

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

Used by · 1

Source code

	public function getLyrics3Data($endoffset, $version, $length) {		// http://www.volweb.cz/str/tags.htm 		$info = &$this->getid3->info; 		if (!getid3_lib::intValueSupported($endoffset)) {			$this->warning('Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB');			return false;		} 		$this->fseek($endoffset);		if ($length <= 0) {			return false;		}		$rawdata = $this->fread($length); 		$ParsedLyrics3 = array(); 		$ParsedLyrics3['raw']['lyrics3version'] = $version;		$ParsedLyrics3['raw']['lyrics3tagsize'] = $length;		$ParsedLyrics3['tag_offset_start']      = $endoffset;		$ParsedLyrics3['tag_offset_end']        = $endoffset + $length - 1; 		if (substr($rawdata, 0, 11) != 'LYRICSBEGIN') {			if (strpos($rawdata, 'LYRICSBEGIN') !== false) { 				$this->warning('"LYRICSBEGIN" expected at '.$endoffset.' but actually found at '.($endoffset + strpos($rawdata, 'LYRICSBEGIN')).' - this is invalid for Lyrics3 v'.$version);				$info['avdataend'] = $endoffset + strpos($rawdata, 'LYRICSBEGIN');				$rawdata = substr($rawdata, strpos($rawdata, 'LYRICSBEGIN'));				$length = strlen($rawdata);				$ParsedLyrics3['tag_offset_start'] = $info['avdataend'];				$ParsedLyrics3['raw']['lyrics3tagsize'] = $length; 			} else { 				$this->error('"LYRICSBEGIN" expected at '.$endoffset.' but found "'.substr($rawdata, 0, 11).'" instead');				return false; 			} 		} 		switch ($version) { 			case 1:				if (substr($rawdata, strlen($rawdata) - 9, 9) == 'LYRICSEND') {					$ParsedLyrics3['raw']['LYR'] = trim(substr($rawdata, 11, strlen($rawdata) - 11 - 9));					$this->Lyrics3LyricsTimestampParse($ParsedLyrics3);				} else {					$this->error('"LYRICSEND" expected at '.($this->ftell() - 11 + $length - 9).' but found "'.substr($rawdata, strlen($rawdata) - 9, 9).'" instead');					return false;				}				break; 			case 2:				if (substr($rawdata, strlen($rawdata) - 9, 9) == 'LYRICS200') {					$ParsedLyrics3['raw']['unparsed'] = substr($rawdata, 11, strlen($rawdata) - 11 - 9 - 6); // LYRICSBEGIN + LYRICS200 + LSZ					$rawdata = $ParsedLyrics3['raw']['unparsed'];					while (strlen($rawdata) > 0) {						$fieldname = substr($rawdata, 0, 3);						$fieldsize = (int) substr($rawdata, 3, 5);						$ParsedLyrics3['raw'][$fieldname] = substr($rawdata, 8, $fieldsize);						$rawdata = substr($rawdata, 3 + 5 + $fieldsize);					} 					if (isset($ParsedLyrics3['raw']['IND'])) {						$i = 0;						$flagnames = array('lyrics', 'timestamps', 'inhibitrandom');						foreach ($flagnames as $flagname) {							if (strlen($ParsedLyrics3['raw']['IND']) > $i++) {								$ParsedLyrics3['flags'][$flagname] = $this->IntString2Bool(substr($ParsedLyrics3['raw']['IND'], $i, 1 - 1));							}						}					} 					$fieldnametranslation = array('ETT'=>'title', 'EAR'=>'artist', 'EAL'=>'album', 'INF'=>'comment', 'AUT'=>'author');					foreach ($fieldnametranslation as $key => $value) {						if (isset($ParsedLyrics3['raw'][$key])) {							$ParsedLyrics3['comments'][$value][] = trim($ParsedLyrics3['raw'][$key]);						}

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.lyrics3.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.