Repository navigation
Ignore script tags without an id in the attributes filter - #60
Conversation
Themes and other plugins can print script tags without an id, which made the wp_script_attributes filter emit an "Undefined array key" warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
|
SDLC label: |
Summary
Fixes #59
wp_script_attributesruns for every script tag printed throughwp_get_script_tag(), including tags from themes and other plugins that have noid. The filter now treats a missingidas "not our script" and returns those attributes unchanged.Adds
tests/Regression/script-attributes.php, which the existingphpRegression.spec.tspicks up:Evidence
Ran the new regression file in WordPress Playground (latest WordPress, PHP 8.3). Playground has no Docker requirement, but its SQLite database can't create the MySQL temporary table that
tests/Support/isolated-options.phpuses. For this local run only, a stub of that helper ran the closure directly. CI runs the real helper on MySQL.FAIL: ErrorException: Undefined array key "id" @ src/ScriptRegistry.php:57After:
Regression checks passedPHP 7.4 wasn't tested locally;
??works in PHP 7.0 and later, and CI's WordPress/PHP matrix covers 7.4.Security implications
Merge Danger
Door: two-way
Blast Radius: minimal
Only affects tags without an
id, which previously failed the comparison anyway (nullnever equalssimpleanalytics-js). The attributes on our own script are unchanged.Summary by CodeRabbit
idattribute. Matching registered scripts continue to receive their configured attributes.