Repository navigation
Enhance data handling for Black Friday - #3198
Conversation
Bundle Size Diff
|
|
Plugin build for 3c5509b is ready 🛎️!
|
E2E TestsPlaywright Test Status: See serial and parallel matrix jobs Performance ResultsserverResponse: {"q25":274.76,"q50":304.34,"q75":311.84,"cnt":10}, firstPaint: {"q25":1020.58,"q50":1057.15,"q75":1200.73,"cnt":10}, domContentLoaded: {"q25":2890.99,"q50":2929.87,"q75":2943.3,"cnt":10}, loaded: {"q25":2894.17,"q50":2932.81,"q75":2946.41,"cnt":10}, firstContentfulPaint: {"q25":1432.45,"q50":1475.37,"q75":2222.85,"cnt":10}, firstBlock: {"q25":12747.55,"q50":12896.15,"q75":13076.79,"cnt":10}, type: {"q25":22.13,"q50":24.23,"q75":26.03,"cnt":10}, typeWithoutInspector: {"q25":17.43,"q50":19.66,"q75":23.95,"cnt":10}, typeWithTopToolbar: {"q25":25.06,"q50":27.1,"q75":31.17,"cnt":10}, typeContainer: {"q25":11.86,"q50":12.23,"q75":13.02,"cnt":10}, focus: {"q25":93.69,"q50":100.51,"q75":114.1,"cnt":10}, inserterOpen: {"q25":33.38,"q50":33.99,"q75":36.6,"cnt":10}, inserterSearch: {"q25":21.11,"q50":21.71,"q75":21.98,"cnt":10}, inserterHover: {"q25":4.16,"q50":4.42,"q75":5.02,"cnt":20}, loadPatterns: {"q25":1404.23,"q50":1430.86,"q75":1514.25,"cnt":10}, listViewOpen: {"q25":158.04,"q50":168.25,"q75":181.6,"cnt":10} |
There was a problem hiding this comment.
🟢 Approved
This approves the fix; the notes ask a developer to confirm two input shapes the new checks may meet.
otter-blocks.php:168—noteThethemeisle_sdk_telemetry_productscallback reads$product['slug']without a check. An earlier callback that returns an entry withoutslugwould emitUndefined array key "slug", like the fixed Black Friday warning. The SDK seeds each entry with a slug, and no known plugin removes it. Isslugguaranteed after the filter? If yes, the code is safe. If not, skip entries withoutslug.
Validation details
- Files reviewed: 5/5 changed files. Narrowed input: Sources was not fully checked.
- The new tests pass at HEAD:
cd /repo && set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-cache-result --filter 'TestBlackFridayData::' 2>&1 …printedOK (3 tests, 6 assertions)(run R2) - Against the base code, the two guard tests fail on the reported warning:
rm -rf /workspace/checks/R1/base-tree && rsync -a --exclude=.git /repo/ /workspace/checks/R1/base-tree/ && cd /workspace…printedErrors: 2(run R4) - The Blocks Animation and Blocks CSS callbacks warned on empty input at base and pass it through at HEAD `mkdir -p /workspace/checks/R1/base-files && cd /workspace/checks/R1 && cat > closure-harness.php <<'EOF'
Questions for the author
- Does the installed SDK show no sale notice when this filter returns an empty array? The SDK v3.3.72 source suggests so. - Can a supported filter return an empty `default` and still expect the Otter entry?Untested areas
- Narrowed input: Sources. Only the SDK seed and the Easy MCP AI empty-array policy were checked as producers. - The PHPUnit suite cannot load the Blocks Animation and Blocks CSS callbacks, so only a standalone harness ran them.| */ | ||
| public function add_black_friday_data( $configs ) { | ||
| // An earlier filter may drop the default entry, or empty the list to opt out of the sale. | ||
| if ( empty( $configs['default'] ) ) { |
There was a problem hiding this comment.
note The new empty() check also skips a present but empty default, such as array( 'default' => array() ). Before this change, Otter still added its sale entry for that value. Does any supported filter send an empty default and expect the Otter entry? If no, the change is safe. If yes, check ! isset() instead, so an empty array still gets the entry.
There was a problem hiding this comment.
No supported producer sends an empty default. The SDK always seeds it from get_notice_data(), a non-empty array of title, sale_url, message and time_left (Announcements.php:212-217). Every themeisle_sdk_blackfriday_data callback on the test install reads default and none empties it, so an empty default only arrives when a filter blanks the sale data. Passing it through unchanged is the intended opt-out.
|
🎉 This PR is included in version 3.2.12 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Closes #3196
Summary
Improved Black Friday data integration by adding checks for missing or empty
defaultconfiguration entries inMain::add_black_friday_data()and the filter callbacks inblocks-animation.phpandblocks-css.php. These checks allow earlier filters to opt out of the promotion cleanly and prevent unnecessary processing when no default sale configuration is available.Checklist before the final review