diff --git a/.tools/psalm/baseline.xml b/.tools/psalm/baseline.xml index 093807b82c..fb867fb2a4 100644 --- a/.tools/psalm/baseline.xml +++ b/.tools/psalm/baseline.xml @@ -3791,6 +3791,12 @@ + + + + + value]]> + diff --git a/src/MetaInfo/Form/Field/RestrictionField.php b/src/MetaInfo/Form/Field/RestrictionField.php index a5669fda88..d53372ad0d 100644 --- a/src/MetaInfo/Form/Field/RestrictionField.php +++ b/src/MetaInfo/Form/Field/RestrictionField.php @@ -8,6 +8,8 @@ use Redaxo\Core\MetaInfo\Form\MetaInfoForm; use Redaxo\Core\Translation\I18n; +use function is_array; + /** * @internal */ @@ -26,9 +28,19 @@ public function __construct($tag = '', ?MetaInfoForm $form = null, array $attrib { parent::__construct('', $form, $attributes); + $this->setSeparator(','); $this->setNotice(I18n::msg('ctrl')); } + /** @return void */ + public function setValue($value) + { + if (is_array($value)) { + $value = implode(',', $value); + } + $this->value = $value; + } + public function setAllCheckboxLabel(string $label): void { $this->allCheckboxLabel = $label; diff --git a/src/MetaInfo/Handler/ArticleHandler.php b/src/MetaInfo/Handler/ArticleHandler.php index 87cc0e2c76..dd2d4bc7b6 100644 --- a/src/MetaInfo/Handler/ArticleHandler.php +++ b/src/MetaInfo/Handler/ArticleHandler.php @@ -59,11 +59,11 @@ protected function buildFilterCondition(array $params) // Alle Metafelder des Pfades sind erlaubt foreach ($OOArt->getPathAsArray() as $pathElement) { if ('' != $pathElement) { - $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"'; + $s .= ' OR FIND_IN_SET(' . $pathElement . ', `p`.`restrictions`)'; } } - $t = ' OR `p`.`templates` LIKE "%|' . $OOArt->getValue('template_id') . '|%"'; + $t = ' OR FIND_IN_SET(' . $OOArt->getValue('template_id') . ', `p`.`templates`)'; $restrictionsCondition = 'AND (`p`.`restrictions` = "" OR `p`.`restrictions` IS NULL ' . $s . ') AND (`p`.`templates` = "" OR `p`.`templates` IS NULL ' . $t . ')'; } diff --git a/src/MetaInfo/Handler/CategoryHandler.php b/src/MetaInfo/Handler/CategoryHandler.php index 5f37e61cc7..874ee45de2 100644 --- a/src/MetaInfo/Handler/CategoryHandler.php +++ b/src/MetaInfo/Handler/CategoryHandler.php @@ -69,12 +69,12 @@ protected function buildFilterCondition(array $params) // Alle Metafelder des Pfades sind erlaubt foreach ($OOCat->getPathAsArray() as $pathElement) { if ('' != $pathElement) { - $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"'; + $s .= ' OR FIND_IN_SET(' . $pathElement . ', `p`.`restrictions`)'; } } // Auch die Kategorie selbst kann Metafelder haben - $s .= ' OR `p`.`restrictions` LIKE "%|' . $params['id'] . '|%"'; + $s .= ' OR FIND_IN_SET(' . $params['id'] . ', `p`.`restrictions`)'; } return 'AND (`p`.`restrictions` = "" OR `p`.`restrictions` IS NULL ' . $s . ')'; diff --git a/src/MetaInfo/Handler/MediaHandler.php b/src/MetaInfo/Handler/MediaHandler.php index 98cb8ab00e..0468358d5e 100644 --- a/src/MetaInfo/Handler/MediaHandler.php +++ b/src/MetaInfo/Handler/MediaHandler.php @@ -146,13 +146,13 @@ protected function buildFilterCondition(array $params) // Alle Metafelder des Pfades sind erlaubt foreach ($OOCat->getPathAsArray() as $pathElement) { if ('' != $pathElement) { - $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"'; + $s .= ' OR FIND_IN_SET(' . $pathElement . ', `p`.`restrictions`)'; } } } // Auch die Kategorie selbst kann Metafelder haben - $s .= ' OR `p`.`restrictions` LIKE "%|' . $catId . '|%"'; + $s .= ' OR FIND_IN_SET(' . $catId . ', `p`.`restrictions`)'; $restrictionsCondition = 'AND (`p`.`restrictions` = "" OR `p`.`restrictions` IS NULL ' . $s . ')'; }