aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-04-21 16:25:37 +0200
committerGravatar GitHub <noreply@github.com> 2024-04-21 16:25:37 +0200
commit90fbb524ce5a8c5a87d808278289b013300b0aba (patch)
treeacc592a51517eaa60a09388d2ed058ad82aeb502 /lib
parentb37404cce7a73d1ca52405a70dbe8929135584a3 (diff)
Windows: release SQLite (#6285)
* Windows: release SQLite fix https://github.com/FreshRSS/FreshRSS/issues/6275 * Do not use sharedPdo for deleting user * Case of same user * Help PHPStan
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/ModelPdo.php21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php
index 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)