diff --git a/lib/Service/Settings/SettingCacheService.php b/lib/Service/Settings/SettingCacheService.php index 51ad23b..f6164ed 100644 --- a/lib/Service/Settings/SettingCacheService.php +++ b/lib/Service/Settings/SettingCacheService.php @@ -69,7 +69,7 @@ class SettingCacheService } // PHP include returns an array — loaded by OPcache on subsequent requests, much faster than DB. - $payload = "exportValue($settings) . ";\n"; + $payload = "exportValue($settings) . ";\n"; $written = @file_put_contents($tmp, $payload, LOCK_EX); if ($written === false) { @unlink($tmp); diff --git a/templates/default.phtml b/templates/default.phtml index 6c2c41f..3afd8bd 100644 --- a/templates/default.phtml +++ b/templates/default.phtml @@ -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="" data-telemetry-csrf-key="" data-telemetry-csrf-token="" - 0): ?> + data-session-idle-seconds="" data-session-ping-url="" data-session-logout-url="" @@ -89,7 +86,7 @@ if ($bufferTitle !== '') { - 0): ?> + diff --git a/tests/Architecture/CoreStarterkitContractTest.php b/tests/Architecture/CoreStarterkitContractTest.php index 986d2bb..8aead44 100644 --- a/tests/Architecture/CoreStarterkitContractTest.php +++ b/tests/Architecture/CoreStarterkitContractTest.php @@ -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 = [