This commit is contained in:
2026-09-16 13:53:54 +02:00
parent 0b5ca54db9
commit d4e4b69e02
6 changed files with 97 additions and 68 deletions
+12
View File
@@ -347,6 +347,11 @@ function ensure_remember_token_columns(PDO $db): void {
if ($columnsChecked) return;
$columnsChecked = true;
$lockFile = sys_get_temp_dir() . '/fociz_auth_cols_' . md5(__DIR__) . '.lock';
if (file_exists($lockFile)) {
return;
}
try {
$result = $db->query("SHOW COLUMNS FROM `users` LIKE 'remember_token'");
if (!$result || $result->rowCount() === 0) {
@@ -360,6 +365,7 @@ function ensure_remember_token_columns(PDO $db): void {
if (!$resActivity || $resActivity->rowCount() === 0) {
$db->exec("ALTER TABLE `users` ADD COLUMN `last_activity_at` DATETIME NULL AFTER `remember_token_expires_at`");
}
@touch($lockFile);
} catch (Throwable $e) {
// Stil negeren indien al aanwezig of tijdens migraties
}
@@ -374,6 +380,11 @@ function ensure_sessions_table(PDO $db): void {
if ($sessionsTableChecked) return;
$sessionsTableChecked = true;
$lockFile = sys_get_temp_dir() . '/fociz_sessions_tbl_' . md5(__DIR__) . '.lock';
if (file_exists($lockFile)) {
return;
}
try {
$db->exec("
CREATE TABLE IF NOT EXISTS `user_sessions` (
@@ -394,6 +405,7 @@ function ensure_sessions_table(PDO $db): void {
CONSTRAINT `fk_user_sessions_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");
@touch($lockFile);
} catch (Throwable $e) {
error_log("ensure_sessions_table notice: " . $e->getMessage());
}