瀏覽代碼

Fix crash during update of existing install (#6205)

fix https://github.com/FreshRSS/FreshRSS/issues/6204
Mess due to https://github.com/FreshRSS/FreshRSS/pull/5511
Alexandre Alapetite 2 年之前
父節點
當前提交
cf29ca19c0
共有 3 個文件被更改,包括 14 次插入6 次删除
  1. 6 2
      app/Models/SystemConfiguration.php
  2. 6 2
      app/Models/UserConfiguration.php
  3. 2 2
      app/install.php

+ 6 - 2
app/Models/SystemConfiguration.php

@@ -30,9 +30,13 @@ declare(strict_types=1);
  */
 final class FreshRSS_SystemConfiguration extends Minz_Configuration {
 
-	/** @throws Minz_ConfigurationNamespaceException */
+	/** @throws Minz_FileNotExistException */
 	public static function init(string $config_filename, ?string $default_filename = null): FreshRSS_SystemConfiguration {
 		parent::register('system', $config_filename, $default_filename);
-		return parent::get('system');
+		try {
+			return parent::get('system');
+		} catch (Minz_ConfigurationNamespaceException $ex) {
+			FreshRSS::killApp($ex->getMessage());
+		}
 	}
 }

+ 6 - 2
app/Models/UserConfiguration.php

@@ -75,10 +75,14 @@ declare(strict_types=1);
 final class FreshRSS_UserConfiguration extends Minz_Configuration {
 	use FreshRSS_FilterActionsTrait;
 
-	/** @throws Minz_ConfigurationNamespaceException */
+	/** @throws Minz_FileNotExistException */
 	public static function init(string $config_filename, ?string $default_filename = null): FreshRSS_UserConfiguration {
 		parent::register('user', $config_filename, $default_filename);
-		return parent::get('user');
+		try {
+			return parent::get('user');
+		} catch (Minz_ConfigurationNamespaceException $ex) {
+			FreshRSS::killApp($ex->getMessage());
+		}
 	}
 
 	/**

+ 2 - 2
app/install.php

@@ -293,7 +293,7 @@ function freshrss_already_installed(): bool {
 	$system_conf = null;
 	try {
 		$system_conf = FreshRSS_SystemConfiguration::init($conf_path);
-	} catch (Minz_ConfigurationNamespaceException $e) {
+	} catch (Minz_FileNotExistException $e) {
 		return false;
 	}
 
@@ -301,7 +301,7 @@ function freshrss_already_installed(): bool {
 	$current_user = $system_conf->default_user;
 	try {
 		FreshRSS_UserConfiguration::init(USERS_PATH . '/' . $current_user . '/config.php');
-	} catch (Minz_ConfigurationNamespaceException $e) {
+	} catch (Minz_FileNotExistException $e) {
 		return false;
 	}