fix: ensure mutability is accounted for when restoring drafts

addresses #869cdzmkq
This commit is contained in:
Björn Fromme
2026-03-16 12:03:00 +01:00
parent 11ff2b9084
commit cef2e4fa49
5 changed files with 364 additions and 22 deletions
+11 -5
View File
@@ -34,6 +34,7 @@ class TravelDataService
public const SOURCE_LOCAL = 'local';
public const SOURCE_REMOTE = 'remote';
private const AVAILABILITY_CACHE_TTL = 600;
private const MUTABILITY_CACHE_TTL = 3600;
public function __construct(
private readonly TravelLoader $travelLoader,
@@ -438,20 +439,25 @@ class TravelDataService
/**
* Gets mutability data for a travel date.
*
* @param int $dateId The travel date ID for API call
* @param bool $cached Whether to use cached data (default: true, TTL: 12 hours)
* @param int $dateId The travel date ID for API call
* @param bool $cached Whether to use cached data (default: true, TTL: 1 hour)
* @param bool $forceRefresh Whether to invalidate cache before fetching (requires cached: true)
*
* @return BaseData|null The mutability data or null if not available or error occurred
*/
public function getMutabilityData(int $dateId, bool $cached = true): ?BaseData
public function getMutabilityData(int $dateId, bool $cached = true, bool $forceRefresh = false): ?BaseData
{
if ($cached) {
$cacheKey = sprintf('mutability_%d', $dateId);
try {
if (true === $forceRefresh) {
$this->cache->delete($cacheKey);
}
return $this->cache->get($cacheKey, function (ItemInterface $item) use ($dateId) {
// 12 hours TTL - mutability dates have date-only granularity
$item->expiresAfter(43200);
// 1 hour TTL - better safe than sorry with mutability changes
$item->expiresAfter(self::MUTABILITY_CACHE_TTL);
return $this->fetchMutabilityData($dateId);
});