PHP 8.1 deprecation, fix submitted
-
Just flagging this in case anyone else is running into the same issue.
Since PHP 8.1,
preg_quote()gives a deprecation warning if it receives anullvalue. In this plugin that can happen when a post contains an<img>tag without analtattribute, which is fairly common with hotlinked or scraped images.Deprecated: preg_quote(): Passing null to parameter #1 ($str) of type string is deprecated in .../auto-upload-images/src/WpAutoUpload.php on line 85I noticed this was also reported in the “doesn’t work now” thread back in November 2023, which is now closed to replies, as well as in a couple of other threads here since then.
I’ve submitted a small fix upstream:
https://github.com/airani/wp-auto-upload/pull/105
If anyone wants to patch it locally in the meantime, the change is in
src/WpAutoUpload.phpon line 85:preg_quote($image['alt'], '/')becomes:
preg_quote($image['alt'] ?? '', '/')This doesn’t change the behaviour for images that already have alt text, and
preg_quote('')is effectively a no-op in the surrounding pattern.@airani, I’m also happy to help keep the plugin maintained if that would be useful. Either way, the fix is yours to use.
You must be logged in to reply to this topic.