offset can't be null, and named args
This commit is contained in:
parent
e8aadf8d23
commit
e62cdb0979
7 changed files with 14 additions and 15 deletions
|
@ -149,7 +149,7 @@ class Image
|
|||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
if ($limit!=null && $limit < 1) {
|
||||
if ($limit !== null && $limit < 1) {
|
||||
$limit = 1;
|
||||
}
|
||||
|
||||
|
@ -166,11 +166,11 @@ class Image
|
|||
/**
|
||||
* Search for an array of images
|
||||
*
|
||||
* @param String[] $tags
|
||||
* @param string[] $tags
|
||||
* @return Image[]
|
||||
*/
|
||||
#[Query(name: "posts", type: "[Post!]!", args: ["tags" => "[string!]"])]
|
||||
public static function find_images(?int $offset = 0, ?int $limit = null, array $tags=[]): array
|
||||
public static function find_images(int $offset = 0, ?int $limit = null, array $tags=[]): array
|
||||
{
|
||||
$result = self::find_images_internal($offset, $limit, $tags);
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ class Artists extends Extension
|
|||
$userIsLogged = !$user->is_anonymous();
|
||||
$userIsAdmin = $user->can(Permissions::ARTISTS_ADMIN);
|
||||
|
||||
$images = Image::find_images(0, 4, Tag::explode($artist['name']));
|
||||
$images = Image::find_images(limit: 4, tags: Tag::explode($artist['name']));
|
||||
|
||||
$this->theme->show_artist($artist, $aliases, $members, $urls, $images, $userIsLogged, $userIsAdmin);
|
||||
/*
|
||||
|
|
|
@ -166,7 +166,7 @@ class Index extends Extension
|
|||
}
|
||||
if ($event->cmd == "search") {
|
||||
$query = count($event->args) > 0 ? Tag::explode($event->args[0]) : [];
|
||||
$items = Image::find_images(0, 1000, $query);
|
||||
$items = Image::find_images(limit: 1000, tags: $query);
|
||||
foreach ($items as $item) {
|
||||
print("{$item->hash}\n");
|
||||
}
|
||||
|
|
|
@ -357,9 +357,8 @@ class Pools extends Extension
|
|||
case "import":
|
||||
if ($this->have_permission($user, $pool)) {
|
||||
$images = Image::find_images(
|
||||
0,
|
||||
$config->get_int(PoolsConfig::MAX_IMPORT_RESULTS, 1000),
|
||||
Tag::explode($_POST["pool_tag"])
|
||||
limit: $config->get_int(PoolsConfig::MAX_IMPORT_RESULTS, 1000),
|
||||
tags: Tag::explode($_POST["pool_tag"])
|
||||
);
|
||||
$this->theme->pool_result($page, $images, $pool);
|
||||
} else {
|
||||
|
|
|
@ -30,7 +30,7 @@ class RegenThumb extends Extension
|
|||
}
|
||||
if ($event->page_matches("regen_thumb/mass") && $user->can(Permissions::DELETE_IMAGE) && isset($_POST['tags'])) {
|
||||
$tags = Tag::explode(strtolower($_POST['tags']), false);
|
||||
$images = Image::find_images(0, 10000, $tags);
|
||||
$images = Image::find_images(limit: 10000, tags: $tags);
|
||||
|
||||
foreach ($images as $image) {
|
||||
$this->regenerate_thumbnail($image);
|
||||
|
|
|
@ -42,7 +42,7 @@ class XMLSitemap extends Extension
|
|||
private function handle_smaller_sitemap()
|
||||
{
|
||||
/* --- Add latest images to sitemap with higher priority --- */
|
||||
$latestimages = Image::find_images(0, 50, []);
|
||||
$latestimages = Image::find_images(limit: 50);
|
||||
if (empty($latestimages)) {
|
||||
return;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class XMLSitemap extends Extension
|
|||
$this->add_sitemap_queue($popular_tags, "monthly", "0.9" /* not sure how to deal with date here */);
|
||||
|
||||
/* --- Add latest images to sitemap with higher priority --- */
|
||||
$latestimages = Image::find_images(0, 50, []);
|
||||
$latestimages = Image::find_images(limit: 50);
|
||||
$latestimages_urllist = [];
|
||||
$latest_image = null;
|
||||
foreach ($latestimages as $arrayid => $image) {
|
||||
|
@ -107,7 +107,7 @@ class XMLSitemap extends Extension
|
|||
$this->add_sitemap_queue($other_tags, "monthly", "0.7" /* not sure how to deal with date here */);
|
||||
|
||||
/* --- Add all other images to sitemap with lower priority --- */
|
||||
$otherimages = Image::find_images(51, 10000000, []);
|
||||
$otherimages = Image::find_images(offset: 51, limit: 10000000);
|
||||
$image = null;
|
||||
foreach ($otherimages as $arrayid => $image) {
|
||||
// create url from image id's
|
||||
|
|
|
@ -300,7 +300,7 @@ class TagEdit extends Extension
|
|||
log_info("tag_edit", "Mass editing tags: '$search' -> '$replace'");
|
||||
|
||||
if (count($search_set) == 1 && count($replace_set) == 1) {
|
||||
$images = Image::find_images(0, 10, $replace_set);
|
||||
$images = Image::find_images(limit: 10, tags: $replace_set);
|
||||
if (count($images) == 0) {
|
||||
log_info("tag_edit", "No images found with target tag, doing in-place rename");
|
||||
$database->execute(
|
||||
|
@ -329,7 +329,7 @@ class TagEdit extends Extension
|
|||
$search_forward[] = "id<$last_id";
|
||||
}
|
||||
|
||||
$images = Image::find_images(0, 100, $search_forward);
|
||||
$images = Image::find_images(limit: 100, tags: $search_forward);
|
||||
if (count($images) == 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ class TagEdit extends Extension
|
|||
$search_forward[] = "id<$last_id";
|
||||
}
|
||||
|
||||
$images = Image::find_images(0, 100, $search_forward);
|
||||
$images = Image::find_images(limit: 100, tags: $search_forward);
|
||||
if (count($images) == 0) {
|
||||
break;
|
||||
}
|
||||
|
|
Reference in a new issue