Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error analyzing mp3 file with chapters: "Caught exception: Undefined array key 1" #355

Closed
yassinedoghri opened this issue Dec 15, 2021 · 3 comments

Comments

@yassinedoghri
Copy link

When analyzing an mp3 file with chapters, I get the following error:
The returned data from the analyze function is missing a chunk of the info, such as mime_type, avdataoffset, ...

Steps to reproduce

  1. Download the following mp3: https://www.buzzsprout.com/1529720/6705454-cc-1-introductions.mp3
  2. Analyze it using the $getID3->analyze($file) method.
  3. Dump result and see error with missing data.

Expected behavior

The returned data from the analyze method should include all of the expected data.

Relevant logs and/or screenshots

What is returned:
image

What should be returned:
image

Context

  • getID3: v2.0.0-beta4
  • PHP v8.0.13

Possible fixes

With some brute force var_dumps, I was able to pinpoint the issue to this line, just after the WXXX case:

// v1.9 - getid3/module.tag.id3v2.php - line 2067
// v2 - src/Module/Tag/ID3v2.php - line 2066
list($subframe['chapter_url_description'], $subframe['chapter_url']) = explode("\x00", $encoding_converted_text, 2);

👉 Apparently, the $encoding_converted_text doesn't include the chapter_url so the index 1 doesn't exist in the array created from the explode().

Naively, this fixes it:

$encoding_converted_text_array = explode("\x00", $encoding_converted_text, 2);
$subframe['chapter_url_description'] = $encoding_converted_text_array[0];
$subframe['chapter_url'] = isset($encoding_converted_text_array[1]) ? $encoding_converted_text_array[1] : '';

That being said, thanks for your hard work, getID3 is amazing 🙂

@yassinedoghri yassinedoghri changed the title Error analyzing mp3 file with chapters : "Caught exception: Undefined array key 1" Error analyzing mp3 file with chapters: "Caught exception: Undefined array key 1" Dec 15, 2021
JamesHeinrich added a commit that referenced this issue Dec 15, 2021
@JamesHeinrich
Copy link
Owner

You correctly traced the source of the problem. Even more naively, error-suppressing the list will fix it:
@list($subframe['chapter_url_description'], $subframe['chapter_url']) = explode("\x00", $encoding_converted_text, 2);
Which is how I have fixed it in a99e0a2

@StudioMaX
Copy link
Collaborator

I backported this fix to 2.0 in #356.
Please require james-heinrich/getid3:^2.0-dev if you need so in your composer.json until the new version is released.

@yassinedoghri
Copy link
Author

Awesome, thank you both!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants