Commit b0000a5e19 for woocommerce
commit b0000a5e196b34145a0f5ba5b0129571b5f2cd93
Author: Tony Arcangelini <33258733+arcangelini@users.noreply.github.com>
Date: Mon Jan 5 04:30:35 2026 -0600
Email Editor: fix classic block (#62605)
* Email Editor: fix classic block
* Add changefile(s) from automation for the following project(s): packages/php/email-editor
* Update test
* Use strict string comparison instead of empty.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Allison Levine <1689238+allilevine@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
diff --git a/packages/php/email-editor/changelog/62605-fix-email-editor-classic-content b/packages/php/email-editor/changelog/62605-fix-email-editor-classic-content
new file mode 100644
index 0000000000..2a011eff8e
--- /dev/null
+++ b/packages/php/email-editor/changelog/62605-fix-email-editor-classic-content
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+Comment: Email Editor: make Cleanup_Preprocessor only remove truly empty blocks.
+
diff --git a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-cleanup-preprocessor.php b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-cleanup-preprocessor.php
index c9a33bc8bc..ec60829c40 100644
--- a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-cleanup-preprocessor.php
+++ b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-cleanup-preprocessor.php
@@ -25,7 +25,7 @@ class Cleanup_Preprocessor implements Preprocessor {
// https://core.trac.wordpress.org/ticket/45312
// \WP_Block_Parser::parse_blocks() sometimes add a block with name null that can cause unexpected spaces in rendered content
// This behavior was reported as an issue, but it was closed as won't fix.
- if ( null === $block['blockName'] ) {
+ if ( null === $block['blockName'] && '' === trim( $block['innerHTML'] ?? '' ) ) {
unset( $parsed_blocks[ $key ] );
}
}
diff --git a/packages/php/email-editor/tests/unit/Engine/Renderer/ContentRenderer/Preprocessors/Cleanup_Preprocessor_Test.php b/packages/php/email-editor/tests/unit/Engine/Renderer/ContentRenderer/Preprocessors/Cleanup_Preprocessor_Test.php
index 0c9405a23a..f10129b180 100644
--- a/packages/php/email-editor/tests/unit/Engine/Renderer/ContentRenderer/Preprocessors/Cleanup_Preprocessor_Test.php
+++ b/packages/php/email-editor/tests/unit/Engine/Renderer/ContentRenderer/Preprocessors/Cleanup_Preprocessor_Test.php
@@ -108,4 +108,25 @@ class Cleanup_Preprocessor_Test extends \Email_Editor_Unit_Test {
$this->assertEquals( self::PARAGRAPH_BLOCK, $result[1] );
$this->assertEquals( self::COLUMNS_BLOCK, $result[2] );
}
+
+ /**
+ * Test it preserves blocks with null blockName but non-empty innerHTML
+ */
+ public function testItPreservesBlocksWithNullBlockNameButWithInnerHtml(): void {
+ $block_with_content = array(
+ 'blockName' => null,
+ 'attrs' => array(),
+ 'innerHTML' => '<p>Some content</p>',
+ );
+ $blocks = array(
+ self::COLUMNS_BLOCK,
+ $block_with_content,
+ self::PARAGRAPH_BLOCK,
+ );
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $this->assertCount( 3, $result );
+ $this->assertEquals( self::COLUMNS_BLOCK, $result[0] );
+ $this->assertEquals( $block_with_content, $result[1] );
+ $this->assertEquals( self::PARAGRAPH_BLOCK, $result[2] );
+ }
}