-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Prevent db_schema.xml declarations with comment="" from breaking zero downtime deployments
#40242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.4-develop
Are you sure you want to change the base?
Changes from 4 commits
8f64331
80597ab
b5300f1
d451655
7c80241
b8c6cf9
3f55b7c
8188a01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <?php | ||
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| * Copyright 2015 Adobe | ||
| * All Rights Reserved. | ||
| */ | ||
| namespace Magento\Framework\Setup\Declaration\Schema\Dto; | ||
|
|
||
|
|
@@ -22,6 +22,8 @@ class ElementFactory | |
| * | ||
| * Where @key - is xsi:type of the object | ||
| * Where @value - is instance class name | ||
| * | ||
| * @var array | ||
| */ | ||
| private $typeFactories = []; | ||
|
|
||
|
|
@@ -70,6 +72,25 @@ private function castGenericAttributes(array $elementStructuralData) | |
| return $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 | ||
| * @return array | ||
| */ | ||
| private function removeEmptyComments(array $elementStructuralData) | ||
| { | ||
| if (isset($elementStructuralData['comment']) && $elementStructuralData['comment'] === "") { | ||
|
||
| unset($elementStructuralData['comment']); | ||
| } | ||
|
|
||
| return $elementStructuralData; | ||
| } | ||
|
|
||
| /** | ||
| * Instantiate different types of elements, depends on their xsi:type. | ||
| * | ||
|
|
@@ -84,6 +105,7 @@ public function create($type, array $elementStructuralData) | |
| } | ||
|
|
||
| $elementStructuralData = $this->castGenericAttributes($elementStructuralData); | ||
| $elementStructuralData = $this->removeEmptyComments($elementStructuralData); | ||
| $elementStructuralData['type'] = $type; | ||
| return $this->typeFactories[$type]->create($elementStructuralData); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.