more handling

This commit is contained in:
Shish 2021-11-10 19:42:01 +00:00
parent 58db685b29
commit 52fa31df3e
2 changed files with 8 additions and 5 deletions

View file

@ -30,6 +30,8 @@ class RSSImages extends Extension
try {
$images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms);
$this->do_rss($images, $search_terms, $page_number);
} catch (SearchTermParseException $stpe) {
$this->theme->display_error(400, "Search parse error", $pde->error);
} catch (PermissionDeniedException $pde) {
$this->theme->display_error(403, "Permission denied", $pde->error);
}

View file

@ -385,12 +385,13 @@ class UserPage extends Extension
$matches = [];
if (preg_match(self::USER_SEARCH_REGEX, $event->term, $matches)) {
try {
$user_id = User::name_to_id($matches[2]);
$event->add_querylet(new Querylet("images.owner_id ${matches[1]}= $user_id"));
} catch (UserDoesNotExist $e) {
$event->add_querylet(new Querylet("1=0"));
$duser = User::by_name($matches[1]);
if (is_null($duser)) {
throw new SearchTermParseException(
"Can't find the user named ".html_escape($matches[1])
);
}
$event->add_querylet(new Querylet("images.owner_id ${matches[1]}= {$duser->id}"));
} elseif (preg_match(self::USER_ID_SEARCH_REGEX, $event->term, $matches)) {
$user_id = int_escape($matches[2]);
$event->add_querylet(new Querylet("images.owner_id ${matches[1]}= $user_id"));