Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[BUGFIX] Reduce amount of Cache::set() calls in AssetService
With TYPO3 v13, AssetService calls FrontendInterface::set() four times
in AssetService::getTypoScript() for a single AssetService::buildAll()
invocation. The cache usage was introduced in e84af96 ("[BUGFIX] Handle
new TS-not-set limitation on v13 (#1928)"), as TYPO3 v13 no longer fully
sets up TypoScript when serving fully-cached pages.

The four callers of AssetService::getTypoScript() are:

- AssetService::getSettings()
- AssetService::writeCachedMergedFileAndReturnTag()
- AssetService::getFileIntegrity()
- AssetService::generateTagForAssetType()

Reducing the number of FrontendInterface::set() calls reduces the amount
of database deadlock errors that occur if the Typo3DatabaseBackend is
used for the "vhs_main" cache and many concurrent requests hit the same
TYPO3 page that contains at least one uncached content element. But it
doesn't solve them completely; e.q. They still occur but less frequent.
This issue is tracked in the upstream TYPO3 bug tracker as #106593 [1].
A reproduction example is available on GitHub [2].

[1]: https://forge.typo3.org/issues/106593
[2]: https://github.com/adamkoppede/reproduce-deadlock-with-fluidtypo3-vhs-7-1
  • Loading branch information
adamkoppede authored and NamelessCoder committed May 7, 2025
commit df366c26d97d8e34916404039a0d7883ccbff335
13 changes: 7 additions & 6 deletions Classes/Service/AssetService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AssetService implements SingletonInterface
protected $cacheManager;

protected static bool $typoScriptAssetsBuilt = false;
protected static ?array $settingsCache = null;
protected static ?array $typoScriptCache = null;
protected static array $cachedDependencies = [];
protected static bool $cacheCleared = false;

Expand Down Expand Up @@ -145,15 +145,15 @@ public function isAlreadyDefined(string $assetName): bool
*/
public function getSettings(): array
{
if (null === static::$settingsCache) {
static::$settingsCache = $this->getTypoScript()['settings'] ?? [];
}
$settings = (array) static::$settingsCache;
return $settings;
return $this->getTypoScript()['settings'] ?? [];
}

protected function getTypoScript(): array
{
if (static::$typoScriptCache !== null) {
return static::$typoScriptCache;
}

$cache = $this->cacheManager->getCache('vhs_main');
$pageUid = $this->readPageUidFromContext();
$cacheId = 'vhs_asset_ts_' . $pageUid;
Expand Down Expand Up @@ -192,6 +192,7 @@ protected function getTypoScript(): array
$this->cacheManager->flushCachesByTag($cacheTag);
}

static::$typoScriptCache = $typoScript;
return $typoScript;
}

Expand Down