Commit 934f8a2709e for woocommerce
commit 934f8a2709ef85f4f8c20cd2ee09db9edd7951d2
Author: Jan Lysý <lysyjan@users.noreply.github.com>
Date: Thu Nov 12 15:24:23 2026 +0100
[Email Editor] Skip block settings without a name in block filters (#70907)
* Skip block settings without a name in email editor block filters
* Add changelog entry for email editor block settings fix
diff --git a/packages/php/email-editor/changelog/fix-stomail-8802-email-editor-block-name-warning b/packages/php/email-editor/changelog/fix-stomail-8802-email-editor-block-name-warning
new file mode 100644
index 00000000000..45bc81e16c0
--- /dev/null
+++ b/packages/php/email-editor/changelog/fix-stomail-8802-email-editor-block-name-warning
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Stop a PHP warning when block settings without a block name reach the email editor's block settings filter.
diff --git a/packages/php/email-editor/docs/block-registration.md b/packages/php/email-editor/docs/block-registration.md
index 4ca9735d360..303bb59b71e 100644
--- a/packages/php/email-editor/docs/block-registration.md
+++ b/packages/php/email-editor/docs/block-registration.md
@@ -84,7 +84,7 @@ function add_email_support_to_blocks( $settings, $metadata ) {
'my-plugin/another-block',
);
- if ( in_array( $settings['name'], $email_supported_blocks, true ) ) {
+ if ( isset( $settings['name'] ) && in_array( $settings['name'], $email_supported_blocks, true ) ) {
// Enable email support
$settings['supports']['email'] = true;
diff --git a/packages/php/email-editor/src/Integrations/Core/class-initializer.php b/packages/php/email-editor/src/Integrations/Core/class-initializer.php
index 3ba6d656e91..60c5248f5b2 100644
--- a/packages/php/email-editor/src/Integrations/Core/class-initializer.php
+++ b/packages/php/email-editor/src/Integrations/Core/class-initializer.php
@@ -194,6 +194,10 @@ class Initializer {
* @return array Modified block settings.
*/
public function update_block_settings( array $settings ): array {
+ if ( ! isset( $settings['name'] ) ) {
+ return $settings;
+ }
+
// Enable blocks in email editor and set rendering callback.
if ( in_array( $settings['name'], self::ALLOWED_BLOCK_TYPES, true ) ) {
$settings['supports']['email'] = true;
diff --git a/packages/php/email-editor/src/Integrations/WooCommerce/class-initializer.php b/packages/php/email-editor/src/Integrations/WooCommerce/class-initializer.php
index c490dd3f06b..37e8dabbfcc 100644
--- a/packages/php/email-editor/src/Integrations/WooCommerce/class-initializer.php
+++ b/packages/php/email-editor/src/Integrations/WooCommerce/class-initializer.php
@@ -48,6 +48,10 @@ class Initializer {
* @return array
*/
public function update_block_settings( array $settings ): array {
+ if ( ! isset( $settings['name'] ) ) {
+ return $settings;
+ }
+
if ( in_array( $settings['name'], self::ALLOWED_BLOCK_TYPES, true ) ) {
$settings['supports']['email'] = true;
$settings['render_email_callback'] = array( $this, 'render_block' );
diff --git a/packages/php/email-editor/tests/unit/Integrations/Core/Initializer_Test.php b/packages/php/email-editor/tests/unit/Integrations/Core/Initializer_Test.php
new file mode 100644
index 00000000000..f89e3743f4c
--- /dev/null
+++ b/packages/php/email-editor/tests/unit/Integrations/Core/Initializer_Test.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * This file is part of the WooCommerce Email Editor package
+ *
+ * @package Automattic\WooCommerce\EmailEditor
+ */
+
+declare(strict_types = 1);
+namespace Automattic\WooCommerce\EmailEditor\Integrations\Core;
+
+/**
+ * Unit test for the core blocks Initializer class.
+ */
+class Initializer_Test extends \Email_Editor_Unit_Test {
+ /**
+ * Test it returns block settings without a block name unchanged.
+ */
+ public function testItReturnsSettingsWithoutNameUnchanged(): void {
+ $settings = array( 'title' => 'No name' );
+
+ $this->assertSame( $settings, ( new Initializer() )->update_block_settings( $settings ) );
+ }
+
+ /**
+ * Test it enables email support for an allowed core block.
+ */
+ public function testItEnablesEmailSupportForAllowedBlock(): void {
+ $initializer = new Initializer();
+
+ $settings = $initializer->update_block_settings( array( 'name' => 'core/paragraph' ) );
+
+ $this->assertTrue( $settings['supports']['email'] );
+ $this->assertSame( array( $initializer, 'render_block' ), $settings['render_email_callback'] );
+ }
+}
diff --git a/packages/php/email-editor/tests/unit/Integrations/WooCommerce/Initializer_Test.php b/packages/php/email-editor/tests/unit/Integrations/WooCommerce/Initializer_Test.php
new file mode 100644
index 00000000000..625945e0580
--- /dev/null
+++ b/packages/php/email-editor/tests/unit/Integrations/WooCommerce/Initializer_Test.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * This file is part of the WooCommerce Email Editor package
+ *
+ * @package Automattic\WooCommerce\EmailEditor
+ */
+
+declare(strict_types = 1);
+namespace Automattic\WooCommerce\EmailEditor\Integrations\WooCommerce;
+
+/**
+ * Unit test for the WooCommerce blocks Initializer class.
+ */
+class Initializer_Test extends \Email_Editor_Unit_Test {
+ /**
+ * Test it returns block settings without a block name unchanged.
+ */
+ public function testItReturnsSettingsWithoutNameUnchanged(): void {
+ $settings = array( 'title' => 'No name' );
+
+ $this->assertSame( $settings, ( new Initializer() )->update_block_settings( $settings ) );
+ }
+
+ /**
+ * Test it enables email support and full alignment for the product image block.
+ */
+ public function testItEnablesEmailSupportForProductImageBlock(): void {
+ $initializer = new Initializer();
+
+ $settings = $initializer->update_block_settings( array( 'name' => 'woocommerce/product-image' ) );
+
+ $this->assertTrue( $settings['supports']['email'] );
+ $this->assertSame( array( 'full' ), $settings['supports']['align'] );
+ $this->assertSame( array( $initializer, 'render_block' ), $settings['render_email_callback'] );
+ }
+}