update migrations

This commit is contained in:
Flatlogic Bot 2026-05-01 18:46:08 +00:00
parent c46f356c7c
commit 01dd6a10f5

View File

@ -15,17 +15,49 @@ function migrationOutput(string $message = ''): void
echo $message . PHP_EOL;
}
function configureMigrationSession(): void
{
if (PHP_SAPI === 'cli') {
return;
}
$sessionsDir = __DIR__ . '/sessions';
if (!is_dir($sessionsDir)) {
@mkdir($sessionsDir, 0777, true);
}
if (is_writable($sessionsDir)) {
session_save_path($sessionsDir);
}
if (
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
) {
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
'secure' => true,
'httponly' => true,
'samesite' => 'None',
]);
}
}
function canRunMigrations(): bool
{
if (PHP_SAPI === 'cli') {
return true;
}
configureMigrationSession();
if (session_status() === PHP_SESSION_NONE) {
@session_start();
}
if (($_SESSION['user_role_name'] ?? '') === 'Administrator') {
$roleName = (string) ($_SESSION['user_role_name'] ?? '');
if (strcasecmp($roleName, 'Administrator') === 0 || (int) ($_SESSION['user_id'] ?? 0) === 1) {
return true;
}