fix: wishlist 404 page

This commit is contained in:
grandeljay 2023-09-08 11:08:02 +02:00
parent 19eb3cc0d3
commit 6838e26f32
3 changed files with 13 additions and 11 deletions

View file

@ -770,7 +770,7 @@ class Page
<?php
}
public function errorDocument(int $statusCode, object $objectNotFound): void
public function errorDocument(int $statusCode, string $fullyQualifiedClass): void
{
http_response_code($statusCode);
@ -778,7 +778,7 @@ class Page
$this->bodyStart();
$this->navigation();
$class = new \ReflectionClass($objectNotFound);
$class = new \ReflectionClass($fullyQualifiedClass);
$className = $class->getShortName();
?>
<main>

View file

@ -46,12 +46,13 @@ class Wishlist
)
);
if (false === $wishlistQuery) {
$wishlistData = $wishlistQuery->fetch();
if (false === $wishlistData) {
return false;
}
$wishlistData = $wishlistQuery->fetch();
$wishlist = new Wishlist($wishlistData);
$wishlist = new Wishlist($wishlistData);
return $wishlist;
}

View file

@ -8,7 +8,13 @@
namespace wishthis;
$wishlist = Wishlist::getFromHash($_GET['hash']);
$wishlist = Wishlist::getFromHash($_GET['hash']);
if (false === $wishlist) {
$page = new Page(__FILE__, 'Wishlist not found');
$page->errorDocument(404, Wishlist::class);
}
$wishlist_user = User::getFromID($wishlist->getUserId());
$page = new Page(__FILE__, $wishlist->getTitle());
$page->stylesheets['wish'] = 'src/assets/css/wish.css';
@ -16,11 +22,6 @@ $page->stylesheets['wish-card'] = 'src/assets/css/wish-card.css';
$page->scripts['wish'] = 'src/assets/js/parts/wish.js';
$page->scripts['wishlist-filter-priority'] = 'src/assets/js/parts/wishlist-filter-priority.js';
$page->scripts['wishlists'] = 'src/assets/js/parts/wishlists.js';
if (false === $wishlist) {
$page->errorDocument(404, $wishlist);
}
$page->header();
$page->bodyStart();
$page->navigation();