Fix empty wish title

This commit is contained in:
Jay Trees 2022-03-10 15:47:52 +01:00
parent 5e3eee3ed0
commit 23b724bfdc
2 changed files with 12 additions and 2 deletions

View file

@ -212,4 +212,14 @@ class Wish
return $html; return $html;
} }
public function getTitle(): string
{
$title = $this->title
?: $this->description
?: $this->url
?: $this->id;
return $title;
}
} }

View file

@ -11,7 +11,7 @@ use wishthis\{Page, Wish};
$userIsAuthenticated = false; $userIsAuthenticated = false;
$wish = new Wish($_GET['id'], false); $wish = new Wish($_GET['id'], false);
$page = new Page(__FILE__, $wish->title); $page = new Page(__FILE__, $wish->getTitle());
if ('POST' === $_SERVER['REQUEST_METHOD'] && count($_POST) >= 0) { if ('POST' === $_SERVER['REQUEST_METHOD'] && count($_POST) >= 0) {
$wish_id = $_POST['wish_id']; $wish_id = $_POST['wish_id'];
@ -31,7 +31,7 @@ if ('POST' === $_SERVER['REQUEST_METHOD'] && count($_POST) >= 0) {
WHERE `id` = ' . $wish_id . ';'); WHERE `id` = ' . $wish_id . ';');
$wish = new Wish($_GET['id'], false); $wish = new Wish($_GET['id'], false);
$page = new Page(__FILE__, $wish->title); $page = new Page(__FILE__, $wish->getTitle());
$page->messages[] = Page::success('Wish successfully updated.', 'Success'); $page->messages[] = Page::success('Wish successfully updated.', 'Success');
} }