From 4377a06aba673ac9377b841971d1ef5bcfe9f042 Mon Sep 17 00:00:00 2001 From: Stefan Heimes Date: Fri, 23 Jan 2026 10:44:22 +0100 Subject: [PATCH 1/9] Some fixes - Clean up duplicate entries in yaml configs - Refactor deep-copy: use prepared statements and bind values for inserts --- src/EventListener/BackendEventListener.php | 11 +++++++++-- src/Resources/config/listeners.yml | 2 ++ src/Resources/config/services.yml | 5 ----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/EventListener/BackendEventListener.php b/src/EventListener/BackendEventListener.php index d4302e4..dee8250 100644 --- a/src/EventListener/BackendEventListener.php +++ b/src/EventListener/BackendEventListener.php @@ -146,11 +146,18 @@ private function duplicateContentEntries($strTable, $intSourceId, $intDestinatio $arrContent['pid'] = $intDestinationId; unset($arrContent['id']); + $parameters = []; + foreach (array_keys($arrContent) as $key) { + $parameters[$key] = '?'; + } + $this->connection ->createQueryBuilder() ->insert('tl_content') - ->setParameters($arrContent) - ->executeQuery(); + ->values($parameters) + ->setParameters(array_values($arrContent)) + ->executeStatement() + ; } } diff --git a/src/Resources/config/listeners.yml b/src/Resources/config/listeners.yml index 4175454..dbcc3f4 100644 --- a/src/Resources/config/listeners.yml +++ b/src/Resources/config/listeners.yml @@ -1,6 +1,8 @@ services: MetaModels\AttributeTranslatedContentArticleBundle\EventListener\BackendEventListener: public: false + arguments: + - '@database_connection' tags: - name: kernel.event_listener, event: 'dc-general.view.contao2backend.manipulate-widget' diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index 9f523ee..fc2881d 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -6,10 +6,5 @@ services: tags: - { name: metamodels.attribute_factory } - MetaModels\AttributeTranslatedContentArticleBundle\EventListener\BackendEventListener: - public: true - arguments: - - '@database_connection' - MetaModels\AttributeTranslatedContentArticleBundle\Controller\Backend\MetaModelController: tags: ['controller.service_arguments'] From c25a578827f5bb0693347ebde0a99769cd9fe56b Mon Sep 17 00:00:00 2001 From: Stefan Heimes Date: Fri, 23 Jan 2026 10:58:04 +0100 Subject: [PATCH 2/9] Update phpcq trusted-keys --- .phpcq.yaml.dist | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist index 41607a4..22a8a4b 100644 --- a/.phpcq.yaml.dist +++ b/.phpcq.yaml.dist @@ -36,22 +36,28 @@ phpcq: trusted-keys: # composer-require-checker - 033E5F8D801A2F8D + - B2BDAAAC6F1FDE528CD9EEC9033E5F8D801A2F8D # sb@sebastian-bergmann.de - 4AA394086372C20A + - D8406D0D82947747293778314AA394086372C20A # psalm - 8A03EA3B385DBAA1 - 12CE0F1D262429A5 + - 2DE50EB60C013FFFA831040D12CE0F1D262429A5 # magl@magll.net - D2CCAC42F6295E7D # PHP_CodeSniffer - 31C7E470E2138192 - 5E6DDE998AB73B8E - A978220305CD5C32 + - 689DAD778FF08760E046228BA978220305CD5C32 # Composer normalize - C00543248C87FB13 + - 0FDE18AE1D09E19F60F6B1CBC00543248C87FB13 # phpmd - A4E55EA12C7C085C - 9093F8B32E4815AA + - E7A745102ECC980F7338B3079093F8B32E4815AA tasks: fix: From 5c519dc3601f28180365cfa01cba4babe308d7ac Mon Sep 17 00:00:00 2001 From: Stefan Heimes Date: Fri, 23 Jan 2026 11:00:33 +0100 Subject: [PATCH 3/9] Update phpcq trusted-keys --- .phpcq.yaml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist index 22a8a4b..0835297 100644 --- a/.phpcq.yaml.dist +++ b/.phpcq.yaml.dist @@ -51,6 +51,7 @@ phpcq: - 5E6DDE998AB73B8E - A978220305CD5C32 - 689DAD778FF08760E046228BA978220305CD5C32 + - 97B02DD8E5071466 # Composer normalize - C00543248C87FB13 - 0FDE18AE1D09E19F60F6B1CBC00543248C87FB13 From 0f9b4a2c2ddcda1bdd0c957f4daa47274304b9dc Mon Sep 17 00:00:00 2001 From: Stefan Heimes Date: Fri, 23 Jan 2026 11:11:42 +0100 Subject: [PATCH 4/9] Update phpcq config Set psalm version to 5.26.1 --- .phpcq.yaml.dist | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist index 0835297..7d94f6a 100644 --- a/.phpcq.yaml.dist +++ b/.phpcq.yaml.dist @@ -15,6 +15,9 @@ phpcq: psalm: version: ^1.0 signed: false + requirements: + psalm: + version: ^5.26.1 composer-require-checker: version: ^1.0 signed: false From 8276f29198b1ef52595332528b5cdb84dacbc1e8 Mon Sep 17 00:00:00 2001 From: Stefan Heimes Date: Fri, 23 Jan 2026 12:08:01 +0100 Subject: [PATCH 5/9] Correct tests --- .composer-require-checker.json | 3 ++- tests/ContaoManager/PluginTest.php | 5 ++++- tests/Widgets/ContentArticleWidgetTest.php | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.composer-require-checker.json b/.composer-require-checker.json index 85cda09..c80cca7 100644 --- a/.composer-require-checker.json +++ b/.composer-require-checker.json @@ -13,6 +13,7 @@ "InspiredMinds\\ContaoFileUsage\\Result\\FileTreeSingleResult", "InspiredMinds\\ContaoFileUsage\\Result\\ResultInterface", "InspiredMinds\\ContaoFileUsage\\Result\\ResultsCollection", - "tl_content" + "tl_content", + "MetaModels\\AttributeContentArticleBundle\\MetaModelsAttributeContentArticleBundle" ] } diff --git a/tests/ContaoManager/PluginTest.php b/tests/ContaoManager/PluginTest.php index ed250dc..25c4099 100644 --- a/tests/ContaoManager/PluginTest.php +++ b/tests/ContaoManager/PluginTest.php @@ -47,7 +47,10 @@ public function testGetBundles(): void $config ->expects(self::once()) ->method('getLoadAfter') - ->willReturn([MetaModelsCoreBundle::class]); + ->willReturn([ + 'MetaModels\AttributeContentArticleBundle\MetaModelsAttributeContentArticleBundle', + MetaModelsCoreBundle::class + ]); $config ->expects(self::once()) ->method('getReplace') diff --git a/tests/Widgets/ContentArticleWidgetTest.php b/tests/Widgets/ContentArticleWidgetTest.php index cde3449..7790708 100644 --- a/tests/Widgets/ContentArticleWidgetTest.php +++ b/tests/Widgets/ContentArticleWidgetTest.php @@ -48,7 +48,7 @@ public function testNewInstance(): void $input = $this->getMockBuilder(Adapter::class) ->disableOriginalConstructor() - ->setMethods(['get']) + ->addMethods(['get']) ->getMock(); $input @@ -61,7 +61,7 @@ public function testNewInstance(): void $widget = $this->getMockBuilder(ContentArticleWidget::class) ->setConstructorArgs([null, $dcCompat, $connection, $input, $translator]) - ->setMethods(['import']) + ->onlyMethods(['import']) ->getMock(); $widget From a71e8b91bf30bbb20e715617cecdfd8f7ae8b7a6 Mon Sep 17 00:00:00 2001 From: Stefan Heimes Date: Fri, 23 Jan 2026 12:25:15 +0100 Subject: [PATCH 6/9] Update for phpcq and phpunit --- .phpcq.yaml.dist | 4 ++++ tests/Widgets/ContentArticleWidgetTest.php | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist index 7d94f6a..3345178 100644 --- a/.phpcq.yaml.dist +++ b/.phpcq.yaml.dist @@ -12,6 +12,9 @@ phpcq: phpunit: version: ^1.0 signed: false + requirements: + phpunit: + version: ^11.5.48 psalm: version: ^1.0 signed: false @@ -55,6 +58,7 @@ phpcq: - A978220305CD5C32 - 689DAD778FF08760E046228BA978220305CD5C32 - 97B02DD8E5071466 + - D91D86963AF3A29B6520462297B02DD8E5071466 # Composer normalize - C00543248C87FB13 - 0FDE18AE1D09E19F60F6B1CBC00543248C87FB13 diff --git a/tests/Widgets/ContentArticleWidgetTest.php b/tests/Widgets/ContentArticleWidgetTest.php index 7790708..5cbcf6f 100644 --- a/tests/Widgets/ContentArticleWidgetTest.php +++ b/tests/Widgets/ContentArticleWidgetTest.php @@ -67,7 +67,10 @@ public function testNewInstance(): void $widget ->expects(self::any()) ->method('import') - ->withConsecutive([Config::class, 'Config']); + ->willReturnCallback(function ($parameters) { + $this->assertInstanceof(Config::class, $parameters[0]); + $this->assertSame('Config', $parameters[1]); + }); self::assertEmpty($widget->getAttributes()); } From d3604c8f483bc43b346843391d1ec1260014e1c2 Mon Sep 17 00:00:00 2001 From: Stefan Heimes Date: Fri, 23 Jan 2026 12:27:02 +0100 Subject: [PATCH 7/9] Update again for phpunit --- tests/ContaoManager/PluginTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ContaoManager/PluginTest.php b/tests/ContaoManager/PluginTest.php index 25c4099..2ffd96b 100644 --- a/tests/ContaoManager/PluginTest.php +++ b/tests/ContaoManager/PluginTest.php @@ -48,7 +48,6 @@ public function testGetBundles(): void ->expects(self::once()) ->method('getLoadAfter') ->willReturn([ - 'MetaModels\AttributeContentArticleBundle\MetaModelsAttributeContentArticleBundle', MetaModelsCoreBundle::class ]); $config From a29db51e3002fa51ab60982f47cc2d08169c64bd Mon Sep 17 00:00:00 2001 From: Stefan Heimes Date: Fri, 23 Jan 2026 12:28:58 +0100 Subject: [PATCH 8/9] Update php versions --- .github/workflows/diagnostics.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/diagnostics.yml b/.github/workflows/diagnostics.yml index c37db76..5d46265 100644 --- a/.github/workflows/diagnostics.yml +++ b/.github/workflows/diagnostics.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.1', '8.2', '8.3' ] + php: [ '8.2', '8.3', '8.4', '8.5' ] contao: [ '~4.13.0' ] phpcq_install: [ 'update' ] output: [ '-o github-action -o default' ] From 6734570eb558fa95330d4444cbdb621ed5342916 Mon Sep 17 00:00:00 2001 From: Stefan Heimes Date: Fri, 23 Jan 2026 12:33:11 +0100 Subject: [PATCH 9/9] Change the supporterd php versions again for the test --- .github/workflows/diagnostics.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/diagnostics.yml b/.github/workflows/diagnostics.yml index 5d46265..9626542 100644 --- a/.github/workflows/diagnostics.yml +++ b/.github/workflows/diagnostics.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.2', '8.3', '8.4', '8.5' ] + php: [ '8.2', '8.3' ] contao: [ '~4.13.0' ] phpcq_install: [ 'update' ] output: [ '-o github-action -o default' ]