From 0c637c2f92d5225a73ed3ef495917652eb2ed983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Mummert?= Date: Sun, 11 Jan 2026 18:19:40 +0100 Subject: [PATCH] Fix file indexing in Contao 5.6 (inject DBAL connection, add debug logs) --- src/EventListener/IndexPageListener.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/EventListener/IndexPageListener.php b/src/EventListener/IndexPageListener.php index 05954fe..6a71ed4 100644 --- a/src/EventListener/IndexPageListener.php +++ b/src/EventListener/IndexPageListener.php @@ -4,18 +4,21 @@ namespace MummertMedia\ContaoMeilisearchBundle\EventListener; use Contao\Config; use Contao\System; +use Doctrine\DBAL\Connection; class IndexPageListener { - public function __construct() - { + public function __construct( + private readonly Connection $connection, + ) { } private function debug(string $message, array $context = []): void { - // Debug bewusst immer aktiv (bis du es wieder entfernst) - // Kontext kurz halten, damit Logs nicht explodieren - $ctx = $context ? ' | ' . json_encode($context, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : ''; + $ctx = $context + ? ' | ' . json_encode($context, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) + : ''; + error_log('[ContaoMeilisearch][IndexPageListener] ' . $message . $ctx); } @@ -178,7 +181,15 @@ class IndexPageListener ]); if ($fileLinks) { - $db = System::getContainer()->get('database_connection'); + + $this->debug('About to use Doctrine DBAL connection'); + + $db = $this->connection; + + $this->debug('Doctrine DBAL connection ready', [ + 'driver' => get_class($db->getDriver()), + ]); + $time = time(); foreach ($fileLinks as $file) {