Repository navigation
Fixed AMP slider parser timeout - #3119
girishpanchal30 wants to merge 2 commits into
Conversation
Bundle Size Diff
|
|
Plugin build for a21c88a is ready 🛎️!
|
E2E TestsPlaywright Test Status: See serial and parallel matrix jobs Performance ResultsserverResponse: {"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} |
There was a problem hiding this comment.
🟢 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
DOMDocumentand escapes carousel IDs. - Adds tests for attribute escaping and malformed-markup parsing performance.
- Removes the unused
masterminds/html5dependency.
| 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.
There was a problem hiding this comment.
🟡 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…printedOK (2 tests, 3 assertions)(run R8) - Both tests fail on the base tree with
masterminds/html5installed:cd /workspace/checks/T1/base; set -o pipefail; timeout 900 vendor/bin/phpunit --do-not-cache-result --filter 'Test_AMP_S…printedFailed 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
iddiffers. - The libxml2 2.12.10, 2.13.8 and 2.14.5 sources still read
<?xmlas 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.phpfile 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
There was a problem hiding this comment.
🟢 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…printedOK (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
Closes #3071
Summary
Refactors the AMP slider block rendering to remove the dependency on the
masterminds/html5library and instead use PHP's built-inDOMDocumentfor 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