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

fixed deprecation crash (passing null to json_decode()) #82

Closed
wants to merge 1 commit into from

Conversation

pasqual-artif
Copy link

You cannot pass NULL to json_decode anymore... this prevents the file from being uploaded by using for example StorageRepository->addFile()

Comment on lines +123 to +124
$metadata = empty($content) ? [] : json_decode($content, true);
return $metadata;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO we still need the return $metadata ?? [] in case json_decode fails somehow

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the crash occurs in 123... the execution stops before the ternary can be called...

PHP 8.2.15

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't say the rest of the patch didn't look good :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? :D
I meant that the original line 123 crashed, before the ternary can choose something ^^

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that if somehow $content is not empty and CANNOT be properly decoded as JSON, then the second part of the ternary with the json_decode you use will put something that is not an array into $metadata, thus the return statement should (still) take care of that imho.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function json_decode() can't use NULL as first parameter... at least PHP 8.2.15.. so if $content is NULL in 123, the execution stops... no matter what happens afterwards...

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

Successfully merging this pull request may close these issues.

None yet

2 participants