1
0

settings cache

This commit is contained in:
2026-03-13 14:38:58 +01:00
parent 04995e3712
commit add5cca222
3 changed files with 21 additions and 8 deletions

View File

@@ -69,7 +69,7 @@ class SettingCacheService
}
// PHP include returns an array — loaded by OPcache on subsequent requests, much faster than DB.
$payload = "<?php\nreturn " . $this->exportValue($settings) . ";\n";
$payload = "<?php\n\nreturn " . $this->exportValue($settings) . ";\n";
$written = @file_put_contents($tmp, $payload, LOCK_EX);
if ($written === false) {
@unlink($tmp);

View File

@@ -2,7 +2,6 @@
use MintyPHP\Buffer;
use MintyPHP\Http\RequestContext;
use MintyPHP\Service\Settings\SettingsSessionGateway;
use MintyPHP\Session;
$defaultTitle = appTitle();
@@ -12,10 +11,8 @@ $primaryVars = appPrimaryCssVars();
$csrfKey = Session::$csrfSessionKey;
$csrfToken = (string) ($_SESSION[$csrfKey] ?? '');
$isLoggedIn = !empty($user['id']);
$sessionIdleSeconds = 0;
if ($isLoggedIn) {
$sessionIdleSeconds = app(SettingsSessionGateway::class)->getSessionIdleTimeoutSeconds();
}
$sessionIdleMinutes = (int) (appSetting('session_idle_timeout_minutes') ?? 30);
$sessionIdleSeconds = max($sessionIdleMinutes, 5) * 60;
$telemetryEnabled = frontendTelemetryEnabled();
$telemetrySampleRate = frontendTelemetrySampleRate();
$telemetryAllowedEvents = implode(',', frontendTelemetryAllowedEvents());
@@ -44,7 +41,7 @@ if ($bufferTitle !== '') {
data-telemetry-allowed-events="<?php e($telemetryAllowedEvents); ?>"
data-telemetry-csrf-key="<?php e($csrfKey); ?>"
data-telemetry-csrf-token="<?php e($csrfToken); ?>"
<?php if ($isLoggedIn && $sessionIdleSeconds > 0): ?>
<?php if ($isLoggedIn): ?>
data-session-idle-seconds="<?php e((string) $sessionIdleSeconds); ?>"
data-session-ping-url="<?php e(lurl('admin/session-ping/data')); ?>"
data-session-logout-url="<?php e(lurl('logout')); ?>"
@@ -89,7 +86,7 @@ if ($bufferTitle !== '') {
<script src="<?php e(assetVersion('vendor/fslightbox/fslightbox.js')); ?>"></script>
<?php require __DIR__ . '/partials/app-confirm-dialog.phtml'; ?>
<?php if ($isLoggedIn && $sessionIdleSeconds > 0): ?>
<?php if ($isLoggedIn): ?>
<?php require __DIR__ . '/partials/app-session-warning-dialog.phtml'; ?>
<script type="module" src="<?php e(assetVersion('js/components/app-session-warning.js')); ?>"></script>
<?php endif; ?>

View File

@@ -110,6 +110,22 @@ class CoreStarterkitContractTest extends TestCase
$this->assertSame([], $violations, "asset(...) JS URLs found in templates/pages:\n" . implode("\n", $violations));
}
public function testTemplatesDoNotUseDatabaseFacadeDirectly(): void
{
$violations = $this->findPatternMatchesInFiles('templates', '/\bDB::/', ['phtml']);
$this->assertSame([], $violations, "Direct DB facade usage found in templates/:\n" . implode("\n", $violations));
}
public function testTemplatesDoNotResolveServiceGatewayOrRepositoryViaDI(): void
{
$violations = $this->findPatternMatchesInFiles(
'templates',
'/app\(\s*[\\\\A-Za-z0-9_]*(?:Service|Gateway|Repository)::class\s*\)/',
['phtml']
);
$this->assertSame([], $violations, "DI resolution of Service/Gateway/Repository found in templates/:\n" . implode("\n", $violations));
}
public function testNoLegacySettingsGatewayOrServiceReferencesExist(): void
{
$patterns = [