From a3b9aa7fa8be00f64b6989b36ca4502702adfa66 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Fri, 15 May 2026 14:35:23 +0200 Subject: [PATCH 1/2] Fix collection class with missing filter definition --- composer.json | 205 +++++++++--------- .../contao/dca/tl_metamodel_filtersetting.php | 2 +- src/Filter/Setting/Collection.php | 8 +- tests/Filter/Setting/CollectionTest.php | 55 +++++ 4 files changed, 165 insertions(+), 105 deletions(-) create mode 100644 tests/Filter/Setting/CollectionTest.php diff --git a/composer.json b/composer.json index 63c3ffaf5..bad15d816 100644 --- a/composer.json +++ b/composer.json @@ -1,108 +1,109 @@ { - "name": "metamodels/core", - "description": "MetaModels core", - "license": "LGPL-3.0-or-later", - "type": "contao-bundle", - "keywords": [ - "contao", - "metamodels", - "core" - ], - "authors": [ - { - "name": "Christian Schiffler", - "email": "c.schiffler@cyberspectrum.de", - "homepage": "https://www.cyberspectrum.de", - "role": "Developer" + "name": "metamodels/core", + "description": "MetaModels core", + "license": "LGPL-3.0-or-later", + "type": "contao-bundle", + "keywords": [ + "contao", + "metamodels", + "core" + ], + "authors": [ + { + "name": "Christian Schiffler", + "email": "c.schiffler@cyberspectrum.de", + "homepage": "https://www.cyberspectrum.de", + "role": "Developer" + }, + { + "name": "Stefan Heimes", + "email": "stefan_heimes@hotmail.com", + "role": "Developer" + } + ], + "homepage": "https://now.metamodel.me/", + "support": { + "email": "mail@metamodel.me", + "issues": "https://github.com/MetaModels/core/issues", + "wiki": "https://de.contaowiki.org/MetaModels", + "source": "https://github.com/MetaModels/core" }, - { - "name": "Stefan Heimes", - "email": "stefan_heimes@hotmail.com", - "role": "Developer" - } - ], - "homepage": "https://now.metamodel.me/", - "support": { - "email": "mail@metamodel.me", - "issues": "https://github.com/MetaModels/core/issues", - "wiki": "https://de.contaowiki.org/MetaModels", - "source": "https://github.com/MetaModels/core" - }, - "require": { - "php": "^8.2", - "ext-dom": "*", - "contao-community-alliance/dc-general": "^2.4.12", - "contao-community-alliance/events-contao-bindings": "^5.0", - "contao-community-alliance/meta-palettes": "^2.0.10", - "contao-community-alliance/translator": "^2.5", - "contao-community-alliance/url-builder": "^2.0", - "contao/core-bundle": "^5.3 <5.7", - "discordier/justtextwidgets": "^2.0", - "doctrine/cache": "^2.1", - "doctrine/dbal": "^3.6", - "doctrine/doctrine-bundle": "^2.8", - "doctrine/orm": "^2.17", - "knplabs/knp-menu": "^3.1", - "menatwork/contao-multicolumnwizard-bundle": "^3.6.10", - "psr/container": "^2.0", - "psr/log": "^2.0 || ^3.0", - "symfony/asset": "^6.4", - "symfony/cache": "^6.4", - "symfony/cache-contracts": "^3.0", - "symfony/config": "^6.4", - "symfony/console": "^6.4", - "symfony/dependency-injection": "^6.4", - "symfony/deprecation-contracts": "^3.3.0", - "symfony/event-dispatcher": "^6.4", - "symfony/event-dispatcher-contracts": "^3.0", - "symfony/filesystem": "^6.4", - "symfony/finder": "^6.4", - "symfony/framework-bundle": "^6.4", - "symfony/http-foundation": "^6.4", - "symfony/http-kernel": "^6.4", - "symfony/routing": "^6.4", - "symfony/security-core": "^6.4", - "symfony/service-contracts": "^3.0", - "symfony/translation": "^6.4", - "symfony/translation-contracts": "^3.0", - "terminal42/service-annotation-bundle": "^1.1", - "twig/intl-extra": "^3.21", - "twig/twig": "^3.10.0" - }, - "require-dev": { - "contao/manager-bundle": "^5.3.0 <5.7.0", - "contao/manager-plugin": "^2.8", - "doctrine/doctrine-bundle": "^2.8.3", - "inspiredminds/contao-file-usage": "^3.0.1", - "phpcq/runner-bootstrap": "^1.0@dev" - }, - "autoload": { - "psr-4": { - "MetaModels\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "MetaModels\\Test\\": "tests/" - } - }, - "config": { - "allow-plugins": { - "contao-components/installer": false, - "contao/manager-plugin": false, - "php-http/discovery": false + "require": { + "php": "^8.2", + "ext-dom": "*", + "contao-community-alliance/dc-general": "^2.4.13", + "contao-community-alliance/events-contao-bindings": "^5.0", + "contao-community-alliance/meta-palettes": "^2.0.10", + "contao-community-alliance/translator": "^2.5", + "contao-community-alliance/url-builder": "^2.0", + "contao/core-bundle": "^5.3 <5.7", + "discordier/justtextwidgets": "^2.0", + "doctrine/cache": "^2.1", + "doctrine/dbal": "^3.6", + "doctrine/doctrine-bundle": "^2.8", + "doctrine/orm": "^2.17", + "knplabs/knp-menu": "^3.1", + "menatwork/contao-multicolumnwizard-bundle": "^3.6.10", + "psr/container": "^2.0", + "psr/log": "^2.0 || ^3.0", + "symfony/asset": "^6.4", + "symfony/cache": "^6.4", + "symfony/cache-contracts": "^3.0", + "symfony/config": "^6.4", + "symfony/console": "^6.4", + "symfony/dependency-injection": "^6.4", + "symfony/deprecation-contracts": "^3.3.0", + "symfony/event-dispatcher": "^6.4", + "symfony/event-dispatcher-contracts": "^3.0", + "symfony/filesystem": "^6.4", + "symfony/finder": "^6.4", + "symfony/framework-bundle": "^6.4", + "symfony/http-foundation": "^6.4", + "symfony/http-kernel": "^6.4", + "symfony/routing": "^6.4", + "symfony/security-core": "^6.4", + "symfony/service-contracts": "^3.0", + "symfony/translation": "^6.4", + "symfony/translation-contracts": "^3.0", + "terminal42/service-annotation-bundle": "^1.1", + "twig/intl-extra": "^3.21", + "twig/twig": "^3.10.0" }, - "sort-packages": true - }, - "extra": { - "branch-alias": { - "dev-master": "2.4.x-dev" + "require-dev": { + "contao/manager-bundle": "^5.3.0 <5.7.0", + "contao/manager-plugin": "^2.8", + "doctrine/doctrine-bundle": "^2.8.3", + "inspiredminds/contao-file-usage": "^3.0.1", + "phpcq/runner-bootstrap": "^1.0@dev" }, - "contao": { - "runonce": [ - "runonce/runonce.php" - ] + "autoload": { + "psr-4": { + "MetaModels\\": "src/" + } }, - "contao-manager-plugin": "MetaModels\\CoreBundle\\ContaoManager\\Plugin" - } + "autoload-dev": { + "psr-4": { + "MetaModels\\Test\\": "tests/" + } + }, + "config": { + "allow-plugins": { + "contao-components/installer": false, + "contao/manager-plugin": false, + "php-http/discovery": false + }, + "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-master": "2.4.x-dev", + "dev-hotfix/2.4.18": "2.4.x-dev" + }, + "contao": { + "runonce": [ + "runonce/runonce.php" + ] + }, + "contao-manager-plugin": "MetaModels\\CoreBundle\\ContaoManager\\Plugin" + } } diff --git a/src/CoreBundle/Resources/contao/dca/tl_metamodel_filtersetting.php b/src/CoreBundle/Resources/contao/dca/tl_metamodel_filtersetting.php index bd53a1b26..9f19b2001 100644 --- a/src/CoreBundle/Resources/contao/dca/tl_metamodel_filtersetting.php +++ b/src/CoreBundle/Resources/contao/dca/tl_metamodel_filtersetting.php @@ -493,7 +493,7 @@ 'mandatory' => true, 'tl_class' => 'clr', ], - 'sql' => "text NOT NULL default ''" + 'sql' => 'text NULL' ], 'label' => [ 'label' => 'label.label', diff --git a/src/Filter/Setting/Collection.php b/src/Filter/Setting/Collection.php index 19272aa9f..52728e4ae 100644 --- a/src/Filter/Setting/Collection.php +++ b/src/Filter/Setting/Collection.php @@ -3,7 +3,7 @@ /** * This file is part of MetaModels/core. * - * (c) 2012-2024 The MetaModels team. + * (c) 2012-2026 The MetaModels team. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -17,7 +17,7 @@ * @author Sven Baumann * @author Richard Henkenjohann * @author Ingolf Steinhardt - * @copyright 2012-2024 The MetaModels team. + * @copyright 2012-2026 The MetaModels team. * @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ @@ -208,6 +208,10 @@ public function getParameterFilterWidgets( $arrJumpTo, FrontendFilterOptions $objFrontendFilterOptions ) { + if (null === $this->metaModel) { + return []; + } + $parameters = []; $metaModel = $this->getMetaModel(); $previousLanguage = ($metaModel instanceof ITranslatedMetaModel) diff --git a/tests/Filter/Setting/CollectionTest.php b/tests/Filter/Setting/CollectionTest.php new file mode 100644 index 000000000..a76afe9a4 --- /dev/null +++ b/tests/Filter/Setting/CollectionTest.php @@ -0,0 +1,55 @@ + + * @copyright 2012-2026 The MetaModels team. + * @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later + * @filesource + */ + +namespace MetaModels\Test\Filter\Setting; + +use MetaModels\Filter\Setting\Collection; +use MetaModels\FrontendIntegration\FrontendFilterOptions; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\TestCase; + +/** + * @covers \MetaModels\Filter\Setting\Collection + */ +#[CoversClass(Collection::class)] +class CollectionTest extends TestCase +{ + /** + * When no MetaModel is set (e.g. FE list module with no filter configured), + * getParameterFilterWidgets() must return an empty array instead of throwing a RuntimeException. + */ + public function testGetParameterFilterWidgetsReturnsEmptyArrayWhenNoMetaModelSet(): void + { + $collection = new Collection([]); + + $result = $collection->getParameterFilterWidgets([], [], new FrontendFilterOptions()); + + self::assertSame([], $result); + } + + /** + * getParameters() returns an empty array when the collection has no settings. + */ + public function testGetParametersReturnsEmptyArrayWhenNoSettings(): void + { + $collection = new Collection([]); + + self::assertSame([], $collection->getParameters()); + } +} From 070d497efdb1d400d2254988d598ce8e046e7a02 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Fri, 15 May 2026 14:42:14 +0200 Subject: [PATCH 2/2] Fix collection class with missing filter definition --- composer.json | 206 +++++++++++++++++++++++++------------------------- 1 file changed, 103 insertions(+), 103 deletions(-) diff --git a/composer.json b/composer.json index bad15d816..7f471242b 100644 --- a/composer.json +++ b/composer.json @@ -1,109 +1,109 @@ { - "name": "metamodels/core", - "description": "MetaModels core", - "license": "LGPL-3.0-or-later", - "type": "contao-bundle", - "keywords": [ - "contao", - "metamodels", - "core" - ], - "authors": [ - { - "name": "Christian Schiffler", - "email": "c.schiffler@cyberspectrum.de", - "homepage": "https://www.cyberspectrum.de", - "role": "Developer" - }, - { - "name": "Stefan Heimes", - "email": "stefan_heimes@hotmail.com", - "role": "Developer" - } - ], - "homepage": "https://now.metamodel.me/", - "support": { - "email": "mail@metamodel.me", - "issues": "https://github.com/MetaModels/core/issues", - "wiki": "https://de.contaowiki.org/MetaModels", - "source": "https://github.com/MetaModels/core" + "name": "metamodels/core", + "description": "MetaModels core", + "license": "LGPL-3.0-or-later", + "type": "contao-bundle", + "keywords": [ + "contao", + "metamodels", + "core" + ], + "authors": [ + { + "name": "Christian Schiffler", + "email": "c.schiffler@cyberspectrum.de", + "homepage": "https://www.cyberspectrum.de", + "role": "Developer" }, - "require": { - "php": "^8.2", - "ext-dom": "*", - "contao-community-alliance/dc-general": "^2.4.13", - "contao-community-alliance/events-contao-bindings": "^5.0", - "contao-community-alliance/meta-palettes": "^2.0.10", - "contao-community-alliance/translator": "^2.5", - "contao-community-alliance/url-builder": "^2.0", - "contao/core-bundle": "^5.3 <5.7", - "discordier/justtextwidgets": "^2.0", - "doctrine/cache": "^2.1", - "doctrine/dbal": "^3.6", - "doctrine/doctrine-bundle": "^2.8", - "doctrine/orm": "^2.17", - "knplabs/knp-menu": "^3.1", - "menatwork/contao-multicolumnwizard-bundle": "^3.6.10", - "psr/container": "^2.0", - "psr/log": "^2.0 || ^3.0", - "symfony/asset": "^6.4", - "symfony/cache": "^6.4", - "symfony/cache-contracts": "^3.0", - "symfony/config": "^6.4", - "symfony/console": "^6.4", - "symfony/dependency-injection": "^6.4", - "symfony/deprecation-contracts": "^3.3.0", - "symfony/event-dispatcher": "^6.4", - "symfony/event-dispatcher-contracts": "^3.0", - "symfony/filesystem": "^6.4", - "symfony/finder": "^6.4", - "symfony/framework-bundle": "^6.4", - "symfony/http-foundation": "^6.4", - "symfony/http-kernel": "^6.4", - "symfony/routing": "^6.4", - "symfony/security-core": "^6.4", - "symfony/service-contracts": "^3.0", - "symfony/translation": "^6.4", - "symfony/translation-contracts": "^3.0", - "terminal42/service-annotation-bundle": "^1.1", - "twig/intl-extra": "^3.21", - "twig/twig": "^3.10.0" - }, - "require-dev": { - "contao/manager-bundle": "^5.3.0 <5.7.0", - "contao/manager-plugin": "^2.8", - "doctrine/doctrine-bundle": "^2.8.3", - "inspiredminds/contao-file-usage": "^3.0.1", - "phpcq/runner-bootstrap": "^1.0@dev" - }, - "autoload": { - "psr-4": { - "MetaModels\\": "src/" - } + { + "name": "Stefan Heimes", + "email": "stefan_heimes@hotmail.com", + "role": "Developer" + } + ], + "homepage": "https://now.metamodel.me/", + "support": { + "email": "mail@metamodel.me", + "issues": "https://github.com/MetaModels/core/issues", + "wiki": "https://de.contaowiki.org/MetaModels", + "source": "https://github.com/MetaModels/core" + }, + "require": { + "php": "^8.2", + "ext-dom": "*", + "contao-community-alliance/dc-general": "^2.4.13", + "contao-community-alliance/events-contao-bindings": "^5.0", + "contao-community-alliance/meta-palettes": "^2.0.10", + "contao-community-alliance/translator": "^2.5", + "contao-community-alliance/url-builder": "^2.0", + "contao/core-bundle": "^5.3 <5.7", + "discordier/justtextwidgets": "^2.0", + "doctrine/cache": "^2.1", + "doctrine/dbal": "^3.6", + "doctrine/doctrine-bundle": "^2.8", + "doctrine/orm": "^2.17", + "knplabs/knp-menu": "^3.1", + "menatwork/contao-multicolumnwizard-bundle": "^3.6.10", + "psr/container": "^2.0", + "psr/log": "^2.0 || ^3.0", + "symfony/asset": "^6.4", + "symfony/cache": "^6.4", + "symfony/cache-contracts": "^3.0", + "symfony/config": "^6.4", + "symfony/console": "^6.4", + "symfony/dependency-injection": "^6.4", + "symfony/deprecation-contracts": "^3.3.0", + "symfony/event-dispatcher": "^6.4", + "symfony/event-dispatcher-contracts": "^3.0", + "symfony/filesystem": "^6.4", + "symfony/finder": "^6.4", + "symfony/framework-bundle": "^6.4", + "symfony/http-foundation": "^6.4", + "symfony/http-kernel": "^6.4", + "symfony/routing": "^6.4", + "symfony/security-core": "^6.4", + "symfony/service-contracts": "^3.0", + "symfony/translation": "^6.4", + "symfony/translation-contracts": "^3.0", + "terminal42/service-annotation-bundle": "^1.1", + "twig/intl-extra": "^3.21", + "twig/twig": "^3.10.0" + }, + "require-dev": { + "contao/manager-bundle": "^5.3.0 <5.7.0", + "contao/manager-plugin": "^2.8", + "doctrine/doctrine-bundle": "^2.8.3", + "inspiredminds/contao-file-usage": "^3.0.1", + "phpcq/runner-bootstrap": "^1.0@dev" + }, + "autoload": { + "psr-4": { + "MetaModels\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "MetaModels\\Test\\": "tests/" + } + }, + "config": { + "allow-plugins": { + "contao-components/installer": false, + "contao/manager-plugin": false, + "php-http/discovery": false }, - "autoload-dev": { - "psr-4": { - "MetaModels\\Test\\": "tests/" - } + "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-hotfix/2.4.18": "2.4.x-dev", + "dev-master": "2.4.x-dev" }, - "config": { - "allow-plugins": { - "contao-components/installer": false, - "contao/manager-plugin": false, - "php-http/discovery": false - }, - "sort-packages": true + "contao": { + "runonce": [ + "runonce/runonce.php" + ] }, - "extra": { - "branch-alias": { - "dev-master": "2.4.x-dev", - "dev-hotfix/2.4.18": "2.4.x-dev" - }, - "contao": { - "runonce": [ - "runonce/runonce.php" - ] - }, - "contao-manager-plugin": "MetaModels\\CoreBundle\\ContaoManager\\Plugin" - } + "contao-manager-plugin": "MetaModels\\CoreBundle\\ContaoManager\\Plugin" + } }