Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f86a5240d | |||
| 59b261c333 | |||
| 0912738528 | |||
| 8b2c6e6b92 | |||
| ca1305c9c6 | |||
| e6e3e9339a | |||
| b7a5e95c7d | |||
| bc35527f3f | |||
| e04dfb2bd4 | |||
| 6d8d0938f1 | |||
| 8f9c9cea72 | |||
| ad532e7b4c | |||
| 2257178cb6 | |||
| 2f8eddda36 | |||
| 5026f615f2 | |||
| f402e6546a | |||
| 579f58b614 | |||
| 17188537bc | |||
| 3427f6b60b | |||
| 6e41df002e | |||
| 838f574574 | |||
| 8549e4e9da | |||
| 29f7920cb5 |
@@ -4,6 +4,7 @@ namespace MummertMedia\ContaoMeilisearchBundle\Command;
|
|||||||
|
|
||||||
use Contao\CoreBundle\Framework\ContaoFramework;
|
use Contao\CoreBundle\Framework\ContaoFramework;
|
||||||
use Contao\Database;
|
use Contao\Database;
|
||||||
|
use Contao\System;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
@@ -102,7 +103,11 @@ class MeilisearchFilesParseCommand extends Command
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$absolutePath = TL_ROOT . '/' . $normalized;
|
$root = defined('TL_ROOT')
|
||||||
|
? TL_ROOT
|
||||||
|
: System::getContainer()->getParameter('kernel.project_dir') . '/public';
|
||||||
|
|
||||||
|
$absolutePath = $root . '/' . $normalized;
|
||||||
|
|
||||||
if (!is_file($absolutePath)) {
|
if (!is_file($absolutePath)) {
|
||||||
$this->log('File missing, skip', [
|
$this->log('File missing, skip', [
|
||||||
|
|||||||
@@ -4,21 +4,18 @@ namespace MummertMedia\ContaoMeilisearchBundle\EventListener;
|
|||||||
|
|
||||||
use Contao\Config;
|
use Contao\Config;
|
||||||
use Contao\System;
|
use Contao\System;
|
||||||
use Doctrine\DBAL\Connection;
|
use MummertMedia\ContaoMeilisearchBundle\Service\MeilisearchFileHelper;
|
||||||
|
|
||||||
class IndexPageListener
|
class IndexPageListener
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly Connection $connection,
|
private readonly MeilisearchFileHelper $fileHelper,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function debug(string $message, array $context = []): void
|
private function debug(string $message, array $context = []): void
|
||||||
{
|
{
|
||||||
$ctx = $context
|
$ctx = $context ? ' | ' . json_encode($context, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : '';
|
||||||
? ' | ' . json_encode($context, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)
|
|
||||||
: '';
|
|
||||||
|
|
||||||
error_log('[ContaoMeilisearch][IndexPageListener] ' . $message . $ctx);
|
error_log('[ContaoMeilisearch][IndexPageListener] ' . $message . $ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,8 +76,6 @@ class IndexPageListener
|
|||||||
$parsed['page']['keywords'] ?? null,
|
$parsed['page']['keywords'] ?? null,
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->debug('Meta: keyword sources', ['sources' => $keywordSources]);
|
|
||||||
|
|
||||||
$keywords = [];
|
$keywords = [];
|
||||||
foreach ($keywordSources as $src) {
|
foreach ($keywordSources as $src) {
|
||||||
if (!is_string($src) || trim($src) === '') {
|
if (!is_string($src) || trim($src) === '') {
|
||||||
@@ -95,77 +90,41 @@ class IndexPageListener
|
|||||||
$set['keywords'] = implode(' ', array_unique($keywords));
|
$set['keywords'] = implode(' ', array_unique($keywords));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->debug('Meta: keywords result', [
|
// IMAGEPATH
|
||||||
'keywords' => $set['keywords'] ?? null,
|
if (!empty($parsed['page']['searchimage'] ?? null)) {
|
||||||
]);
|
$set['imagepath'] = trim((string) $parsed['page']['searchimage']);
|
||||||
|
|
||||||
// IMAGEPATH (UUID)
|
|
||||||
$searchImage = $parsed['page']['searchimage'] ?? null;
|
|
||||||
$this->debug('Meta: searchimage candidate', ['searchimage' => $searchImage]);
|
|
||||||
|
|
||||||
if (!empty($searchImage)) {
|
|
||||||
$set['imagepath'] = trim((string) $searchImage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// STARTDATE
|
// STARTDATE
|
||||||
$startDate =
|
if (is_numeric($parsed['event']['startDate'] ?? null)) {
|
||||||
$parsed['event']['startDate']
|
$set['startDate'] = (int) $parsed['event']['startDate'];
|
||||||
?? $parsed['news']['startDate']
|
|
||||||
?? null;
|
|
||||||
|
|
||||||
$this->debug('Meta: startDate candidate', ['startDate' => $startDate]);
|
|
||||||
|
|
||||||
if (is_numeric($startDate) && (int) $startDate > 0) {
|
|
||||||
$set['startDate'] = (int) $startDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECKSUM
|
// CHECKSUM
|
||||||
try {
|
$checksumSeed = (string) ($data['checksum'] ?? '');
|
||||||
$checksumSeed = (string) ($data['checksum'] ?? '');
|
$checksumSeed .= '|' . ($set['keywords'] ?? '');
|
||||||
$checksumSeed .= '|' . ($set['keywords'] ?? '');
|
$checksumSeed .= '|' . ($set['priority'] ?? '');
|
||||||
$checksumSeed .= '|' . ($set['priority'] ?? '');
|
$checksumSeed .= '|' . ($set['imagepath'] ?? '');
|
||||||
$checksumSeed .= '|' . ($set['imagepath'] ?? '');
|
$checksumSeed .= '|' . ($set['startDate'] ?? '');
|
||||||
$checksumSeed .= '|' . ($set['startDate'] ?? '');
|
|
||||||
|
|
||||||
$set['checksum'] = md5($checksumSeed);
|
$set['checksum'] = md5($checksumSeed);
|
||||||
|
|
||||||
$this->debug('Checksum generated', [
|
|
||||||
'seed_preview' => substr($checksumSeed, 0, 120) . (strlen($checksumSeed) > 120 ? '…' : ''),
|
|
||||||
'checksum' => $set['checksum'],
|
|
||||||
]);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
$this->debug('Failed to generate checksum', [
|
|
||||||
'error' => $e->getMessage(),
|
|
||||||
'class' => $e::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* =====================
|
* =====================
|
||||||
* DATEI-ERKENNUNG + UPSERT
|
* DATEI-ERKENNUNG (NUR ERKENNUNG!)
|
||||||
* =====================
|
* =====================
|
||||||
*/
|
*/
|
||||||
if ((int) ($data['protected'] ?? 0) !== 0) {
|
if ((int) ($data['protected'] ?? 0) !== 0) {
|
||||||
$this->debug('Abort: protected page', ['protected' => $data['protected'] ?? null]);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$indexFiles = (bool) Config::get('meilisearch_index_files');
|
if (!Config::get('meilisearch_index_files')) {
|
||||||
|
|
||||||
$this->debug('File indexing setting', [
|
|
||||||
'meilisearch_index_files' => $indexFiles,
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!$indexFiles) {
|
|
||||||
$this->debug('Abort: file indexing disabled');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$links = $this->findAllLinks($content);
|
$links = $this->findAllLinks($content);
|
||||||
$this->debug('Links found', ['count' => count($links)]);
|
|
||||||
|
|
||||||
$fileLinks = [];
|
$fileLinks = [];
|
||||||
|
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
@@ -177,72 +136,15 @@ class IndexPageListener
|
|||||||
|
|
||||||
$this->debug('Indexable file links found', [
|
$this->debug('Indexable file links found', [
|
||||||
'count' => count($fileLinks),
|
'count' => count($fileLinks),
|
||||||
'types' => array_count_values(array_column($fileLinks, 'type')),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($fileLinks) {
|
if ($fileLinks) {
|
||||||
|
|
||||||
$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) {
|
foreach ($fileLinks as $file) {
|
||||||
$url = strtok($file['url'], '#');
|
$this->fileHelper->collect(
|
||||||
|
$file['url'],
|
||||||
$path = parse_url($url, PHP_URL_PATH);
|
$file['type'],
|
||||||
$abs = $path ? TL_ROOT . '/' . ltrim($path, '/') : null;
|
(int) ($data['pid'] ?? 0)
|
||||||
|
|
||||||
$mtime = ($abs && is_file($abs)) ? filemtime($abs) : 0;
|
|
||||||
$checksum = md5($url . '|' . $mtime);
|
|
||||||
|
|
||||||
$existing = $db->fetchAssociative(
|
|
||||||
'SELECT id, checksum FROM tl_search_files WHERE url = ?',
|
|
||||||
[$url]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($existing) {
|
|
||||||
$db->update(
|
|
||||||
'tl_search_files',
|
|
||||||
[
|
|
||||||
'tstamp' => $time,
|
|
||||||
'last_seen' => $time,
|
|
||||||
'page_id' => (int) ($data['pid'] ?? 0),
|
|
||||||
'file_mtime' => $mtime,
|
|
||||||
'checksum' => $checksum,
|
|
||||||
],
|
|
||||||
['id' => $existing['id']]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->debug('File updated', [
|
|
||||||
'url' => $url,
|
|
||||||
'checksum' => $checksum,
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
$db->insert(
|
|
||||||
'tl_search_files',
|
|
||||||
[
|
|
||||||
'tstamp' => $time,
|
|
||||||
'last_seen' => $time,
|
|
||||||
'type' => $file['type'],
|
|
||||||
'url' => $url,
|
|
||||||
'title' => $file['linkText'] ?? basename($url),
|
|
||||||
'page_id' => (int) ($data['pid'] ?? 0),
|
|
||||||
'file_mtime' => $mtime,
|
|
||||||
'checksum' => $checksum,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->debug('File inserted', [
|
|
||||||
'url' => $url,
|
|
||||||
'checksum' => $checksum,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,11 +194,7 @@ class IndexPageListener
|
|||||||
private function detectIndexableFileType(string $url): ?string
|
private function detectIndexableFileType(string $url): ?string
|
||||||
{
|
{
|
||||||
$url = strtok($url, '#');
|
$url = strtok($url, '#');
|
||||||
|
|
||||||
$parts = parse_url($url);
|
$parts = parse_url($url);
|
||||||
if (!$parts) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($parts['path'])) {
|
if (!empty($parts['path'])) {
|
||||||
$ext = strtolower(pathinfo($parts['path'], PATHINFO_EXTENSION));
|
$ext = strtolower(pathinfo($parts['path'], PATHINFO_EXTENSION));
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ $GLOBALS['TL_DCA']['tl_search_files'] = [
|
|||||||
'url' => 'unique',
|
'url' => 'unique',
|
||||||
'type' => 'index',
|
'type' => 'index',
|
||||||
'checksum' => 'index',
|
'checksum' => 'index',
|
||||||
'last_seen' => 'index', // ⬅️ NEU (für Cleanup-Performance)
|
'uuid' => 'index',
|
||||||
|
'last_seen' => 'index',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@@ -63,6 +64,10 @@ $GLOBALS['TL_DCA']['tl_search_files'] = [
|
|||||||
'sql' => "mediumtext NULL",
|
'sql' => "mediumtext NULL",
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'uuid' => [
|
||||||
|
'sql' => "binary(16) NULL",
|
||||||
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* md5(url + filemtime)
|
* md5(url + filemtime)
|
||||||
* → erkennt Änderungen zuverlässig
|
* → erkennt Änderungen zuverlässig
|
||||||
|
|||||||
@@ -0,0 +1,259 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MummertMedia\ContaoMeilisearchBundle\Service;
|
||||||
|
|
||||||
|
use Contao\FilesModel;
|
||||||
|
use Contao\StringUtil;
|
||||||
|
use Contao\System;
|
||||||
|
use Doctrine\DBAL\Connection;
|
||||||
|
|
||||||
|
class MeilisearchFileHelper
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly Connection $connection,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zentrale Datei-Verarbeitung
|
||||||
|
*/
|
||||||
|
public function collect(string $url, string $type, int $pageId): void
|
||||||
|
{
|
||||||
|
$this->log('collect() start', [
|
||||||
|
'url' => $url,
|
||||||
|
'type' => $type,
|
||||||
|
'pageId' => $pageId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// -------------------------------------------------
|
||||||
|
// 1. URL normalisieren
|
||||||
|
// -------------------------------------------------
|
||||||
|
$cleanUrl = strtok($url, '#');
|
||||||
|
$parts = parse_url($cleanUrl);
|
||||||
|
|
||||||
|
if (!$parts) {
|
||||||
|
$this->log('Invalid URL, skip');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------
|
||||||
|
// 2. Externe Datei? → skip
|
||||||
|
// -------------------------------------------------
|
||||||
|
if (!empty($parts['host'])) {
|
||||||
|
$currentRequest = System::getContainer()
|
||||||
|
->get('request_stack')
|
||||||
|
->getCurrentRequest();
|
||||||
|
|
||||||
|
$pageHost = $currentRequest
|
||||||
|
? parse_url($currentRequest->getSchemeAndHttpHost(), PHP_URL_HOST)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if ($pageHost && $parts['host'] !== $pageHost) {
|
||||||
|
$this->log('External file detected, skip', [
|
||||||
|
'host' => $parts['host'],
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------
|
||||||
|
// 3. Pfad-Kandidaten sammeln (ohne Annahmen!)
|
||||||
|
// -------------------------------------------------
|
||||||
|
$query = [];
|
||||||
|
if (!empty($parts['query'])) {
|
||||||
|
parse_str($parts['query'], $query);
|
||||||
|
}
|
||||||
|
|
||||||
|
$pathCandidates = [];
|
||||||
|
|
||||||
|
// direkter Pfad
|
||||||
|
if (!empty($parts['path'])) {
|
||||||
|
$pathCandidates[] = $parts['path'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Download-Parameter
|
||||||
|
foreach (['file', 'f', 'p'] as $param) {
|
||||||
|
if (!empty($query[$param])) {
|
||||||
|
$pathCandidates[] = $query[$param];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// normalisieren
|
||||||
|
$pathCandidates = array_values(array_unique(array_filter(array_map(
|
||||||
|
static function ($candidate) {
|
||||||
|
$candidate = rawurldecode(html_entity_decode((string) $candidate, ENT_QUOTES));
|
||||||
|
return ltrim($candidate, '/') ?: null;
|
||||||
|
},
|
||||||
|
$pathCandidates
|
||||||
|
))));
|
||||||
|
|
||||||
|
$this->log('Path candidates (normalized)', [
|
||||||
|
'candidates' => $pathCandidates,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// -------------------------------------------------
|
||||||
|
// 4. FilesModel (DBAFS) auflösen → UUID
|
||||||
|
// -------------------------------------------------
|
||||||
|
$fileModel = null;
|
||||||
|
|
||||||
|
foreach ($pathCandidates as $candidate) {
|
||||||
|
|
||||||
|
// 1) direkt
|
||||||
|
$model = FilesModel::findByPath($candidate);
|
||||||
|
if ($model && $model->uuid) {
|
||||||
|
$fileModel = $model;
|
||||||
|
$this->log('Resolved via FilesModel (direct)', [
|
||||||
|
'candidate' => $candidate,
|
||||||
|
'path' => $model->path,
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) fallback: files/ davor
|
||||||
|
if (!str_starts_with($candidate, 'files/')) {
|
||||||
|
$model = FilesModel::findByPath('files/' . $candidate);
|
||||||
|
if ($model && $model->uuid) {
|
||||||
|
$fileModel = $model;
|
||||||
|
$this->log('Resolved via FilesModel (files/ prefix)', [
|
||||||
|
'candidate' => $candidate,
|
||||||
|
'path' => $model->path,
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$fileModel) {
|
||||||
|
$this->log('No Contao file model found, skip', [
|
||||||
|
'candidates' => $pathCandidates,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$normalizedPath = (string) $fileModel->path;
|
||||||
|
$uuidBin = $fileModel->uuid;
|
||||||
|
$uuid = StringUtil::binToUuid($uuidBin);
|
||||||
|
$canonicalUrl = '/' . ltrim($normalizedPath, '/');
|
||||||
|
|
||||||
|
$this->log('UUID resolved', [
|
||||||
|
'path' => $canonicalUrl,
|
||||||
|
'uuid' => $uuid,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// -------------------------------------------------
|
||||||
|
// 5. Datei im Filesystem prüfen
|
||||||
|
// -------------------------------------------------
|
||||||
|
$projectDir = System::getContainer()->getParameter('kernel.project_dir');
|
||||||
|
$abs = $projectDir . '/public/' . $normalizedPath;
|
||||||
|
|
||||||
|
if (!is_file($abs)) {
|
||||||
|
$this->log('Resolved model but file missing on filesystem, skip', [
|
||||||
|
'path' => $normalizedPath,
|
||||||
|
'abs' => $abs,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------
|
||||||
|
// 6. Redaktionellen Titel aus tl_files.meta
|
||||||
|
// -------------------------------------------------
|
||||||
|
$title = null;
|
||||||
|
$meta = StringUtil::deserialize($fileModel->meta, true);
|
||||||
|
|
||||||
|
// 1) bevorzugte Sprache (falls vorhanden)
|
||||||
|
$lang = $GLOBALS['TL_LANGUAGE'] ?? null;
|
||||||
|
if ($lang && !empty($meta[$lang]['title'])) {
|
||||||
|
$title = trim((string) $meta[$lang]['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) Fallback: erste verfügbare Sprache
|
||||||
|
if ($title === null && is_array($meta)) {
|
||||||
|
foreach ($meta as $langKey => $langMeta) {
|
||||||
|
if (!empty($langMeta['title'])) {
|
||||||
|
$title = trim((string) $langMeta['title']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($title) {
|
||||||
|
$this->log('Title resolved from tl_files', [
|
||||||
|
'title' => $title,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------
|
||||||
|
// 7. Datei-Infos
|
||||||
|
// -------------------------------------------------
|
||||||
|
$mtime = filemtime($abs) ?: 0;
|
||||||
|
$checksum = md5($normalizedPath . '|' . $mtime);
|
||||||
|
$now = time();
|
||||||
|
|
||||||
|
// -------------------------------------------------
|
||||||
|
// 8. Upsert über UUID
|
||||||
|
// -------------------------------------------------
|
||||||
|
$existing = $this->connection->fetchAssociative(
|
||||||
|
'SELECT id FROM tl_search_files WHERE uuid = ?',
|
||||||
|
[$uuidBin]
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($existing) {
|
||||||
|
$data = [
|
||||||
|
'tstamp' => $now,
|
||||||
|
'last_seen' => $now,
|
||||||
|
'type' => $type,
|
||||||
|
'url' => $canonicalUrl,
|
||||||
|
'page_id' => $pageId,
|
||||||
|
'file_mtime' => $mtime,
|
||||||
|
'checksum' => $checksum,
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($title !== null) {
|
||||||
|
$data['title'] = $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->connection->update(
|
||||||
|
'tl_search_files',
|
||||||
|
$data,
|
||||||
|
['id' => $existing['id']]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->log('File updated by UUID', [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$this->connection->insert(
|
||||||
|
'tl_search_files',
|
||||||
|
[
|
||||||
|
'tstamp' => $now,
|
||||||
|
'last_seen' => $now,
|
||||||
|
'type' => $type,
|
||||||
|
'url' => $canonicalUrl,
|
||||||
|
'title' => $title ?? basename($normalizedPath),
|
||||||
|
'page_id' => $pageId,
|
||||||
|
'file_mtime' => $mtime,
|
||||||
|
'checksum' => $checksum,
|
||||||
|
'uuid' => $uuidBin,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->log('File inserted by UUID', [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->log('collect() end');
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------
|
||||||
|
// Logging
|
||||||
|
// -------------------------------------------------
|
||||||
|
private function log(string $message, array $context = []): void
|
||||||
|
{
|
||||||
|
$ctx = $context
|
||||||
|
? ' | ' . json_encode($context, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)
|
||||||
|
: '';
|
||||||
|
|
||||||
|
error_log('[ContaoMeilisearch][MeilisearchFileHelper] ' . $message . $ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user