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
- Scaling
- Scales with input
- Instructions
- 27–155
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 1038.
Nothing here hands control to plugin code.
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.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 27–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) && !$sizeofframes | 136–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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 1038 | 27–155 | 88 | |
| 8.5 | 1038 | 27–155 | 88 | |
| 8.4 | 1038 | 27–155 | 88 | 134 fewer instructions than PHP 8.3 |
| 8.3 | 1172 | 30–163 | 88 | |
| 8.2 | 1172 | 30–163 | 88 | 4 more instructions than PHP 8.1 |
| 8.1 | 1168 | 30–163 | 88 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 1169 | 30–163 | 88 |
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
- getid3_id3v2::fseek()
- getid3_id3v2::fread()
- getid3_id3v2::error()
- getid3_lib::BigEndian2Int()
- getid3_id3v2::DeUnsynchronise()
- getid3_id3v2::LookupExtendedHeaderRestrictionsTagSizeLimits()
- getid3_id3v2::LookupExtendedHeaderRestrictionsTextEncodings()
- getid3_id3v2::LookupExtendedHeaderRestrictionsTextFieldSize()
- getid3_id3v2::LookupExtendedHeaderRestrictionsImageEncoding()
- getid3_id3v2::LookupExtendedHeaderRestrictionsImageSizeSize()
- getid3_id3v2::warning()
- getid3_id3v2::ID3v2HeaderLength()
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.
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.