From 5652ea6442203fcd1046ea0e6758a679d70b11a8 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Wed, 3 Aug 2022 08:41:54 +0200 Subject: [PATCH] Fix broken import without features --- Classes/Domain/Model/Import.php | 16 ++++++++++++---- .../CategoriesAssignment.php | 2 +- .../CategoriesAssignment/Import.php | 8 ++++---- Documentation/Changelog/2.6.0.rst | 4 +++- .../DestinationDataTest/Fixtures/Response.json | 9 ++++++++- ext_tables.sql | 8 ++++---- 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Classes/Domain/Model/Import.php b/Classes/Domain/Model/Import.php index 045af84..06d736f 100644 --- a/Classes/Domain/Model/Import.php +++ b/Classes/Domain/Model/Import.php @@ -22,7 +22,7 @@ class Import extends AbstractDomainObject protected $filesFolder; /** - * @var int + * @var int|null */ protected $categoriesPid; @@ -32,7 +32,7 @@ class Import extends AbstractDomainObject protected $categoryParent; /** - * @var int + * @var int|null */ protected $featuresPid; @@ -70,9 +70,17 @@ class Import extends AbstractDomainObject $this->filesFolder = $filesFolder; $this->storagePid = $storagePid; + // Do not allow categories on pid 0 + if ($categoriesPid === 0) { + $categoriesPid = null; + } $this->categoriesPid = $categoriesPid; $this->categoryParent = $categoryParent; + // Do not allow features on pid 0 + if ($featuresPid === 0) { + $featuresPid = null; + } $this->featuresPid = $featuresPid; $this->featuresParent = $featuresParent; @@ -92,7 +100,7 @@ class Import extends AbstractDomainObject return $this->filesFolder; } - public function getCategoriesPid(): int + public function getCategoriesPid(): ?int { return $this->categoriesPid; } @@ -102,7 +110,7 @@ class Import extends AbstractDomainObject return $this->categoryParent; } - public function getFeaturesPid(): int + public function getFeaturesPid(): ?int { return $this->featuresPid; } diff --git a/Classes/Service/DestinationDataImportService/CategoriesAssignment.php b/Classes/Service/DestinationDataImportService/CategoriesAssignment.php index 333afb4..055d480 100644 --- a/Classes/Service/DestinationDataImportService/CategoriesAssignment.php +++ b/Classes/Service/DestinationDataImportService/CategoriesAssignment.php @@ -35,7 +35,7 @@ class CategoriesAssignment ): ObjectStorage { $categories = new ObjectStorage(); - if ($import->getParentCategory() === null) { + if ($import->getParentCategory() === null || $import->getPid() === null) { return $categories; } diff --git a/Classes/Service/DestinationDataImportService/CategoriesAssignment/Import.php b/Classes/Service/DestinationDataImportService/CategoriesAssignment/Import.php index 8daa13b..ae90425 100644 --- a/Classes/Service/DestinationDataImportService/CategoriesAssignment/Import.php +++ b/Classes/Service/DestinationDataImportService/CategoriesAssignment/Import.php @@ -7,12 +7,12 @@ use Wrm\Events\Domain\Model\Category; class Import { /** - * @var null|Category + * @var Category|null */ private $parentCategory; /** - * @var int + * @var int|null */ private $pid; @@ -28,7 +28,7 @@ class Import public function __construct( ?Category $parentCategory, - int $pid, + ?int $pid, array $categoryTitles, bool $hideByDefault = false ) { @@ -43,7 +43,7 @@ class Import return $this->parentCategory; } - public function getPid(): int + public function getPid(): ?int { return $this->pid; } diff --git a/Documentation/Changelog/2.6.0.rst b/Documentation/Changelog/2.6.0.rst index e5bb16f..a5b6e39 100644 --- a/Documentation/Changelog/2.6.0.rst +++ b/Documentation/Changelog/2.6.0.rst @@ -31,7 +31,9 @@ Features Fixes ----- -Nothing +* Do not break old scheduler tasks as no features can be configured. + Ensure we properly handle none configured features within configurations. + Allow null within database and handle Extbase converting this to integer 0. Tasks ----- diff --git a/Tests/Functional/Import/DestinationDataTest/Fixtures/Response.json b/Tests/Functional/Import/DestinationDataTest/Fixtures/Response.json index 9c3534d..8bf8bdb 100644 --- a/Tests/Functional/Import/DestinationDataTest/Fixtures/Response.json +++ b/Tests/Functional/Import/DestinationDataTest/Fixtures/Response.json @@ -128,7 +128,14 @@ "value": "1" } ], - "features": [], + "features": [ + "vorhandenes Feature", + "Barrierefrei", + "Zielgruppe Jugendliche", + "Karten an der Abendkasse", + "Ausreichende Lüftung", + "Beachtung der Hygienehinweise" + ], "addresses": [ { "name": "Städtetourismus in Thüringen e.V.", diff --git a/ext_tables.sql b/ext_tables.sql index c7bd3d3..76b26be 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -105,11 +105,11 @@ CREATE TABLE tx_events_domain_model_import ( storage_pid int(11) unsigned DEFAULT '0' NOT NULL, files_folder varchar(1024) DEFAULT '' NOT NULL, - categories_pid int(11) unsigned DEFAULT '0' NOT NULL, - category_parent int(11) unsigned DEFAULT '0' NOT NULL, + categories_pid int(11) unsigned, + category_parent int(11) unsigned, - features_pid int(11) unsigned DEFAULT '0' NOT NULL, - features_parent int(11) unsigned DEFAULT '0' NOT NULL, + features_pid int(11) unsigned, + features_parent int(11) unsigned, region int(11) unsigned DEFAULT '0' NOT NULL,