diff --git a/CHANGELOG.md b/CHANGELOG.md index cadb015..2999e4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# Version 18.3.1 + +## Bugfixes + +* Fix `AttributeObserverTrait::mergeEntity()`: columns with a default value (`default-values`) were never emptied by `clean-up-empty-columns`, because the attribute code was looked up in the list of header positions +* Fix XML DI configuration loading for `symfony/dependency-injection` 6.4 and 7.x: `ImportExtension` uses the loader shipped with Symfony again and falls back to the copied `XmlFileLoader` only where it is not available (Symfony 8) + # Version 18.3.0 ## Features diff --git a/composer.json b/composer.json index c1247dd..c5c9a70 100755 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "league/event": "^2.2", "ramsey/uuid": "^4.2|^4.7", "symfony/mailer": "^5.4|^6.4|^7.4", + "symfony/dependency-injection": "^6.4|^7.0|^8.0", "laminas/laminas-filter": "^2.31", "techdivision/import-dbal": "^2.1", "techdivision/import-dbal-collection": "^2.2", diff --git a/src/Observers/AttributeObserverTrait.php b/src/Observers/AttributeObserverTrait.php index 4a147b6..e71eae1 100644 --- a/src/Observers/AttributeObserverTrait.php +++ b/src/Observers/AttributeObserverTrait.php @@ -465,9 +465,11 @@ protected function mergeEntity(array $entity, array $attr, $changeSetName = null // if the value is empty AND it is IN the array with default column values // BUT it is NOT in the array with columns we want to clean-up the default // column value has to be removed, because we do NOT want to override the - // value existing in the database + // value existing in the database. The clean-up column keys are the header + // positions of the columns, so the attribute code has to be translated first if (array_key_exists($this->attributeCode, $this->getDefaultColumnValues()) && - array_key_exists($this->attributeCode, $this->getCleanUpEmptyColumnKeys()) === false + !($this->hasHeader($this->attributeCode) && + in_array($this->getHeader($this->attributeCode), $this->getCleanUpEmptyColumnKeys() ?? [], true)) ) { // remove the value from the array with the column values, because // this is the default value from the database and it should NOT diff --git a/symfony/DependencyInjection/ImportExtension.php b/symfony/DependencyInjection/ImportExtension.php index 9dbb380..b8e1ce5 100644 --- a/symfony/DependencyInjection/ImportExtension.php +++ b/symfony/DependencyInjection/ImportExtension.php @@ -17,6 +17,7 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader as SymfonyXmlFileLoader; use TechDivision\Import\DependencyInjection\Loader\XmlFileLoader; /** @@ -39,7 +40,10 @@ class ImportExtension extends Extension */ public function load(array $configs, ContainerBuilder $container): void { - $loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__) . '/Resources/config')); + // use the XML loader shipped with symfony/dependency-injection where available (6.4 and 7.x), + // symfony 8 removed it, so the copy of the 7.x loader has to be used there + $loaderClass = class_exists(SymfonyXmlFileLoader::class) ? SymfonyXmlFileLoader::class : XmlFileLoader::class; + $loader = new $loaderClass($container, new FileLocator(dirname(__DIR__) . '/Resources/config')); $loader->load('services.xml'); } }