Repository navigation
Fix blank Place Ad page with Jetpack Boost JS deferral - #173
Conversation
Fixes Strategy11/awpcp#3177 Stops Jetpack Boost's deferral from breaking the Place Ad and Edit Ad forms.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 41 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Both functions have been no-ops since PHP 8.0 and are deprecated in PHP 8.5, which fails the PHPCS inspection.
There was a problem hiding this comment.
Approve. I reproduced the blank Place Ad page with the real Jetpack Boost plugin on master, and the form renders with this PR.
Repro (WordPress Playground, WP 7.1.4, Jetpack Boost 4.8.1 from wp.org with "Defer Non-Essential JavaScript" on, a page with [AWPCPPLACEAD]):
- Base
357533e: the page is blank under the title. Console:AWPCPSubmitListingPageData is not defined. The inline payload contains HTML with<script type="text/javascript">in it, and Boost'sdo_shortcode_tagfilter rewrites those tags to<script data-jetpack-boost="ignore" type=...>inside the JSON string. The new quotes end the string early, soJSON.parsefails at position 1335 and the JS statement throwsSyntaxError: Unexpected identifier 'ignore'. Base screenshot: https://github.com/user-attachments/assets/cc04144f-55e3-4fce-b3bc-ab644c6c62e9 - PR
601ced0: the payload has 0 raw<, so Boost has nothing to rewrite.JSON.parsesucceeds (6 sections) and the Category selection step renders with the category dropdown, captcha and Continue button. PR screenshot: https://github.com/user-attachments/assets/c22f3fc9-0e02-4e2f-8ae6-e770e47b07f1
CI is green (PHPUnit 7.4/8, PHPStan, PHPCS).
Not covered: I only loaded the Place Ad page (listing-information-step.tpl.php). The Edit Ad page (class-edit-listing-page.php) has the identical one-line change, but I did not load it with Boost on. I did not run the PHPUnit suite locally.
Non-blocking notes
templates/components/category-selector.tpl.php:41still haswp_json_encode( $javascript )inside an inline<script>withoutJSON_HEX_TAG. Its payload is category data, so Boost did not break it in my run, but a category name containing<scriptor</script>would hit the same problem. AddingJSON_HEX_TAGthere is a one-word change.- No regression test for the encoded output.
- The
finfo_close()/imagedestroy()tounset()change is unrelated to this ticket (the same change is in #172). Fine to keep, but it would read better as its own commit or PR.
Fixes Strategy11/awpcp#3177
Encodes the inline AWPCPSubmitListingPageData with JSON_HEX_TAG so Jetpack Boost's script rewriting no longer breaks the Place Ad and Edit Ad forms. Verified with the real Jetpack Boost plugin, not a simulation.