fix deployment db issue and widthrawal administration page
This commit is contained in:
@@ -15,6 +15,11 @@ class TimeService
|
||||
// Cached per-request user timezone
|
||||
private ?string $cachedUserTz = null;
|
||||
|
||||
/** @var array<string, mixed>|null */
|
||||
private ?array $cachedSettings = null;
|
||||
|
||||
private bool $settingsLookupAttempted = false;
|
||||
|
||||
/**
|
||||
* Prime detection cache from the Request (optional call, lazy by default).
|
||||
*/
|
||||
@@ -76,13 +81,13 @@ class TimeService
|
||||
|
||||
// 3) Global settings timezone (if available)
|
||||
try {
|
||||
$settings = (new SettingsModel())->getSettings();
|
||||
$settings = $this->cachedApplicationSettings();
|
||||
$tz = $settings['timezone'] ?? null;
|
||||
if ($tz && in_array($tz, timezone_identifiers_list(), true)) {
|
||||
return $tz;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// ignore
|
||||
// ignore — never fail the request for timezone lookup
|
||||
}
|
||||
|
||||
// 4) School attendance timezone (if defined)
|
||||
@@ -219,4 +224,25 @@ class TimeService
|
||||
$value = trim($value);
|
||||
return (bool) preg_match('/^\d{4}-\d{2}-\d{2}$/', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function cachedApplicationSettings(): array
|
||||
{
|
||||
if ($this->settingsLookupAttempted) {
|
||||
return $this->cachedSettings ?? [];
|
||||
}
|
||||
|
||||
$this->settingsLookupAttempted = true;
|
||||
|
||||
try {
|
||||
$settings = (new SettingsModel())->getSettings();
|
||||
$this->cachedSettings = is_array($settings) ? $settings : [];
|
||||
} catch (\Throwable $e) {
|
||||
$this->cachedSettings = [];
|
||||
}
|
||||
|
||||
return $this->cachedSettings;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user