diff --git a/CHANGELOG.md b/CHANGELOG.md index 421381d..5a4c695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - **Cron:** Fix components lost in CronTabProcess (1ced4bf) - **Redis:** Fix wrong type of Redis call function hMset() to hMSet() (a163150) - **Response:** Fix Response header and status not clean (82977ea) +- **Response:** Fix Header `Set-Cookie` header don't clean (144eef7) - **Route:** Fix user can access maintenance page even not on maintenance status (b29c2f6) - **Tracker:** Fix typo in TrackerController (323c8ec) - **Tracker:** Disable `retry in` feature by default (4b1f767) diff --git a/application/Entity/User/User.php b/application/Entity/User/User.php index e6dc684..3ef6757 100644 --- a/application/Entity/User/User.php +++ b/application/Entity/User/User.php @@ -397,6 +397,11 @@ public function getInvitees() }); } + public function updateBookmarkList() { + $this->removeCacheValue('bookmark_list'); + $this->getBookmarkList(); + } + public function getBookmarkList() { return $this->getCacheValue('bookmark_list', function () { diff --git a/application/Models/Api/v1/Form/TorrentsForm.php b/application/Models/Api/v1/Form/TorrentsForm.php index f546d97..ddc66f0 100644 --- a/application/Models/Api/v1/Form/TorrentsForm.php +++ b/application/Models/Api/v1/Form/TorrentsForm.php @@ -26,7 +26,7 @@ public function updateRecord() app()->pdo->prepare('DELETE FROM `bookmarks` WHERE `id` = :bid')->bindParams([ 'bid' => $bookmark_exist ])->execute(); - app()->redis->del('User:' . app()->auth->getCurUser()->getId() . ':bookmark_array'); + app()->auth->getCurUser()->updateBookmarkList(); return ['msg' => 'Delete Old Bookmark Success', 'result' => 'deleted']; } else { // Add new record @@ -34,7 +34,7 @@ public function updateRecord() 'uid' => app()->auth->getCurUser()->getId(), 'tid' => $this->getInput('id') ])->execute(); - app()->redis->del('User:' . app()->auth->getCurUser()->getId() . ':bookmark_array'); + app()->auth->getCurUser()->updateBookmarkList(); return ['msg' => 'Add New Bookmark Success', 'result' => 'added']; } diff --git a/application/Models/Form/Torrents/SearchForm.php b/application/Models/Form/Torrents/SearchForm.php index d808c75..d6678a4 100644 --- a/application/Models/Form/Torrents/SearchForm.php +++ b/application/Models/Form/Torrents/SearchForm.php @@ -115,6 +115,14 @@ private function getSearchField(): array } } + // Favour + $favour = $this->getInput('favour'); + if ($favour == 1) { // bookmarked in favour + $fields[] = ['AND `id` IN (SELECT `tid` FROM `bookmarks` WHERE `uid` = :uid)', 'params' => ['uid' => app()->auth->getCurUser()->getId()]]; + } elseif ($favour == 2) { // not bookmarked in favour + $fields[] = ['AND `id` NOT IN (SELECT `tid` FROM `bookmarks` WHERE `uid` = :uid)', 'params' => ['uid' => app()->auth->getCurUser()->getId()]]; + } + // TODO we may not use `&search_area=` to search in non-title/subtitle/descr field, Use sep `&ownerid=` , `&doubanid=` instead. $searchstr = $this->getInput('search'); diff --git a/framework/Utils/ClassValueCacheUtils.php b/framework/Utils/ClassValueCacheUtils.php index 630779d..e30c4ce 100644 --- a/framework/Utils/ClassValueCacheUtils.php +++ b/framework/Utils/ClassValueCacheUtils.php @@ -27,4 +27,9 @@ final protected function getCacheValue($key, $closure) } return $this->$key; } + + final protected function removeCacheValue($key) { + unset($this->$key); + app()->redis->hDel($this->getCacheNameSpace(), $key); + } } diff --git a/templates/helper/torrent_table.php b/templates/helper/torrent_table.php index 58a15bf..4cb6b5c 100644 --- a/templates/helper/torrent_table.php +++ b/templates/helper/torrent_table.php @@ -29,7 +29,7 @@
- getPagerData() as $torrent): /** @var \App\Entity\Torrent $torrent */ ?> + getPagerData() as $torrent): /** @var \App\Entity\Torrent\Torrent $torrent */ ?>