diff options
author | Simon Rettberg | 2014-10-16 10:30:47 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-10-16 10:30:47 +0200 |
commit | 377fe3adaab82bda7a6e1ced70d5f5273d6d44d3 (patch) | |
tree | 14140b1fc12a54ba70c887fd2612fb5bb3d79813 | |
parent | eventlog: add api, add page to view events (diff) | |
download | slx-admin-377fe3adaab82bda7a6e1ced70d5f5273d6d44d3.tar.gz slx-admin-377fe3adaab82bda7a6e1ced70d5f5273d6d44d3.tar.xz slx-admin-377fe3adaab82bda7a6e1ced70d5f5273d6d44d3.zip |
Don't use EventLog during update if db is too old
-rw-r--r-- | apis/update.inc.php | 12 | ||||
-rw-r--r-- | inc/eventlog.inc.php | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/apis/update.inc.php b/apis/update.inc.php index 384fe0be..1912a3c1 100644 --- a/apis/update.inc.php +++ b/apis/update.inc.php @@ -4,7 +4,8 @@ $targetVersion = Database::getExpectedSchemaVersion(); function fatal($message) { - EventLog::failure($message); + if (tableExists('eventlog')) + EventLog::failure($message); die("$message\n"); } @@ -39,7 +40,8 @@ while ($currentVersion < $targetVersion) { } Message::addSuccess('db-update-done'); -Eventlog::info("Database updated to version $currentVersion"); +if (tableExists('eventlog')) + EventLog::info("Database updated to version $currentVersion"); Util::redirect('index.php?do=Main'); //////////////// @@ -48,7 +50,7 @@ function tableHasColumn($table, $column) { $table = preg_replace('/\W/', '', $table); $column = preg_replace('/\W/', '', $column); - $res = Database::simpleQuery("DESCRIBE `$table`", array(), false); + $res = Database::simpleQuery("DESCRIBE `$table`", array(), true); if ($res !== false) { while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if ((is_array($column) && in_array($row['Field'], $column)) || (is_string($column) && $row['Field'] === $column)) @@ -62,7 +64,7 @@ function tableDropColumn($table, $column) { $table = preg_replace('/\W/', '', $table); $column = preg_replace('/\W/', '', $column); - $res = Database::simpleQuery("DESCRIBE `$table`", array(), false); + $res = Database::simpleQuery("DESCRIBE `$table`", array(), true); if ($res !== false) { while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if ((is_array($column) && in_array($row['Field'], $column)) || (is_string($column) && $row['Field'] === $column)) @@ -73,7 +75,7 @@ function tableDropColumn($table, $column) function tableExists($table) { - $res = Database::simpleQuery("SHOW TABLES", array(), false); + $res = Database::simpleQuery("SHOW TABLES", array(), true); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if ($row['Tables_in_openslx'] === $table) return true; diff --git a/inc/eventlog.inc.php b/inc/eventlog.inc.php index 181f8d38..093840df 100644 --- a/inc/eventlog.inc.php +++ b/inc/eventlog.inc.php @@ -16,6 +16,7 @@ class EventLog public static function failure($message, $details = '') { self::log('failure', $message, $details); + Property::setLastWarningId(Database::lastInsertId()); } public static function warning($message, $details = '') @@ -27,7 +28,6 @@ class EventLog public static function info($message, $details = '') { self::log('info', $message, $details); - Property::setLastWarningId(Database::lastInsertId()); } } |