Jelajahi Sumber

Fix CLI bug regarding an empty user (#2646)

Fix https://github.com/FreshRSS/FreshRSS/issues/2644
Alexandre Alapetite 6 tahun lalu
induk
melakukan
f1d1d46651
3 mengubah file dengan 5 tambahan dan 5 penghapusan
  1. 1 1
      cli/_cli.php
  2. 1 1
      cli/user-info.php
  3. 3 3
      lib/Minz/ModelPdo.php

+ 1 - 1
cli/_cli.php

@@ -37,7 +37,7 @@ function cliInitUser($username) {
 	if (FreshRSS_Context::$user_conf == null) {
 		fail('FreshRSS error: invalid configuration for user: ' . $username . "\n");
 	}
-	new Minz_ModelPdo($username);
+	Minz_Session::_param('currentUser', $username);
 
 	return $username;
 }

+ 1 - 1
cli/user-info.php

@@ -43,7 +43,7 @@ if (array_key_exists('header', $options)) {
 foreach ($users as $username) {
 	$username = cliInitUser($username);
 
-	$catDAO = FreshRSS_Factory::createCategoryDao();
+	$catDAO = FreshRSS_Factory::createCategoryDao($username);
 	$feedDAO = FreshRSS_Factory::createFeedDao($username);
 	$entryDAO = FreshRSS_Factory::createEntryDao($username);
 	$tagDAO = FreshRSS_Factory::createTagDao($username);

+ 3 - 3
lib/Minz/ModelPdo.php

@@ -28,13 +28,13 @@ class Minz_ModelPdo {
 		if ($currentUser === null) {
 			$currentUser = Minz_Session::param('currentUser');
 		}
-		if ($currentUser == '') {
-			throw new Minz_PDOConnectionException('Current user must not be empty!', '', Minz_Exception::ERROR);
-		}
 		if ($currentPdo != null) {
 			$this->pdo = $currentPdo;
 			return;
 		}
+		if ($currentUser == '') {
+			throw new Minz_PDOConnectionException('Current user must not be empty!', '', Minz_Exception::ERROR);
+		}
 		if (self::$usesSharedPdo && self::$sharedPdo != null &&
 			($currentUser == '' || $currentUser === self::$sharedCurrentUser)) {
 			$this->pdo = self::$sharedPdo;