fix: fix boolean return type in totp.php, handle multi-statement sql and enable error reporting

This commit is contained in:
2026-09-08 14:03:47 +02:00
parent 36e38b4df3
commit 17b0557d1d
6 changed files with 29 additions and 8 deletions
+7
View File
@@ -80,3 +80,10 @@ define('APP_ENV', fociz_env('APP_ENV', 'development')); // 'development' of 'liv
// Tijdzone
date_default_timezone_set('Europe/Amsterdam');
// Foutrapportage: in development tonen we fouten direct op het scherm
if (APP_ENV !== 'live') {
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
}
+12 -3
View File
@@ -53,6 +53,9 @@ function get_db_connection(): PDO {
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_TIMEOUT => 5,
];
if (defined('PDO::MYSQL_ATTR_MULTI_STATEMENTS')) {
$options[PDO::MYSQL_ATTR_MULTI_STATEMENTS] = true;
}
try {
$pdo = new PDO($dsn, DB_USER, DB_PASS, $options);
@@ -100,10 +103,16 @@ function ensure_tables_exist(PDO $pdo): void {
$schemaFile = __DIR__ . '/../schema.sql';
if (file_exists($schemaFile)) {
$sql = file_get_contents($schemaFile);
$pdo->exec($sql);
// Splits op puntkomma om elk CREATE TABLE statement apart uit te voeren
$statements = array_filter(array_map('trim', explode(';', $sql)));
foreach ($statements as $stmt) {
if (!empty($stmt)) {
$pdo->exec($stmt);
}
}
}
}
} catch (PDOException $e) {
// Tabellen bestaan waarschijnlijk al
} catch (Exception $e) {
error_log("Fout bij uitvoeren schema.sql: " . $e->getMessage());
}
}