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

[Bug]: Call to a member function format() on false in AudioCore.php:543 #29

Closed
panVag opened this issue Jun 3, 2024 · 0 comments · Fixed by #30
Closed

[Bug]: Call to a member function format() on false in AudioCore.php:543 #29

panVag opened this issue Jun 3, 2024 · 0 comments · Fixed by #30
Labels
bug Something isn't working

Comments

@panVag
Copy link
Contributor

panVag commented Jun 3, 2024

What happened?

When trying to parse a specific date I get an error.

[2024-06-03 05:51:03] production.ERROR: Call to a member function format() on false {"exception":"[object] (Error(code: 0): Call to a member function format() on false at /app/vendor/kiwilan/php-audio/src/Models/AudioCore.php:543)
[stacktrace]
#0 /app/vendor/kiwilan/php-audio/src/Audio.php(420): Kiwilan\\Audio\\Models\\AudioCore::fromQuicktime()
#1 /app/vendor/kiwilan/php-audio/src/Audio.php(102): Kiwilan\\Audio\\Audio->parse()

How to reproduce the bug

Try a date that doesn't match the format specified in https://github.com/kiwilan/php-audio/blob/main/src/Models/AudioCore.php#L543

I get this with dates that don't include time like 2024-01-01.

The following snippet can simulate the issue:

$creation_date = '2024-01-01';
$creation_date = date_create_from_format('Y-m-d\TH:i:s\Z', $creation_date);
var_dump($creation_date?->format('Y-m-d\TH:i:s\Z'));

Package Version

v3.0.06

PHP Version

8.3

Which operating systems does with happen with?

Linux

Notes

The date_create_from_format() will return false when it can't parse the date according to the manual. In which case the null safe operator will not work because it's a boolean. I think this is not intended.

Up to now it only happened with quicktime format. Haven't dig the code in order to figure out why is that, so it might make sense to check if there are other snippets that could cause the same issue.

@panVag panVag added the bug Something isn't working label Jun 3, 2024
ewilan-riviere added a commit that referenced this issue Jun 4, 2024
…t-on-false

#29 Call to a member function format() on false in AudioCore.php:543
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant