Fix bulk insert issue

This commit is contained in:
DariusIII
2026-05-14 11:39:21 +02:00
parent c2b00752d7
commit bd9aa517d3
3 changed files with 70 additions and 1 deletions
@@ -366,7 +366,7 @@ class ManticoreSearchDriver implements SearchDriverInterface
$documents[] = array_merge(
['id' => $release['id']],
ReleaseSearchIndexDocument::normalize($release)
ReleaseSearchIndexDocument::normalizeForBulk($release)
);
}
@@ -9,6 +9,26 @@ namespace App\Support;
*/
final class ReleaseSearchIndexDocument
{
/**
* Normalize a release row for bulk indexing. Rows already produced by {@see normalize()}
* (e.g. from release search populate) lack `postdate` / `adddate` keys;
* calling {@see normalize()} again would zero `postdate_ts` / `adddate_ts` unless those sources are restored.
*
* @param array<string, mixed> $row
* @return array<string, mixed>
*/
public static function normalizeForBulk(array $row): array
{
if (array_key_exists('postdate_ts', $row) && ! array_key_exists('postdate', $row)) {
$row = array_merge($row, [
'postdate' => $row['postdate_ts'] ?? null,
'adddate' => $row['adddate_ts'] ?? null,
]);
}
return self::normalize($row);
}
/**
* @param array<string, mixed> $row Keys from DB or insert parameters
* @return array<string, mixed>