Commit 804105c61e for woocommerce

commit 804105c61ebd78ffaa6b0c22361881692209ea81
Author: Tony Arcangelini <33258733+arcangelini@users.noreply.github.com>
Date:   Fri Dec 19 15:18:55 2025 +0100

    Email Editor: fix block width preprocessor (#62524)

    * Email Editor: fix block width preprocessor

    * Add changefile(s) from automation for the following project(s): packages/php/email-editor

    ---------

    Co-authored-by: github-actions <github-actions@github.com>

diff --git a/packages/php/email-editor/changelog/62524-fix-block-width-preprocessor b/packages/php/email-editor/changelog/62524-fix-block-width-preprocessor
new file mode 100644
index 0000000000..ce040f30a3
--- /dev/null
+++ b/packages/php/email-editor/changelog/62524-fix-block-width-preprocessor
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Email Editor: prevent fatal type errors in Blocks_Width_Preprocessor
\ No newline at end of file
diff --git a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-blocks-width-preprocessor.php b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-blocks-width-preprocessor.php
index 9e608a6607..c3e5d3d259 100644
--- a/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-blocks-width-preprocessor.php
+++ b/packages/php/email-editor/src/Engine/Renderer/ContentRenderer/Preprocessors/class-blocks-width-preprocessor.php
@@ -36,6 +36,7 @@ class Blocks_Width_Preprocessor implements Preprocessor {
 			// Currently we support only % and px units in case only the number is provided we assume it's %
 			// because editor saves percent values as a number.
 			$width_input = is_numeric( $width_input ) ? "$width_input%" : $width_input;
+			$width_input = is_string( $width_input ) ? $width_input : '100%';
 			$width       = $this->convert_width_to_pixels( $width_input, $layout_width );

 			if ( 'core/columns' === $block['blockName'] ) {
diff --git a/packages/php/email-editor/tests/unit/Engine/Renderer/ContentRenderer/Preprocessors/Blocks_Width_Preprocessor_Test.php b/packages/php/email-editor/tests/unit/Engine/Renderer/ContentRenderer/Preprocessors/Blocks_Width_Preprocessor_Test.php
index c7bb7fd550..2c01358402 100644
--- a/packages/php/email-editor/tests/unit/Engine/Renderer/ContentRenderer/Preprocessors/Blocks_Width_Preprocessor_Test.php
+++ b/packages/php/email-editor/tests/unit/Engine/Renderer/ContentRenderer/Preprocessors/Blocks_Width_Preprocessor_Test.php
@@ -539,4 +539,56 @@ class Blocks_Width_Preprocessor_Test extends \Email_Editor_Unit_Test {
 		$image_block = $result[0]['innerBlocks'][2]['innerBlocks'][0];
 		$this->assertEquals( '215px', $image_block['email_attrs']['width'] );
 	}
+
+	/**
+	 * Test it handles non-string width values
+	 */
+	public function testItHandlesNonStringWidthValues(): void {
+		$styles                       = $this->styles;
+		$styles['spacing']['padding'] = array(
+			'left'   => '0px',
+			'right'  => '0px',
+			'top'    => '0px',
+			'bottom' => '0px',
+		);
+
+		// Test numeric width (should be treated as percentage).
+		$blocks = array(
+			array(
+				'blockName'   => 'core/paragraph',
+				'attrs'       => array(
+					'width' => 50,
+				),
+				'innerBlocks' => array(),
+			),
+		);
+		$result = $this->preprocessor->preprocess( $blocks, $this->layout, $styles );
+		$this->assertEquals( '330px', $result[0]['email_attrs']['width'] ); // 660 * 0.5
+
+		// Test array width (should default to 100%).
+		$blocks = array(
+			array(
+				'blockName'   => 'core/paragraph',
+				'attrs'       => array(
+					'width' => array( 'value' => 50 ),
+				),
+				'innerBlocks' => array(),
+			),
+		);
+		$result = $this->preprocessor->preprocess( $blocks, $this->layout, $styles );
+		$this->assertEquals( '660px', $result[0]['email_attrs']['width'] ); // 100% of 660
+
+		// Test boolean width (should default to 100%).
+		$blocks = array(
+			array(
+				'blockName'   => 'core/paragraph',
+				'attrs'       => array(
+					'width' => true,
+				),
+				'innerBlocks' => array(),
+			),
+		);
+		$result = $this->preprocessor->preprocess( $blocks, $this->layout, $styles );
+		$this->assertEquals( '660px', $result[0]['email_attrs']['width'] ); // 100% of 660
+	}
 }