Repository navigation
fix: guard the Black Friday callback against a missing default config - #4717
vytisbulkevicius wants to merge 1 commit into
Conversation
An earlier filter on themeisle_sdk_blackfriday_data can drop the 'default' entry, or empty the list to opt out of the sale. Reading $configs['default'] then emitted an "Undefined array key \"default\"" warning. Return $configs early when it is absent, matching the otter-blocks fix. Also type the callback's array param and return, and drop the now-redundant PHPStan baseline entries.
There was a problem hiding this comment.
🟢 Approved
This approves the guard; the inline comment asks for a PHPUnit case that covers the new early return.
Questions for the author
- Does the installed SDK (3.3.72,
src/Modules/Announcements.php) handle a config withoutdefaultorneve, including[]? A source read suggests it does, but no run confirmed it.
Validation details
- Files reviewed: 2/2 changed files.
- SDK 3.3.72 source read: it picks
defaultor a fallback and stops on an empty array. - The SDK's own producer always sends a non-empty
default. - No other SDK filter callback reads a removable key without a guard.
- The two removed baseline entries match the errors the new docblock types resolve.
Untested areas
- PHPStan and PHPUnit were not run. CI owns them.
- The admin screen with
WP_DEBUGwas not loaded in a site.
🤖 Automated review · run code-review-agent_6b05493291d1f7.89801139.
🤖 Review agent — review posted ✅ on 60608bc7 · approved · 1 finding · 14 min
Run code-review-agent_6b05493291d1f7.89801139 · trail
| // An earlier filter may drop the default entry, or empty the list to opt out of the sale. | ||
| if ( empty( $configs['default'] ) ) { | ||
| return $configs; | ||
| } |
There was a problem hiding this comment.
tests Add a PHPUnit case for the new guard. No test exercises add_black_friday_data(), so a regression of the Undefined array key "default" warning would pass CI. Add tests/test-neve-black-friday-data.php in the style of tests/test-neve-support-hub.php. Call add_black_friday_data() on a Main instance and assert that array() and an array without default come back unchanged with no neve key. These cases fail on the base code because phpunit.xml converts warnings to exceptions. Also assert that a non-empty default still gets a neve entry.
Reading
$configs['default']in thethemeisle_sdk_blackfriday_datacallback emitted an Undefined array key "default" warning when an earlier filter had dropped that entry. Guard it, matching the otter-blocks fix (#3198).What changed
inc/admin/dashboard/main.php—add_black_friday_data()returns$configsunchanged whendefaultis absent/empty, before reading it. Typed the array param and return.phpstan-baseline.neon— dropped the two now-redundantmissingType.iterableValueentries the typed docblock resolves.QA
Add a filter that empties the SDK config:
add_filter( 'themeisle_sdk_blackfriday_data', '__return_empty_array', 999 );.Load any admin screen with
WP_DEBUGon.Expect: no
Undefined array key "default"warning. Without the filter, the Black Friday data still renders as before.Refs #4716 (base is
development, not the default branchmaster, so link via the Development sidebar)