Browse Source

return result codes if DB connection or --debug-feed fails

Andrew Dolgov 3 years ago
parent
commit
3c11159776
4 changed files with 13 additions and 5 deletions
  1. 6 2
      classes/db.php
  2. 2 1
      classes/db/mysqli.php
  3. 2 1
      classes/db/pgsql.php
  4. 3 1
      update.php

+ 6 - 2
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);

+ 2 - 1
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);
 		}
 	}
 

+ 2 - 1
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();

+ 3 - 1
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"])) {