From 43952bb4a957995ee5d35bd8f42ddaf95646bcc1 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Thu, 13 Jun 2024 10:55:26 +0400 Subject: [PATCH] modifs.mineures sans commentaires --- nur_src/b/authnz/InvalidUser.php | 12 +++++++----- src/db/Capacitor.php | 4 ++-- src/db/CapacitorStorage.php | 6 +++--- src/db/mysql/MysqlStorage.php | 3 ++- src/db/sqlite/SqliteStorage.php | 3 ++- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/nur_src/b/authnz/InvalidUser.php b/nur_src/b/authnz/InvalidUser.php index e7ff359..727ad13 100644 --- a/nur_src/b/authnz/InvalidUser.php +++ b/nur_src/b/authnz/InvalidUser.php @@ -1,9 +1,14 @@ username = $username; + $this->data = []; } function isValid(): bool { @@ -59,8 +65,4 @@ class InvalidUser implements IAuthzUser { function has($key): bool { return false; } - - function get($key, $default=null) { - return $default; - } } diff --git a/src/db/Capacitor.php b/src/db/Capacitor.php index 80e132b..dfd3f1b 100644 --- a/src/db/Capacitor.php +++ b/src/db/Capacitor.php @@ -42,8 +42,8 @@ class Capacitor { $this->storage->_ensureExists($this->channel); } - function reset(): void { - $this->storage->_reset($this->channel); + function reset(bool $ensureExists=false): void { + $this->storage->_reset($this->channel, $ensureExists); } function charge($item, $func=null, ?array $args=null): int { diff --git a/src/db/CapacitorStorage.php b/src/db/CapacitorStorage.php index dc6d562..cfd0dae 100644 --- a/src/db/CapacitorStorage.php +++ b/src/db/CapacitorStorage.php @@ -127,11 +127,11 @@ abstract class CapacitorStorage { $this->_ensureExists($this->getChannel($channel)); } - abstract function _reset(CapacitorChannel $channel): void; + abstract function _reset(CapacitorChannel $channel, bool $ensureExists=false): void; /** supprimer le canal spécifié */ - function reset(?string $channel): void { - $this->_reset($this->getChannel($channel)); + function reset(?string $channel, bool $ensureExists=false): void { + $this->_reset($this->getChannel($channel), $ensureExists); } function _charge(CapacitorChannel $channel, $item, $func, ?array $args): int { diff --git a/src/db/mysql/MysqlStorage.php b/src/db/mysql/MysqlStorage.php index d6085cf..b8cb20f 100644 --- a/src/db/mysql/MysqlStorage.php +++ b/src/db/mysql/MysqlStorage.php @@ -54,12 +54,13 @@ class MysqlStorage extends CapacitorStorage { $this->_create($channel); } - function _reset(CapacitorChannel $channel): void { + function _reset(CapacitorChannel $channel, bool $ensureExists=false): void { $this->db->exec([ "drop table if exists", $channel->getTableName(), ]); $channel->setCreated(false); + if ($ensureExists) $this->_ensureExists($channel); } function close(): void { diff --git a/src/db/sqlite/SqliteStorage.php b/src/db/sqlite/SqliteStorage.php index 764325f..7e3633f 100644 --- a/src/db/sqlite/SqliteStorage.php +++ b/src/db/sqlite/SqliteStorage.php @@ -52,12 +52,13 @@ class SqliteStorage extends CapacitorStorage { $this->_create($channel); } - function _reset(CapacitorChannel $channel): void { + function _reset(CapacitorChannel $channel, bool $ensureExists=false): void { $this->db->exec([ "drop table if exists", $channel->getTableName(), ]); $channel->setCreated(false); + if ($ensureExists) $this->_ensureExists($channel); } function close(): void {