Add PreRenderDynamicImagesCron for dynamic image variant caching and idempotency guard for order bookings.
This commit is contained in:
@@ -561,7 +561,7 @@ class orderBookingRoute
|
||||
'reg_1' => (string)($data['reg_1'] ?? ''),
|
||||
'reg_2' => $this->normalizeNullableString($data['reg_2'] ?? null),
|
||||
'reg_3' => $this->normalizeNullableString($data['reg_3'] ?? null),
|
||||
'datetime' => (string)($data['datetime'] ?? ''),
|
||||
'datetime' => $this->normalizeDatetimeForFingerprint((string)($data['datetime'] ?? '')),
|
||||
'note' => $this->normalizeNullableString($data['note'] ?? null),
|
||||
'reference' => $this->normalizeNullableString($data['reference'] ?? null),
|
||||
'po' => $this->normalizeNullableString($data['po'] ?? null),
|
||||
@@ -619,6 +619,25 @@ class orderBookingRoute
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
private function normalizeDatetimeForFingerprint(string $datetime): string
|
||||
{
|
||||
$value = trim($datetime);
|
||||
if ($value === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$formats = ['Y-m-d H:i:s', 'Y-m-d H:i', 'Y-m-d'];
|
||||
foreach ($formats as $format) {
|
||||
$parsed = \DateTime::createFromFormat($format, $value);
|
||||
if ($parsed !== false) {
|
||||
// Use minute precision so rapid retries do not bypass idempotency because of second-level drift.
|
||||
return $parsed->format('Y-m-d H:i');
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function getBookingFromIdempotencyCache(string $fingerprint): ?order_bookings_o
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user