wtf php, array_filter() will return an array with gaps in it...
This commit is contained in:
@@ -146,7 +146,7 @@ class Search
|
|||||||
/**
|
/**
|
||||||
* Count the number of image results for a given search
|
* Count the number of image results for a given search
|
||||||
*
|
*
|
||||||
* @param string[] $tags
|
* @param list<string> $tags
|
||||||
*/
|
*/
|
||||||
public static function count_images(array $tags = []): int
|
public static function count_images(array $tags = []): int
|
||||||
{
|
{
|
||||||
|
@@ -197,6 +197,7 @@ class DanbooruApi extends Extension
|
|||||||
$tags = array_filter($tags, static function ($element) {
|
$tags = array_filter($tags, static function ($element) {
|
||||||
return $element !== "*";
|
return $element !== "*";
|
||||||
});
|
});
|
||||||
|
$tags = array_values($tags); // reindex array because count_images() expects a 0-based array
|
||||||
$count = Search::count_images($tags);
|
$count = Search::count_images($tags);
|
||||||
$results = Search::find_images(max($start, 0), min($limit, 100), $tags);
|
$results = Search::find_images(max($start, 0), min($limit, 100), $tags);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user