Skip to content

Fix blank Place Ad page with Jetpack Boost JS deferral - #173

Merged
sorinmarta merged 2 commits into
masterfrom
fix-3177
Oct 29, 2026
Merged

sorinmarta merged 2 commits into
masterfrom
fix-3177

Conversation

@sorinmarta

Copy link
Copy Markdown
Contributor

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.

Fixes Strategy11/awpcp#3177
Stops Jetpack Boost's deferral from breaking the Place Ad and Edit Ad forms.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8eb172bd-2c8c-4740-8e1d-1e35d788956e
Commits

Reviewing files that changed from the base of the PR and between 357533e and 601ced0.

Files selected for processing: 4
  • includes/frontend/class-edit-listing-page.php
  • includes/functions/deprecated.php
  • includes/media/class-mime-types.php
  • templates/frontend/submit-listing-page/listing-information-step.tpl.php
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sorinmarta sorinmarta added run analysis Run the phpcs run tests Run the unit tests franky-review labels Oct 29, 2026
Both functions have been no-ops since PHP 8.0 and are deprecated in
PHP 8.5, which fails the PHPCS inspection.
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Oct 29, 2026

@franky-the-going-merry franky-the-going-merry Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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's do_shortcode_tag filter rewrites those tags to <script data-jetpack-boost="ignore" type=...> inside the JSON string. The new quotes end the string early, so JSON.parse fails at position 1335 and the JS statement throws SyntaxError: 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.parse succeeds (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:41 still has wp_json_encode( $javascript ) inside an inline <script> without JSON_HEX_TAG. Its payload is category data, so Boost did not break it in my run, but a category name containing <script or </script> would hit the same problem. Adding JSON_HEX_TAG there is a one-word change.
  • No regression test for the encoded output.
  • The finfo_close() / imagedestroy() to unset() 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.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Oct 29, 2026
@sorinmarta
sorinmarta merged commit 4f83b1a into master Oct 29, 2026
9 checks passed
@sorinmarta
sorinmarta deleted the fix-3177 branch October 29, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run analysis Run the phpcs run tests Run the unit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant