wppaste
WordPress

getid3_flac::parseMETAdata(): bool

Source
wp-includes/ID3/module.audio.flac.php:52

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_flac::parseMETAdata() 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
66–203

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

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

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

WhenInstructionsCalls it makes
!$BlockLength && !->parseSTREAMINFO()66->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->parseSTREAMINFO()
!$BlockLength && $LastBlockFlag !== false && empty($value) && !isset($value)94–141->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->ftell()
!$BlockLength && ->parseSTREAMINFO() && $LastBlockFlag !== false && !isset($value)97–150->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->parseSTREAMINFO(), ->ftell()
!$BlockLength && $LastBlockFlag !== false && empty($value)103–144->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->ftell(), ->warning()
!$BlockLength && ->parseSTREAMINFO() && $LastBlockFlag !== false106–153->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->parseSTREAMINFO(), ->ftell(), ->warning()
!$BlockLength && $LastBlockFlag !== false && empty($value)116–134->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->ftell(), ->warning(), ->warning()
!$BlockLength && $LastBlockFlag !== false && empty($value) && isset($value)117–141->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->ftell(), ->isDependencyFor(), ->error()
!$BlockLength && ->parseSTREAMINFO() && $LastBlockFlag !== false119–143->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->parseSTREAMINFO(), ->ftell(), ->warning(), ->warning()
!$BlockLength && $LastBlockFlag !== false && empty($value) && isset($value)120–191->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->ftell(), ->isDependencyFor()
!$BlockLength && ->parseSTREAMINFO() && $LastBlockFlag !== false && isset($value)120–150->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->parseSTREAMINFO(), ->ftell(), ->isDependencyFor(), ->error()
!$BlockLength && ->parseSTREAMINFO() && $LastBlockFlag !== false && isset($value)123–200->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->parseSTREAMINFO(), ->ftell(), ->isDependencyFor()
!$BlockLength && $LastBlockFlag !== false && empty($value) && isset($value)129–194->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->ftell(), ->isDependencyFor(), ->warning()
3 further outcomes, up to 193 instructions
!$BlockLength && ->parseSTREAMINFO() && $LastBlockFlag !== false && isset($value)132–203->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->parseSTREAMINFO(), ->ftell(), ->isDependencyFor(), ->warning()
!$BlockLength && $LastBlockFlag !== false && empty($value) && isset($value)142–184->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->ftell(), ->isDependencyFor(), ->warning(), ->warning()
!$BlockLength && ->parseSTREAMINFO() && $LastBlockFlag !== false && isset($value)145–193->ftell(), ->fread(), ::getid3_lib(), ::getid3_lib(), ::metaBlockTypeLookup(), ->parseSTREAMINFO(), ->ftell(), ->isDependencyFor(), ->warning(), ->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-dev34066–20342
8.534066–20342
8.434066–2034214 fewer instructions than PHP 8.3
8.335472–21542
8.235472–215421 more instruction than PHP 8.1
8.135372–21542
7.435372–21542

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

Show all 13
  • getid3_flac::isDependencyFor()

Used by · 1

Source code

	public function parseMETAdata() {		$info = &$this->getid3->info;		do {			$BlockOffset   = $this->ftell();			$BlockHeader   = $this->fread(4);			$LBFBT         = getid3_lib::BigEndian2Int(substr($BlockHeader, 0, 1));  // LBFBT = LastBlockFlag + BlockType			$LastBlockFlag = (bool) ($LBFBT & 0x80);			$BlockType     =        ($LBFBT & 0x7F);			$BlockLength   = getid3_lib::BigEndian2Int(substr($BlockHeader, 1, 3));			$BlockTypeText = self::metaBlockTypeLookup($BlockType); 			if (($BlockOffset + 4 + $BlockLength) > $info['avdataend']) {				$this->warning('METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockTypeText.') at offset '.$BlockOffset.' extends beyond end of file');				break;			}			if ($BlockLength < 1) {				if ($BlockTypeText != 'reserved') {					// probably supposed to be zero-length					$this->warning('METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$BlockTypeText.') at offset '.$BlockOffset.' is zero bytes');					continue;				}				$this->error('METADATA_BLOCK_HEADER.BLOCK_LENGTH ('.$BlockLength.') at offset '.$BlockOffset.' is invalid');				break;			} 			$info['flac'][$BlockTypeText]['raw'] = array();			$BlockTypeText_raw = &$info['flac'][$BlockTypeText]['raw']; 			$BlockTypeText_raw['offset']          = $BlockOffset;			$BlockTypeText_raw['last_meta_block'] = $LastBlockFlag;			$BlockTypeText_raw['block_type']      = $BlockType;			$BlockTypeText_raw['block_type_text'] = $BlockTypeText;			$BlockTypeText_raw['block_length']    = $BlockLength;			if ($BlockTypeText_raw['block_type'] != 0x06) { // do not read attachment data automatically				$BlockTypeText_raw['block_data']  = $this->fread($BlockLength);			} 			switch ($BlockTypeText) {				case 'STREAMINFO':     // 0x00					if (!$this->parseSTREAMINFO($BlockTypeText_raw['block_data'])) {						return false;					}					break; 				case 'PADDING':        // 0x01					unset($info['flac']['PADDING']); // ignore					break; 				case 'APPLICATION':    // 0x02					if (!$this->parseAPPLICATION($BlockTypeText_raw['block_data'])) {						return false;					}					break; 				case 'SEEKTABLE':      // 0x03					if (!$this->parseSEEKTABLE($BlockTypeText_raw['block_data'])) {						return false;					}					break; 				case 'VORBIS_COMMENT': // 0x04					if (!$this->parseVORBIS_COMMENT($BlockTypeText_raw['block_data'])) {						return false;					}					break; 				case 'CUESHEET':       // 0x05					if (!$this->parseCUESHEET($BlockTypeText_raw['block_data'])) {						return false;					}					break; 				case 'PICTURE':        // 0x06					if (!$this->parsePICTURE()) {						return false;					}					break; 				default:					$this->warning('Unhandled METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$BlockType.') at offset '.$BlockOffset);

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.audio.flac.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.