diff --git a/composer.json b/composer.json index 63c3ffaf5..03cdf2910 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "require": { "php": "^8.2", "ext-dom": "*", - "contao-community-alliance/dc-general": "^2.4.12", + "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", 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()); + } +}