From 3c111597768a13ae05463b044f6e4d6dc18d8be0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 25 Apr 2017 13:39:01 +0300 Subject: [PATCH] return result codes if DB connection or --debug-feed fails --- classes/db.php | 8 ++++++-- classes/db/mysqli.php | 3 ++- classes/db/pgsql.php | 3 ++- update.php | 4 +++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/classes/db.php b/classes/db.php index c7d6da91..e8cb2dea 100644 --- a/classes/db.php +++ b/classes/db.php @@ -23,12 +23,16 @@ class Db implements IDb { } } - if (!$this->adapter) die("Error initializing database adapter for " . DB_TYPE); + if (!$this->adapter) { + print("Error initializing database adapter for " . DB_TYPE); + exit(100); + } $this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : ""); if (!$this->link) { - die("Error connecting through adapter: " . $this->adapter->last_error()); + print("Error connecting through adapter: " . $this->adapter->last_error()); + exit(101); } error_reporting($er); diff --git a/classes/db/mysqli.php b/classes/db/mysqli.php index a9689df7..5a3afdda 100644 --- a/classes/db/mysqli.php +++ b/classes/db/mysqli.php @@ -14,7 +14,8 @@ class Db_Mysqli implements IDb { return $this->link; } else { - die("Unable to connect to database (as $user to $host, database $db): " . mysqli_connect_error()); + print("Unable to connect to database (as $user to $host, database $db): " . mysqli_connect_error()); + exit(102); } } diff --git a/classes/db/pgsql.php b/classes/db/pgsql.php index 7bacfef6..e8697aba 100644 --- a/classes/db/pgsql.php +++ b/classes/db/pgsql.php @@ -21,7 +21,8 @@ class Db_Pgsql implements IDb { $this->link = pg_connect($string); if (!$this->link) { - die("Unable to connect to database (as $user to $host, database $db):" . pg_last_error()); + print("Unable to connect to database (as $user to $host, database $db):" . pg_last_error()); + exit(102); } $this->init(); diff --git a/update.php b/update.php index 2601e965..23289f1d 100755 --- a/update.php +++ b/update.php @@ -401,7 +401,9 @@ $_REQUEST['xdebug'] = 1; - update_rss_feed($feed); + $rc = is_object(update_rss_feed($feed)) ? 0 : 1; + + exit($rc); } if (isset($options["decrypt-feeds"])) { -- 2.39.5