From 14086a0ed6181a0ff4496ee2e56f4fb70bfe18d5 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sun, 4 May 2025 19:40:57 +0300 Subject: [PATCH] misc: Minor improvements (#1897) --- library/includes/functions.php | 5 +---- src/Censor.php | 5 +---- src/Legacy/BBCode.php | 19 ++++++++----------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/library/includes/functions.php b/library/includes/functions.php index 8bc2933ef..bf055495b 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -2154,10 +2154,7 @@ function getBanInfo(?int $userId = null): ?array global $datastore; // Get bans info from datastore - if (!$bans = $datastore->get('ban_list')) { - $datastore->update('ban_list'); - $bans = $datastore->get('ban_list'); - } + $bans = $datastore->get('ban_list'); if (!isset($userId)) { return $bans; diff --git a/src/Censor.php b/src/Censor.php index b28aec723..5b4d00a73 100644 --- a/src/Censor.php +++ b/src/Censor.php @@ -41,10 +41,7 @@ class Censor } // Get censored words - if (!$censoredWords = $datastore->get('censor')) { - $datastore->update('censor'); - $censoredWords = $datastore->get('censor'); - } + $censoredWords = $datastore->get('censor'); foreach ($censoredWords as $word) { $this->words[] = '#(?smilies = $datastore->get('smile_replacements')) { - $datastore->update('smile_replacements'); - $this->smilies = $datastore->get('smile_replacements'); - } + $this->smilies = $datastore->get('smile_replacements'); - if (defined('IN_ADMIN')) { - foreach ($this->smilies['repl'] as &$smile) { - $smile = preg_replace('/src="([^"]+)"/', 'src="./../$1"', $smile); + if (!empty($this->smilies)) { + if (defined('IN_ADMIN')) { + foreach ($this->smilies['repl'] as &$smile) { + $smile = preg_replace('/src="([^"]+)"/', 'src="./../$1"', $smile); + } + unset($smile); } - unset($smile); - } - if ($this->smilies) { /** @noinspection NestedPositiveIfStatementsInspection */ if ($parsed_text = preg_replace($this->smilies['orig'], $this->smilies['repl'], $text)) { return $parsed_text;