Skip to content

Fixed block theme styles without dom - #561

Open
girishpanchal30 wants to merge 4 commits into
developmentfrom
bugfix/544
Open

Fixed block theme styles without dom#561
girishpanchal30 wants to merge 4 commits into
developmentfrom
bugfix/544

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

Summary

Improved the removal of the dependency on the PHP DOM extension (DOMDocument) in favor of a regex-based approach, which increases compatibility and simplifies the code.

Check before Pull Request is ready:

Closes #544

@pirate-bot

pirate-bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Plugin build for 09058cb is ready 🛎️!

Copilot AI 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.

🟡 Changes recommended

Composer still requires ext-dom, and raw regex matching can activate style-like text from scripts or comments.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Replaces DOM-based block-theme style extraction with regex matching to prevent crashes when the PHP DOM extension is unavailable.

Changes:

  • Extracts and compares inline style tags without DOMDocument.
  • Adds block-theme style-flow unit tests.
  • Updates wp-env and E2E CI to PHP 8.2.
File summaries
File Description
includes/classes/wp-maintenance-mode.php Replaces DOM traversal with regex extraction.
tests/block-theme-styles-test.php Tests head/footer style handling.
.wp-env.json Updates wp-env to PHP 8.2.
.github/workflows/test-e2e.yml Updates E2E setup to PHP 8.2.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Balanced

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

Comment thread includes/classes/wp-maintenance-mode.php
Comment thread includes/classes/wp-maintenance-mode.php Outdated

Copilot AI 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.

🟡 Changes recommended

The regression test inspects implementation text, and the unrelated PHP runtime upgrades reduce compatibility coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 5/6 changed files
  • Comments generated: 3
  • Review effort level: Balanced

uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
php-version: "8.2"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The PHP 7.4 wp-env image is based on Debian Bullseye, whose security repository release file has expired. As a result, apt-get update fails and the image build cannot complete.

Therefore, I bumped the PHP version to 8.2 so the test environment can build and the test case can run successfully. This change is only for the test environment and does not mean that the plugin's minimum supported PHP version has been increased to 8.2.

Comment thread .wp-env.json
{
"core": null,
"phpVersion": "7.4",
"phpVersion": "8.2",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sama as #561 (comment)

Comment thread tests/block-theme-styles-test.php Outdated
Comment on lines +101 to +103
$source = file_get_contents( WPMM_PATH . 'includes/classes/wp-maintenance-mode.php' );

$this->assertFalse( strpos( $source, 'DOMDocument' ), 'The block-theme style flow must not depend on the DOM extension.' );

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have reverted this assertion in 09058cb, and verified that the custom logic for extracting the <style> tag works correctly by adding assertions for the extracted styles.

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.

Verified at HEAD. The implementation-text assertion is gone. The focused class passed with 4 tests and 6 behavioral assertions on WordPress 7.1 and PHP 8.3.33.

@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 DOM-free block-theme style flow passed focused callback tests.

Composer no longer requires ext-dom, and the changed trust-boundary check found no security issue.

Validation details
  • WordPress 7.1 and PHP 8.3 passed 4 tests and 6 assertions.
  • The focused callback check excluded style text inside scripts and comments.
  • Composer metadata validated after removing ext-dom.
Untested areas
  • CI owns full suites, builds, E2E checks, and PHP-version matrices.

🤖 Automated review · run code-review-agent_6aa28fa12f0325.41822098.


🤖 Review agent — review posted ✅

Run code-review-agent_6aa28fa12f0325.41822098 · 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.

Block-theme maintenance page fatals when DOMDocument is unavailable

4 participants