fix torrent searchbox id

This commit is contained in:
xiaomlove
2022-11-05 01:39:20 +08:00
parent 7d63a0586a
commit aae99b0df1
6 changed files with 36 additions and 7 deletions

View File

@@ -5727,7 +5727,12 @@ function can_access_torrent($torrent)
if (is_array($torrent) && isset($torrent['search_box_id'])) {
$searchBoxId = $torrent['search_box_id'];
} elseif (is_numeric($torrent)) {
$searchBoxId = \App\Models\Torrent::query()->findOrFail(intval($torrent), ['id', 'category'])->basic_category->mode;
$torrent = \App\Models\Torrent::query()->findOrFail(intval($torrent), ['id', 'category']);
$searchBoxId = $torrent->basic_category->mode ?? 0;
if ($searchBoxId == 0) {
do_log("[INVALID_CATEGORY], torrent: " . $torrent->id, 'error');
return false;
}
} else {
throw new \InvalidArgumentException("Unsupported argument: " . json_encode($torrent));
}