Fix file indexing in Contao 5.6 (inject DBAL connection, add debug logs)

This commit is contained in:
Jürgen Mummert
2026-01-11 18:19:40 +01:00
parent 86b81affdc
commit 0c637c2f92
+17 -6
View File
@@ -4,18 +4,21 @@ namespace MummertMedia\ContaoMeilisearchBundle\EventListener;
use Contao\Config; use Contao\Config;
use Contao\System; use Contao\System;
use Doctrine\DBAL\Connection;
class IndexPageListener class IndexPageListener
{ {
public function __construct() public function __construct(
{ private readonly Connection $connection,
) {
} }
private function debug(string $message, array $context = []): void private function debug(string $message, array $context = []): void
{ {
// Debug bewusst immer aktiv (bis du es wieder entfernst) $ctx = $context
// Kontext kurz halten, damit Logs nicht explodieren ? ' | ' . 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); error_log('[ContaoMeilisearch][IndexPageListener] ' . $message . $ctx);
} }
@@ -178,7 +181,15 @@ class IndexPageListener
]); ]);
if ($fileLinks) { 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(); $time = time();
foreach ($fileLinks as $file) { foreach ($fileLinks as $file) {