Skip to content

Fixed AMP slider parser timeout - #3119

Open
girishpanchal30 wants to merge 2 commits into
developmentfrom
bugfix/3071
Open

girishpanchal30 wants to merge 2 commits into
developmentfrom
bugfix/3071

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

Closes #3071

Summary

Refactors the AMP slider block rendering to remove the dependency on the masterminds/html5 library and instead use PHP's built-in DOMDocument for HTML parsing. It also introduces comprehensive unit tests for the AMP slider block, ensuring proper handling of edge cases such as malformed HTML and attribute escaping.


Checklist before the final review

  • Included E2E or unit tests for the changes in this PR.
  • Visual elements are not affected by independent changes.
  • It is at least compatible with the minimum WordPress version.
  • It loads additional script in frontend only if it is required.
  • Does not impact the Core Web Vitals.
  • In case of deprecation, old blocks are safely migrated.
  • It is usable in Widgets and FSE.
  • Copy/Paste is working if the attributes are modified.
  • PR is following the best practices

@pirate-bot

Copy link
Copy Markdown
Contributor

Bundle Size Diff

Package Old Size New Size Diff
Animations 178.33 KB 178.33 KB 0 B (0.00%)
Blocks 1.65 MB 1.65 MB 0 B (0.00%)
CSS 7.83 KB 7.83 KB 0 B (0.00%)
Dashboard 172.49 KB 172.49 KB 0 B (0.00%)
Onboarding 68.14 KB 68.14 KB 0 B (0.00%)
Export Import 4.73 KB 4.73 KB 0 B (0.00%)
Pro 439.85 KB 439.85 KB 0 B (0.00%)

@pirate-bot

pirate-bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Plugin build for a21c88a is ready 🛎️!

@pirate-bot

pirate-bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

E2E Tests

Playwright Test Status: See serial and parallel matrix jobs

Performance Results serverResponse: {"q25":397.11,"q50":434.86,"q75":436.37,"cnt":10}, firstPaint: {"q25":1500.24,"q50":1712.55,"q75":1849.87,"cnt":10}, domContentLoaded: {"q25":4183.13,"q50":4197.78,"q75":4219.04,"cnt":10}, loaded: {"q25":4186.79,"q50":4201.33,"q75":4222.47,"cnt":10}, firstContentfulPaint: {"q25":2732.85,"q50":3165.36,"q75":3173.04,"cnt":10}, firstBlock: {"q25":19483.72,"q50":19551.55,"q75":19603.02,"cnt":10}, type: {"q25":32.07,"q50":33.27,"q75":34.35,"cnt":10}, typeWithoutInspector: {"q25":27.07,"q50":31.01,"q75":34.8,"cnt":10}, typeWithTopToolbar: {"q25":37.51,"q50":42.43,"q75":43.2,"cnt":10}, typeContainer: {"q25":17.44,"q50":18.27,"q75":20.22,"cnt":10}, focus: {"q25":149.37,"q50":156.16,"q75":162.38,"cnt":10}, inserterOpen: {"q25":49.71,"q50":54.03,"q75":55.58,"cnt":10}, inserterSearch: {"q25":33.93,"q50":34.83,"q75":36.7,"cnt":10}, inserterHover: {"q25":5.44,"q50":5.65,"q75":6.01,"cnt":20}, loadPatterns: {"q25":2104.4,"q50":2134.94,"q75":2141.43,"cnt":10}, listViewOpen: {"q25":266.27,"q50":280.38,"q75":284.55,"cnt":10}

@girishpanchal30
girishpanchal30 requested a balanced review from Copilot October 15, 2026 05:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused replacement preserves verified slider output, adds regression coverage, and has no identified blocking issues.

0 open findings

What changed in this PR

Addresses AMP slider parser timeouts reported in #3071 by replacing the HTML5 library with PHP’s DOMDocument.

Changes:

  • Switches parsing and serialization to DOMDocument and escapes carousel IDs.
  • Adds tests for attribute escaping and malformed-markup parsing performance.
  • Removes the unused masterminds/html5 dependency.
File Description
tests/​test-amp-slider-block.php Adds AMP slider rendering regression tests.
inc/​render/​amp/​class-slider-block.php Replaces the parser and escapes carousel IDs.
composer.lock Removes the locked HTML5 parser package.
composer.json Removes the HTML5 parser requirement.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes requested

The parser fix works and both new tests detect it. Add the missing : void return types to the two new test methods.

Validation details
  • Files reviewed: 4/4 changed files.
  • The new tests pass on HEAD with PHP 8.3 and libxml 2.9.14: cd /workspace/checks/T1; for t in head base; do mkdir -p $t/build/animation; echo "<?php return array('dependencies'=>ar… printed OK (2 tests, 3 assertions) (run R8)
  • Both tests fail on the base tree with masterminds/html5 installed: cd /workspace/checks/T1/base; set -o pipefail; timeout 900 vendor/bin/phpunit --do-not-cache-result --filter 'Test_AMP_S… printed Failed asserting that 6.347926139831543 is less than 2. (run R9)
  • The slide markup output is the same on the base and on HEAD. Only the escaped id differs.
  • The libxml2 2.12.10, 2.13.8 and 2.14.5 sources still read <?xml as UTF-8.
  • No other code references masterminds.
Untested areas
  • The sandbox has no AMP plugin, so a real AMP page request was not rendered.
  • The tests ran with a stub build/animation/frontend.asset.php file because no frontend build was made.

🤖 Automated review · run code-review-agent_6ad06d1c1ea9c0.54130266.


🤖 Review agent — review posted ✅ on f7351e6d · changes requested · 1 finding · 10 min

Run code-review-agent_6ad06d1c1ea9c0.54130266 · trail

Comment thread tests/test-amp-slider-block.php Outdated

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approved

The PR passes. The earlier return-type request is fixed, and the new tests still pass on HEAD.

Validation details
  • Files reviewed: 4/4 changed files.
  • The new tests pass on HEAD with PHP 8.3.35: cd /workspace/checks/T1; rm -rf head; cp -a /repo head; mkdir -p head/build/animation; echo "<?php return array('depende… printed OK (2 tests, 3 assertions) (run R3)
  • Run code-review-agent_6ad06d1c1ea9c0.54130266 showed both tests fail on the base tree, not rerun.
  • The production code is unchanged since that review.
Untested areas
  • The sandbox has no AMP plugin, so a real AMP page request was not rendered.
  • The tests ran with a stub frontend asset file because no frontend build was made.

🤖 Automated review · run code-review-agent_6ad07292374687.79071249.


🤖 Review agent — review posted ✅ on a21c88a2 · approved · 0 findings · 3 min

Run code-review-agent_6ad07292374687.79071249 · trail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants