Skip to content

Commit fc71c37

Browse files
fix: sync IAppConfig cache when CA ID is empty
When getCaId() finds an empty CA ID in cache, it now calls clearCache(true) to reload from database before generating a new one. This prevents race conditions in test environments where CLI commands and HTTP requests may execute simultaneously with independent caches. The solution is simpler than using file locks and works transparently in both test and production environments with minimal overhead. Signed-off-by: Vitor Mattos <[email protected]>
1 parent bffd35d commit fc71c37

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

lib/Handler/CertificateEngine/AEngineHandler.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,8 @@ public function readCertificate(string $certificate, string $privateKey): array
141141
public function getCaId(): string {
142142
$caId = $this->caIdentifierService->getCaId();
143143
if (empty($caId)) {
144-
// In debug mode (tests), use file lock and cache clear to prevent race conditions
145-
// between CLI commands and HTTP requests executing simultaneously.
146-
// In production, this is not needed as setup commands run before HTTP requests.
147-
if ($this->config->getSystemValueBool('debug', false)) {
148-
$caId = $this->getCaIdWithLock();
149-
} else {
150-
$caId = $this->caIdentifierService->generateCaId($this->getName());
151-
}
144+
$this->appConfig->clearCache(true);
145+
$caId = $this->caIdentifierService->getCaId() ?: $this->caIdentifierService->generateCaId($this->getName());
152146
}
153147
return $caId;
154148
}

0 commit comments

Comments
 (0)