Fix PHP 8.4 null deprecation warnings in class-delivery.php#1179
Merged
Conversation
When a parsed tag has no src attribute, get_tag_element() accessed $attributes['src'] directly, emitting 'Undefined array key "src"' and passing null downstream into sanitize_url(), which then triggered 'strlen(): Passing null' and 'strtok(): Passing null' deprecations on PHP 8.4. - Default missing src to an empty string and bail when no usable URL. - Guard sanitize_url() against non-string/empty input.
gabriel-detassigny
approved these changes
Jun 18, 2026
gabrielcld2
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Reported on the WordPress.org support forum: PHP 8.4 deprecation warnings from
class-delivery.php:Root cause
In
get_tag_element(), thesrcattribute was dereferenced directly:When a parsed tag has no
srcattribute, this emitsUndefined array key "src"and sets$raw_urltonull. That null then flows intosanitize_url(), wherestrlen( $url )andstrtok( $url, '?' )trigger the PHP 8.4 deprecation notices.Fix
srcto an empty string (?? '') and bail early when there is no usable URL.sanitize_url()against non-string / empty input as a defensive measure.QA
srcattribute (or otherwise empty source).Undefined array key "src"warning plusstrlen()/strtok()null deprecations in the logs.