From 8f64331f1e2909e5d8a6f775cf54978ca17b957c Mon Sep 17 00:00:00 2001 From: Luke Rodgers Date: Thu, 23 Oct 2025 17:34:12 +0100 Subject: [PATCH 1/3] Prevent db_schema.xml declarations with comment="" from breaking zero downtime deployments The issue is if you define a db_schema.xml with comment="" then the system will always be flagged as needing to make changes. When a table is created there is no concept of a null versus empty string comment, the comment is either there or it is not and this disparity breaks the comparison. Given that the error here is never in the databases side of things, I believe it makes most sense to correct this during the reading and handling of db_schema.xml. We already have an area of code which is doing casting and manipulation of elements, so stripping out empty comment declarations (which will never make it to the database anyway) seems safe to me. --- .../Declaration/Schema/Dto/ElementFactory.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/ElementFactory.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/ElementFactory.php index ff770e2d0dcd8..0ea5d6d1cc047 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/ElementFactory.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/ElementFactory.php @@ -1,7 +1,7 @@ castGenericAttributes($elementStructuralData); + $elementStructuralData = $this->removeEmptyComments($elementStructuralData); $elementStructuralData['type'] = $type; return $this->typeFactories[$type]->create($elementStructuralData); } From 80597ab586b2091292765ddd2653a8fa09bddd58 Mon Sep 17 00:00:00 2001 From: Luke Rodgers Date: Fri, 24 Oct 2025 11:08:52 +0100 Subject: [PATCH 2/3] Fix static analysis --- .../Setup/Declaration/Schema/Dto/ElementFactory.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/ElementFactory.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/ElementFactory.php index 0ea5d6d1cc047..b9e98beec1542 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/ElementFactory.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/ElementFactory.php @@ -22,6 +22,8 @@ class ElementFactory * * Where @key - is xsi:type of the object * Where @value - is instance class name + * + * @var array */ private $typeFactories = []; @@ -73,7 +75,8 @@ private function castGenericAttributes(array $elementStructuralData) /** * Remove empty comments from the schema declaration * - * Empty comments are never persisted in the database, they always end up being read back as null by + * Empty comments are never persisted in the database, they always end up being read back as null + * * @see \Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DbSchemaReader::readColumns * * @param array $elementStructuralData From b5300f119ccdc546c5f0cd747881217e3f4a4bba Mon Sep 17 00:00:00 2001 From: Luke Rodgers Date: Fri, 24 Oct 2025 12:22:00 +0100 Subject: [PATCH 3/3] Fix static analysis Removed unnecessary empty line in docblock. --- .../Framework/Setup/Declaration/Schema/Dto/ElementFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/ElementFactory.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/ElementFactory.php index b9e98beec1542..a6bfa7dc10825 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/ElementFactory.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/ElementFactory.php @@ -76,7 +76,7 @@ private function castGenericAttributes(array $elementStructuralData) * Remove empty comments from the schema declaration * * Empty comments are never persisted in the database, they always end up being read back as null - * + * * @see \Magento\Framework\Setup\Declaration\Schema\Db\MySQL\DbSchemaReader::readColumns * * @param array $elementStructuralData