From 29ee5aeb1dc3976f231ee44ab0b9bbfbf45648d6 Mon Sep 17 00:00:00 2001 From: Lorenzo Yario Date: Sun, 22 Dec 2024 14:05:42 -0600 Subject: [PATCH 1/3] For 7.4 compatibility --- inc/mod/auth.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/mod/auth.php b/inc/mod/auth.php index f6a65db2..43b5e8fc 100644 --- a/inc/mod/auth.php +++ b/inc/mod/auth.php @@ -10,7 +10,7 @@ use Vichan\Functions\Net; defined('TINYBOARD') or exit; // create a hash/salt pair for validate logins -function mkhash(string $username, ?string $password, mixed $salt = false): array|string { +function mkhash(string $username, $password = null, $salt = false) { global $config; if (!$salt) { @@ -79,7 +79,7 @@ function calc_cookie_name(bool $is_https, bool $is_path_jailed, string $base_nam } } -function login(string $username, string $password): array|false { +function login(string $username, string $password) { global $mod, $config; $query = prepare("SELECT `id`, `type`, `boards`, `password`, `version` FROM ``mods`` WHERE BINARY `username` = :username"); From f3f7c0c75c0fc61ad51616969a4f78b9a1bf2a66 Mon Sep 17 00:00:00 2001 From: Lorenzo Yario Date: Sun, 22 Dec 2024 14:13:37 -0600 Subject: [PATCH 2/3] 7.4 compatibility --- inc/lock.php | 124 ++++++++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 66 deletions(-) diff --git a/inc/lock.php b/inc/lock.php index 5a83562a..9b1522c4 100644 --- a/inc/lock.php +++ b/inc/lock.php @@ -1,84 +1,76 @@ f = $fd; + } - function __construct($fd) { - $this->f = $fd; - } + public function get(bool $nonblock = false) { + $wouldblock = false; + flock($this->f, LOCK_SH | ($nonblock ? LOCK_NB : 0), $wouldblock); + if ($nonblock && $wouldblock) { + return false; + } + return $this; + } - public function get(bool $nonblock = false): Lock|false { - $wouldblock = false; - flock($this->f, LOCK_SH | ($nonblock ? LOCK_NB : 0), $wouldblock); - if ($nonblock && $wouldblock) { - return false; - } - return $this; - } + public function get_ex(bool $nonblock = false) { + $wouldblock = false; + flock($this->f, LOCK_EX | ($nonblock ? LOCK_NB : 0), $wouldblock); + if ($nonblock && $wouldblock) { + return false; + } + return $this; + } - public function get_ex(bool $nonblock = false): Lock|false { - $wouldblock = false; - flock($this->f, LOCK_EX | ($nonblock ? LOCK_NB : 0), $wouldblock); - if ($nonblock && $wouldblock) { - return false; - } - return $this; - } + public function free() { + flock($this->f, LOCK_UN); + return $this; + } + }; + } - public function free(): Lock { - flock($this->f, LOCK_UN); - return $this; - } - }; - } + public static function none() { + return new class() implements Lock { + public function get(bool $nonblock = false) { + return $this; + } - /** - * No-op. Can be used for mocking. - */ - public static function none(): Lock|false { - return new class() implements Lock { - public function get(bool $nonblock = false): Lock|false { - return $this; - } + public function get_ex(bool $nonblock = false) { + return $this; + } - public function get_ex(bool $nonblock = false): Lock|false { - return $this; - } + public function free() { + return $this; + } + }; + } - public function free(): Lock { - return $this; - } - }; - } - - public static function get_lock(array $config, string $key): Lock|false { - if ($config['lock']['enabled'] == 'fs') { - return self::filesystem($key); - } else { - return self::none(); - } - } + public static function get_lock(array $config, string $key) { + if ($config['lock']['enabled'] == 'fs') { + return self::filesystem($key); + } else { + return self::none(); + } + } } interface Lock { - // Get a shared lock - public function get(bool $nonblock = false): Lock|false; + public function get(bool $nonblock = false); - // Get an exclusive lock - public function get_ex(bool $nonblock = false): Lock|false; + public function get_ex(bool $nonblock = false); - // Free a lock - public function free(): Lock; + public function free(); } From 2466a3d859c2dc22d1a486ee9616795a36d6bd2e Mon Sep 17 00:00:00 2001 From: Lorenzo Yario Date: Sun, 22 Dec 2024 14:15:40 -0600 Subject: [PATCH 3/3] 7.4 compatibility --- inc/queue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/queue.php b/inc/queue.php index a5905c84..7ba255f3 100644 --- a/inc/queue.php +++ b/inc/queue.php @@ -73,7 +73,7 @@ class Queues { }; } - public static function get_queue(array $config, string $name): Queue|false { + public static function get_queue(array $config, string $name) { if (!isset(self::$queues[$name])) { if ($config['queue']['enabled'] == 'fs') { $lock = Locks::get_lock($config, $name);