Pārlūkot izejas kodu

CLI user-info fixes (#2292)

* CLI missing exit codes

https://github.com/FreshRSS/FreshRSS/issues/2291

* CLI catch for outdated databases

https://github.com/FreshRSS/FreshRSS/issues/2291#issuecomment-475856890
Alexandre Alapetite 7 gadi atpakaļ
vecāks
revīzija
e7a57915f9
3 mainītis faili ar 15 papildinājumiem un 3 dzēšanām
  1. 11 3
      app/Models/TagDAO.php
  2. 2 0
      cli/list-users.php
  3. 2 0
      cli/user-info.php

+ 11 - 3
app/Models/TagDAO.php

@@ -187,9 +187,17 @@ class FreshRSS_TagDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
 	public function count() {
 		$sql = 'SELECT COUNT(*) AS count FROM `' . $this->prefix . 'tag`';
 		$stm = $this->bd->prepare($sql);
-		$stm->execute();
-		$res = $stm->fetchAll(PDO::FETCH_ASSOC);
-		return $res[0]['count'];
+		if ($stm && $stm->execute()) {
+			$res = $stm->fetchAll(PDO::FETCH_ASSOC);
+			return $res[0]['count'];
+		} else {
+			$info = $stm == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $stm->errorInfo();
+			if ($this->autoUpdateDb($info)) {
+				return $this->count();
+			}
+			Minz_Log::error('SQL error TagDAO::count: ' . $info[2]);
+			return false;
+		}
 	}
 
 	public function countEntries($id) {

+ 2 - 0
cli/list-users.php

@@ -13,3 +13,5 @@ if (FreshRSS_Context::$system_conf->default_user !== ''
 foreach ($users as $user) {
 	echo $user, "\n";
 }
+
+done();

+ 2 - 0
cli/user-info.php

@@ -51,3 +51,5 @@ foreach ($users as $username) {
 			"\n";
 	}
 }
+
+done();