{"id":19012944,"date":"2026-09-06T19:04:30","date_gmt":"2026-09-06T19:04:30","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/php-8-1-deprecation-fix-submitted\/"},"modified":"2026-09-06T19:04:30","modified_gmt":"2026-09-06T19:04:30","slug":"php-8-1-deprecation-fix-submitted","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/php-8-1-deprecation-fix-submitted\/","title":{"rendered":"PHP 8.1 deprecation, fix submitted"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Just flagging this in case anyone else is running into the same issue.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Since PHP 8.1, <code>preg_quote()<\/code> gives a deprecation warning if it receives a <code>null<\/code> value. In this plugin that can happen when a post contains an <code>&lt;img&gt;<\/code> tag without an <code>alt<\/code> attribute, which is fairly common with hotlinked or scraped images.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Deprecated: preg_quote(): Passing null to parameter #1 ($str) of type string is deprecated in ...\/auto-upload-images\/src\/WpAutoUpload.php on line 85<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">I noticed this was also reported in the &#8220;doesn&#8217;t work now&#8221; thread back in November 2023, which is now closed to replies, as well as in a couple of other threads here since then.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;ve submitted a small fix upstream:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/airani\/wp-auto-upload\/pull\/105\">https:\/\/github.com\/airani\/wp-auto-upload\/pull\/105<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If anyone wants to patch it locally in the meantime, the change is in <code>src\/WpAutoUpload.php<\/code> on line 85:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>preg_quote($image&#091;'alt'], '\/')<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">becomes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>preg_quote($image&#091;'alt'] ?? '', '\/')<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This doesn&#8217;t change the behaviour for images that already have alt text, and <code>preg_quote('')<\/code> is effectively a no-op in the surrounding pattern.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/profiles.wordpress.org\/airani\/\">@airani<\/a>, I&#8217;m also happy to help keep the plugin maintained if that would be useful. Either way, the fix is yours to use.<\/p>\n","protected":false},"template":"","class_list":["post-19012944","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19012944","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19012944\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19012944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}