page: silence object warnings on missing pages
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 28 Oct 2019 04:02:49 +0000 (05:02 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 9 Nov 2019 06:08:13 +0000 (07:08 +0100)
page.inc.php
page.php

index b7a7e77ab2e01764c4ba1ce43faf3364d26ecc2d..7a54bf7424b59603c98509a65ae83da5962bcf1b 100644 (file)
@@ -7,7 +7,7 @@ print "<header>\n";
 ob_start();
 include 'menu.inc.html';
 ob_start();
-if ($User) {
+if (!empty($User)) {
        print '<div class="login"><p>';
        printf('<span>Ingelogd: <b><a href="%s">%s</a></b></span>', '/login', $User->login);
        if ($User->admin("edit $Page$Args")) {
@@ -44,7 +44,7 @@ register_shutdown_function(function () {
        print "</footer>\n";
 
        global $User, $Page, $Args;
-       if ($User and $User->admin("edit $Page$Args")) {
+       if (!empty($User) and $User->admin("edit $Page$Args")) {
                $ckesrc = '/lib/ckeditor'; # local install
                if (!file_exists(DOCROOT . $ckesrc)) {
                        $ckesrc = '//cdn.ckeditor.com/4.7.3/full-all'; # remote fallback
index f02544bd0b06dbd7add643d19a17e02bbdca69c2..1488f1c5904f7a637208305037bfd73bb02e7861 100644 (file)
--- a/page.php
+++ b/page.php
@@ -84,6 +84,10 @@ set_include_path(implode(PATH_SEPARATOR, [ DOCROOT, __DIR__ ]));
 function fail($error)
 {
        http_response_code(500);
+       if (!isset($Article)) {
+               $Article = new ArchiveArticle(NULL);
+               $Article->title = 'Fout';
+       }
        include_once 'page.inc.php';
        ob_start();
        require_once '500.inc.html';