diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 80a0f827..3a617ab0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,7 @@ Changelog - Fix #512: Validate `from` pagination cursor to prevent unbounded conversation loading - Fix #514: Optimize pin icon rendering on the inbox message list - Fix #515: Reduce database queries in the inbox list, conversation loading, reply action and unread count polling +- Enh: Automated code refactoring for HumHub 1.18.1 using Rector 3.3.12 (July 16, 2026) ---------------------- diff --git a/models/Message.php b/models/Message.php index 482e1194..0734c848 100644 --- a/models/Message.php +++ b/models/Message.php @@ -189,9 +189,7 @@ public function getUsersCount(): int return count($this->users); } - if ($this->_userCount === null) { - $this->_userCount = $this->getUsers()->count(); - } + $this->_userCount ??= $this->getUsers()->count(); return $this->_userCount; } @@ -283,13 +281,11 @@ public function getLastEntry(): ?MessageEntry return $this->lastEntryRelation; } - if ($this->_lastEntry === null) { - $this->_lastEntry = MessageEntry::find() - ->where(['message_id' => $this->id]) - ->orderBy('created_at DESC') - ->limit(1) - ->one(); - } + $this->_lastEntry ??= MessageEntry::find() + ->where(['message_id' => $this->id]) + ->orderBy('created_at DESC') + ->limit(1) + ->one(); return $this->_lastEntry; } diff --git a/models/UserMessage.php b/models/UserMessage.php index 61db924f..c859b815 100644 --- a/models/UserMessage.php +++ b/models/UserMessage.php @@ -135,9 +135,7 @@ public static function invalidateNewMessageCountCache($userId): void public static function findByUser($userId = null) { - if ($userId === null) { - $userId = Yii::$app->user->id; - } + $userId ??= Yii::$app->user->id; if ($userId instanceof User) { $userId = $userId->id; diff --git a/search/SearchProvider.php b/search/SearchProvider.php index 5e5024ed..ac94620d 100644 --- a/search/SearchProvider.php +++ b/search/SearchProvider.php @@ -90,9 +90,7 @@ public function getResults(int $maxResults): array */ public function getService(): MetaSearchService { - if ($this->service === null) { - $this->service = new MetaSearchService($this); - } + $this->service ??= new MetaSearchService($this); return $this->service; } diff --git a/widgets/InboxMessagePreview.php b/widgets/InboxMessagePreview.php index 7e05ed34..03d6be18 100644 --- a/widgets/InboxMessagePreview.php +++ b/widgets/InboxMessagePreview.php @@ -53,9 +53,7 @@ private function getOptions(): array public function getMessage(): Message { - if ($this->_message === null) { - $this->_message = $this->userMessage->message; - } + $this->_message ??= $this->userMessage->message; return $this->_message; }