Debug File Indexing

This commit is contained in:
Jürgen Mummert
2026-01-11 19:31:31 +01:00
parent 3427f6b60b
commit 17188537bc
+16 -8
View File
@@ -181,11 +181,15 @@ class IndexPageListener
$db = System::getContainer()->get('database_connection'); $db = System::getContainer()->get('database_connection');
$time = time(); $time = time();
// ✅ Contao 5.x robust: Projektverzeichnis statt TL_ROOT
$projectDir = System::getContainer()->getParameter('kernel.project_dir');
foreach ($fileLinks as $file) { foreach ($fileLinks as $file) {
try {
$url = strtok($file['url'], '#'); $url = strtok($file['url'], '#');
$path = parse_url($url, PHP_URL_PATH); $path = parse_url($url, PHP_URL_PATH);
$abs = $path ? TL_ROOT . '/' . ltrim($path, '/') : null; $abs = $path ? $projectDir . '/public/' . ltrim($path, '/') : null;
$mtime = ($abs && is_file($abs)) ? filemtime($abs) : 0; $mtime = ($abs && is_file($abs)) ? filemtime($abs) : 0;
$checksum = md5($url . '|' . $mtime); $checksum = md5($url . '|' . $mtime);
@@ -208,10 +212,7 @@ class IndexPageListener
['id' => $existing['id']] ['id' => $existing['id']]
); );
$this->debug('File updated', [ $this->debug('File updated', ['url' => $url, 'checksum' => $checksum]);
'url' => $url,
'checksum' => $checksum,
]);
} else { } else {
$db->insert( $db->insert(
'tl_search_files', 'tl_search_files',
@@ -227,9 +228,16 @@ class IndexPageListener
] ]
); );
$this->debug('File inserted', [ $this->debug('File inserted', ['url' => $url, 'checksum' => $checksum]);
'url' => $url, }
'checksum' => $checksum, } catch (\Throwable $e) {
$this->debug('File upsert FAILED', [
'url' => $file['url'] ?? null,
'type' => $file['type'] ?? null,
'error' => $e->getMessage(),
'class' => $e::class,
// falls DBAL-Exception: SQLSTATE/Code helfen brutal beim Finden
'code' => $e->getCode(),
]); ]);
} }
} }