Tags: opensourcepos/opensourcepos
Tags
fix: Catch mysqli_sql_exception in DB fallback handlers for fresh Doc… …ker installs (#4525) * fix: Catch mysqli_sql_exception in DB fallback handlers for fresh Docker installs On a fresh Docker install with an empty database, the ospos_sessions table doesn't exist yet. The CSRF filter triggers session initialization before the login/migration page can be reached. The existing code in Session.php, OSPOS.php, and MY_Migration.php catches DatabaseException, but the MySQLi driver throws mysqli_sql_exception (which extends RuntimeException, not DatabaseException) when the table doesn't exist. This causes an unhandled exception resulting in HTTP 500. Fix: Change all three catch blocks from to so that mysqli_sql_exception and any other unexpected database errors are caught, allowing the app to fall back gracefully: - Session.php: Falls back to FileHandler so sessions work without DB - OSPOS.php: Falls back to empty settings so config loads work - MY_Migration.php: Falls back to version 0 / false so the migration check passes gracefully This allows the login page with migration UI to be served on first access, so the initial schema migration can run. Fixes #4524 --------- Co-authored-by: Ollama <[email protected]>
PreviousNext