Fix broken import without features

This commit is contained in:
Daniel Siepmann 2022-08-03 08:41:54 +02:00
parent 9b783e5e89
commit 5652ea6442
6 changed files with 32 additions and 15 deletions

View file

@ -22,7 +22,7 @@ class Import extends AbstractDomainObject
protected $filesFolder; protected $filesFolder;
/** /**
* @var int * @var int|null
*/ */
protected $categoriesPid; protected $categoriesPid;
@ -32,7 +32,7 @@ class Import extends AbstractDomainObject
protected $categoryParent; protected $categoryParent;
/** /**
* @var int * @var int|null
*/ */
protected $featuresPid; protected $featuresPid;
@ -70,9 +70,17 @@ class Import extends AbstractDomainObject
$this->filesFolder = $filesFolder; $this->filesFolder = $filesFolder;
$this->storagePid = $storagePid; $this->storagePid = $storagePid;
// Do not allow categories on pid 0
if ($categoriesPid === 0) {
$categoriesPid = null;
}
$this->categoriesPid = $categoriesPid; $this->categoriesPid = $categoriesPid;
$this->categoryParent = $categoryParent; $this->categoryParent = $categoryParent;
// Do not allow features on pid 0
if ($featuresPid === 0) {
$featuresPid = null;
}
$this->featuresPid = $featuresPid; $this->featuresPid = $featuresPid;
$this->featuresParent = $featuresParent; $this->featuresParent = $featuresParent;
@ -92,7 +100,7 @@ class Import extends AbstractDomainObject
return $this->filesFolder; return $this->filesFolder;
} }
public function getCategoriesPid(): int public function getCategoriesPid(): ?int
{ {
return $this->categoriesPid; return $this->categoriesPid;
} }
@ -102,7 +110,7 @@ class Import extends AbstractDomainObject
return $this->categoryParent; return $this->categoryParent;
} }
public function getFeaturesPid(): int public function getFeaturesPid(): ?int
{ {
return $this->featuresPid; return $this->featuresPid;
} }

View file

@ -35,7 +35,7 @@ class CategoriesAssignment
): ObjectStorage { ): ObjectStorage {
$categories = new ObjectStorage(); $categories = new ObjectStorage();
if ($import->getParentCategory() === null) { if ($import->getParentCategory() === null || $import->getPid() === null) {
return $categories; return $categories;
} }

View file

@ -7,12 +7,12 @@ use Wrm\Events\Domain\Model\Category;
class Import class Import
{ {
/** /**
* @var null|Category * @var Category|null
*/ */
private $parentCategory; private $parentCategory;
/** /**
* @var int * @var int|null
*/ */
private $pid; private $pid;
@ -28,7 +28,7 @@ class Import
public function __construct( public function __construct(
?Category $parentCategory, ?Category $parentCategory,
int $pid, ?int $pid,
array $categoryTitles, array $categoryTitles,
bool $hideByDefault = false bool $hideByDefault = false
) { ) {
@ -43,7 +43,7 @@ class Import
return $this->parentCategory; return $this->parentCategory;
} }
public function getPid(): int public function getPid(): ?int
{ {
return $this->pid; return $this->pid;
} }

View file

@ -31,7 +31,9 @@ Features
Fixes 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 Tasks
----- -----

View file

@ -128,7 +128,14 @@
"value": "1" "value": "1"
} }
], ],
"features": [], "features": [
"vorhandenes Feature",
"Barrierefrei",
"Zielgruppe Jugendliche",
"Karten an der Abendkasse",
"Ausreichende Lüftung",
"Beachtung der Hygienehinweise"
],
"addresses": [ "addresses": [
{ {
"name": "Städtetourismus in Thüringen e.V.", "name": "Städtetourismus in Thüringen e.V.",

View file

@ -105,11 +105,11 @@ CREATE TABLE tx_events_domain_model_import (
storage_pid int(11) unsigned DEFAULT '0' NOT NULL, storage_pid int(11) unsigned DEFAULT '0' NOT NULL,
files_folder varchar(1024) DEFAULT '' NOT NULL, files_folder varchar(1024) DEFAULT '' NOT NULL,
categories_pid int(11) unsigned DEFAULT '0' NOT NULL, categories_pid int(11) unsigned,
category_parent int(11) unsigned DEFAULT '0' NOT NULL, category_parent int(11) unsigned,
features_pid int(11) unsigned DEFAULT '0' NOT NULL, features_pid int(11) unsigned,
features_parent int(11) unsigned DEFAULT '0' NOT NULL, features_parent int(11) unsigned,
region int(11) unsigned DEFAULT '0' NOT NULL, region int(11) unsigned DEFAULT '0' NOT NULL,