Dev #9

Merged
LordSchmackes merged 13 commits from dev into main 2026-05-23 21:30:54 +00:00
2 changed files with 9 additions and 4 deletions
Showing only changes of commit 99a04db1c6 - Show all commits
+7 -2
View File
@@ -37,13 +37,17 @@ load_env();
/**
* Get a PDO connection to the database.
*/
function get_db_connection(): ?PDO {
function get_db_connection() {
static $pdo = null;
if ($pdo !== null) {
return $pdo;
}
if (!class_exists('PDO')) {
return null;
}
$url = getenv('DATABASE_URL');
if (!$url) {
return null;
@@ -66,9 +70,10 @@ function get_db_connection(): ?PDO {
$pdo = new PDO($dsn, $user, $pass, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_TIMEOUT => 3,
]);
return $pdo;
} catch (PDOException $e) {
} catch (\Exception $e) {
error_log("Database connection failed: " . $e->getMessage());
return null;
}
+2 -2
View File
2
@@ -38,7 +38,7 @@ function init_db() {
}
}
}
github-actions[bot] commented 2026-05-23 21:30:28 +00:00 (Migrated from github.com)
Review

This helper function provides a clean default structure for internationalized recipe data, ensuring consistency.

This helper function provides a clean default structure for internationalized recipe data, ensuring consistency.
} catch (PDOException $e) {
} catch (\Exception $e) {
error_log("DB Init Error: " . $e->getMessage());
}
github-actions[bot] commented 2026-05-23 21:30:28 +00:00 (Migrated from github.com)
Review

The default value for 'description' is an empty string. While functional, for internationalization, it's often beneficial to provide a placeholder string like null or a specific marker (e.g., __('default_description')) that can be explicitly translated or identified as missing. This can help in debugging or ensuring all fields are eventually populated.

The default value for 'description' is an empty string. While functional, for internationalization, it's often beneficial to provide a placeholder string like `null` or a specific marker (e.g., `__('default_description')`) that can be explicitly translated or identified as missing. This can help in debugging or ensuring all fields are eventually populated.
}
github-actions[bot] commented 2026-05-23 21:30:28 +00:00 (Migrated from github.com)
Review

Similar to the 'description', an empty string for 'category' might be better represented by null or a translatable placeholder to distinguish between an intentionally empty category and a missing one.

Similar to the 'description', an empty string for 'category' might be better represented by `null` or a translatable placeholder to distinguish between an intentionally empty category and a missing one.
4
@@ -70,7 +70,7 @@ function load_recipes_local(): array {
}
}
}
} catch (PDOException $e) {
} catch (\Exception $e) {
error_log("Failed to load recipes from DB: " . $e->getMessage());
}
}
10