A free, self-hostable news aggregator…
Windows: release SQLite (#6285)
Alexandre Alapetite90fbb524ce5a
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.phpindex f23ae008e..1eb7f2b84 100644--- a/app/Controllers/userController.php+++ b/app/Controllers/userController.php@@ -389,8 +389,10 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {$ok &= is_dir($user_data);if ($ok) {FreshRSS_fever_Util::deleteKey($username);+ Minz_ModelPdo::$usesSharedPdo = false;$oldUserDAO = FreshRSS_Factory::createUserDao($username);$ok &= $oldUserDAO->deleteUser();+ Minz_ModelPdo::$usesSharedPdo = true;$ok &= recursive_unlink($user_data);$filenames = glob(PSHB_PATH . '/feeds/*/' . $username . '.txt');if (!empty($filenames)) {diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.phpindex 1f85b5fe9..9ce0d7bd7 100644--- a/app/Models/UserDAO.php+++ b/app/Models/UserDAO.php@@ -32,6 +32,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo {$ok = $this->pdo->exec($GLOBALS['SQL_DROP_TABLES']) !== false;if ($ok) {+ $this->close();return true;} else {$info = $this->pdo->errorInfo();diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.phpindex 69a619833..f7a6994c7 100644--- a/lib/Minz/ModelPdo.php+++ b/lib/Minz/ModelPdo.php@@ -18,7 +18,7 @@ class Minz_ModelPdo {private static ?Minz_Pdo $sharedPdo = null;- private static ?string $sharedCurrentUser;+ private static string $sharedCurrentUser = '';protected Minz_Pdo $pdo;@@ -78,7 +78,9 @@ class Minz_ModelPdo {$db['user'], Minz_Exception::ERROR);}- self::$sharedPdo = $this->pdo;+ if (self::$usesSharedPdo) {+ self::$sharedPdo = $this->pdo;+ }}/**@@ -97,7 +99,7 @@ class Minz_ModelPdo {$this->pdo = $currentPdo;return;}- if ($currentUser == '') {+ if ($currentUser == null) {throw new Minz_PDOConnectionException('Current user must not be empty!', '', Minz_Exception::ERROR);}if (self::$usesSharedPdo && self::$sharedPdo !== null && $currentUser === self::$sharedCurrentUser) {@@ -106,7 +108,9 @@ class Minz_ModelPdo {return;}$this->current_user = $currentUser;- self::$sharedCurrentUser = $currentUser;+ if (self::$usesSharedPdo) {+ self::$sharedCurrentUser = $currentUser;+ }$ex = null;//Attempt a few times to connect to database@@ -155,6 +159,15 @@ class Minz_ModelPdo {self::$sharedCurrentUser = '';}+ public function close(): void {+ if ($this->current_user === self::$sharedCurrentUser) {+ self::clean();+ }+ $this->current_user = '';+ unset($this->pdo);+ gc_collect_cycles();+ }+/*** @param array<string,int|string|null> $values* @phpstan-return ($mode is PDO::FETCH_ASSOC ? array<array<string,int|string|null>>|null : array<int|string|null>|null)