fix: address code review feedback (DB filename, migration query, error handling)

Co-authored-by: naielv <109038805+naielv@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-06 22:02:32 +00:00
parent 0c362fd40b
commit 6aaee59b3d
4 changed files with 12 additions and 8 deletions

View File

@@ -4,12 +4,12 @@
*
* Provides a PDO SQLite connection and a lightweight migration runner.
* All application data previously stored as JSON files under /DATA is now
* persisted in /DATA/axia4.db.
* persisted in /DATA/axia4.sqlite.
*
* Usage: db() → returns the shared PDO instance (auto-migrates on first call).
*/
define('DB_PATH', '/DATA/axia4.db');
define('DB_PATH', '/DATA/axia4.sqlite');
define('MIGRATIONS_DIR', __DIR__ . '/migrations');
// ── Connection ────────────────────────────────────────────────────────────────

View File

@@ -63,8 +63,9 @@ if (is_dir($users_dir)) {
$user_id = (int) $db->lastInsertId();
if ($user_id === 0) {
// Already existed look it up
$row = $db->prepare("SELECT id FROM users WHERE username = ?")->execute([$username]);
$user_id = (int) $db->query("SELECT id FROM users WHERE username = " . $db->quote($username))->fetchColumn();
$stmt2 = $db->prepare("SELECT id FROM users WHERE username = ?");
$stmt2->execute([$username]);
$user_id = (int) $stmt2->fetchColumn();
}
// Entreaulas centro assignment

View File

@@ -72,8 +72,11 @@ switch ($form_action) {
Sf($_POST["name"] ?? ""),
Sf($_POST["icon"] ?? "/static/logo-entreaulas.png"),
]);
// Create Alumnos directory for photo-based features
@mkdir("/DATA/entreaulas/Centros/$centro_id/Aularios/$aulario_id/Proyectos/", 0755, true);
// Create Proyectos directory for project file storage
$proyectos_dir = "/DATA/entreaulas/Centros/$centro_id/Aularios/$aulario_id/Proyectos/";
if (!is_dir($proyectos_dir)) {
mkdir($proyectos_dir, 0755, true);
}
header("Location: ?action=index");
exit();
break;

View File

@@ -32,8 +32,8 @@ switch ($form_action) {
db()->prepare("INSERT INTO centros (centro_id) VALUES (?)")->execute([$centro_id]);
// Keep filesystem directory for activity photos (Panel/Actividades)
$centro_path = "/DATA/entreaulas/Centros/$centro_id";
if (!is_dir($centro_path)) {
mkdir($centro_path, 0755, true);
if (!is_dir($centro_path) && !mkdir($centro_path, 0755, true) && !is_dir($centro_path)) {
error_log("centros.php: failed to create directory $centro_path");
}
header("Location: ?action=index");
exit();