• ioannislazaridis

    (@ioannislazaridis)


    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 a null value. In this plugin that can happen when a post contains an <img> tag without an alt attribute, 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 85

    I 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.php on 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.