Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.

Home Page:https://jetpack.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Image_CDN_Core::banned_domains() causes a PHP deprecation warning.

cfinke opened this issue · comments

Impacted plugin

Jetpack

Quick summary

A given day sees hundreds/thousands of these warnings in my PHP logs:

PHP Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-image-cdn/src/class-image-cdn-core.php on line 350

(Direct link to line: https://github.com/Automattic/jetpack/blob/trunk/projects/packages/image-cdn/src/class-image-cdn-core.php#L350 )

This is because wp_parse_url() can return null, and passing null to preg_match()'s second parameter is deprecated in PHP 8.1. Adding a check for if ( $host ) { before the foreach loop should fix this and save some cycles.

Steps to reproduce

I don't know exactly what posts or content are generating these warnings, just that they happen regularly.

A clear and concise description of what you expected to happen.

No response

What actually happened

No response

Impact

One

Available workarounds?

No but the platform is still usable

Platform (Simple and/or Atomic)

No response

Logs or notes

No response