-
Notifications
You must be signed in to change notification settings - Fork 118
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
Deprecation warning - use of null in str_replace - legacy/libraries/File_field.php (840) #4349
Comments
jcogs-design
added a commit
to jcogs-design/ExpressionEngine
that referenced
this issue
Jun 7, 2024
Adds a simple conditional check to line 840 to ensure that the value returned by $file->getAbsoluteURL() is not null before calling str_replace(). There may be wider issues arising from this condition (that $file->getAbsoluteURL() returns null) so possibly some other conditional is needed to handle what to do if this substitution check fails... but looks the structure added is similar to the one used to check str_replace() on line 859 and there are no fancy routing options taking there if that test skips the str_replace, so am guessing this is all that is needed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description of the problem
Issue reported by Chris Wong via Slack (@chunkitchris)
"I set up a local server with PHP 8.20 and did some initial work. Then, I exported the database and imported it to the production server, which is running PHP 8.2.12. I continued to work on the production site by entering data from my clients. After that, I exported the database and imported it back to my local server for further development. When I tried to access a channel with the Bloqs add-on, an error message was displayed.
Turns out this is caused by use of an untrapped call to
$file->getAbsoluteURL()
on line 840 of legacy/libraries/File_field.php. If the function call returns null, this is passed to str_replace() and it is this passing of null to the php function that causes the deprecation error.How To Reproduce
As per description - in Chris' case it seems to have been triggered by something related to Bloqs add-on, but the cause of the warning is independent of that.
Error Messages
Environment Details:
Possible Solution
Put in a check to ensure that the value returned by
$file->getAbsoluteURL()
is not null before calling the php str_replace function.The text was updated successfully, but these errors were encountered: