mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-15 17:16:08 +00:00
Fix install + admin bugs reported in issue #169
Addresses the five bugs found on master (6e139a1b) during a fresh
Docker install and admin testing:
1. Missing `details` column in gold_fin_log (HTTP 500 on finishing
construction with gold, buying Gold Club, admin giving gold):
- Add `details varchar(255)` to the gold_fin_log schema, matching
every INSERT and the a2b2.php reader that already use it.
- Fix the broken positional INSERT in Logging::goldFinLog() (it sent
3 values for a 7-column table) which 500'd on the same gold path.
2. Admin "View Player Info" fatal error: `<? php` -> `<?php` in
Admin/Templates/playerinfo.tpl.
3. "Reset Server" leaving the DB corrupted (Duplicate key name
'idx_ft_bonus_xy'): move the croppers indexes inline into the
CREATE TABLE IF NOT EXISTS so structure recreation is idempotent,
and add `croppers` to the reset truncate list.
4. Install wizard crash on failed DB connection (mysqli_error(false)):
use mysqli_connect_error() and show a friendly, actionable message
(incl. the Docker "db" hostname hint).
5. PHP exposing errors/stack traces to end users: ship a production
php.ini baseline + docker/php/zz-travianz.ini that turns off
display_errors and logs to stderr instead.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+10
-1
@@ -462,7 +462,16 @@ class MYSQLi_DB implements IDbConnection {
|
||||
$this->dbname = $dbname;
|
||||
|
||||
// connect to the DB
|
||||
if (!$this->connect()) die(mysqli_error($this->dblink));
|
||||
if (!$this->connect()) {
|
||||
// $this->dblink is FALSE here, so we cannot call mysqli_error() on it.
|
||||
// Use mysqli_connect_error() and show a friendly, actionable message.
|
||||
$error = mysqli_connect_error();
|
||||
die("Database connection failed: " . htmlspecialchars(
|
||||
$error !== null && $error !== ''
|
||||
? $error
|
||||
: 'could not connect to the database server. Please check the host, port and credentials. (When running with Docker, the database host is usually "db", not "localhost".)'
|
||||
));
|
||||
}
|
||||
|
||||
// we will operate in UTF8
|
||||
mysqli_query($this->dblink,"SET NAMES 'UTF8'");
|
||||
|
||||
@@ -110,7 +110,7 @@ class Logging {
|
||||
$log = "Finish construction and research with gold";
|
||||
list($log) = $database->escape_input($log);
|
||||
|
||||
$q = "Insert into " . TB_PREFIX . "gold_fin_log values (0,$wid,'$log')";
|
||||
$q = "INSERT INTO " . TB_PREFIX . "gold_fin_log (wid, action, time, details) VALUES ($wid, 'Finish all constructions', " . time() . ", '$log')";
|
||||
$database->query($q);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user