From 6bde7457e74d3f72eaef6557a58efd02e706cf11 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 19 Jan 2024 18:01:50 +0000 Subject: [PATCH] wtf php, array_filter() will return an array with gaps in it... --- core/imageboard/search.php | 2 +- ext/danbooru_api/main.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/imageboard/search.php b/core/imageboard/search.php index 7e153fe8..b71803fc 100644 --- a/core/imageboard/search.php +++ b/core/imageboard/search.php @@ -146,7 +146,7 @@ class Search /** * Count the number of image results for a given search * - * @param string[] $tags + * @param list $tags */ public static function count_images(array $tags = []): int { diff --git a/ext/danbooru_api/main.php b/ext/danbooru_api/main.php index e950ee2a..d29a3eee 100644 --- a/ext/danbooru_api/main.php +++ b/ext/danbooru_api/main.php @@ -197,6 +197,7 @@ class DanbooruApi extends Extension $tags = array_filter($tags, static function ($element) { return $element !== "*"; }); + $tags = array_values($tags); // reindex array because count_images() expects a 0-based array $count = Search::count_images($tags); $results = Search::find_images(max($start, 0), min($limit, 100), $tags); }