Suppress notices during maintenance or on `PermissionDeniedException
authorAlexander Ebert <ebert@woltlab.com>
Thu, 8 Jun 2017 10:26:15 +0000 (12:26 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 8 Jun 2017 10:26:15 +0000 (12:26 +0200)
See #2294

wcfsetup/install/files/lib/system/exception/PermissionDeniedException.class.php
wcfsetup/install/files/lib/system/notice/NoticeHandler.class.php
wcfsetup/install/files/lib/system/request/RequestHandler.class.php

index 50d569acc663ee497b50b09bce57111abe65a808..2a6435f11f06ed2762da04477a16df12ebe441d3 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\system\exception;
 use wcf\system\box\BoxHandler;
+use wcf\system\notice\NoticeHandler;
 use wcf\system\session\SessionHandler;
 use wcf\system\WCF;
 use wcf\system\WCFACP;
@@ -28,6 +29,7 @@ class PermissionDeniedException extends UserException {
        public function show() {
                if (!class_exists(WCFACP::class, false)) {
                        BoxHandler::disablePageLayout();
+                       NoticeHandler::disableNotices();
                }
                SessionHandler::getInstance()->disableTracking();
                
index 6a6326a9e351a9fb593e515034a14474e520e32f..782663495ae1cc8762f3ecb7ea60769bd2758824 100644 (file)
@@ -19,6 +19,12 @@ class NoticeHandler extends SingletonFactory {
         */
        protected $notices = [];
        
+       /**
+        * suppresses display of notices
+        * @var boolean
+        */
+       protected static $disableNotices = false;
+       
        /**
         * @inheritDoc
         */
@@ -32,6 +38,10 @@ class NoticeHandler extends SingletonFactory {
         * @return      Notice[]
         */
        public function getVisibleNotices() {
+               if (self::$disableNotices) {
+                       return [];
+               }
+               
                $notices = [];
                foreach ($this->notices as $notice) {
                        if ($notice->isDismissed()) continue;
@@ -48,4 +58,11 @@ class NoticeHandler extends SingletonFactory {
                
                return $notices;
        }
+       
+       /**
+        * Disables the display of notices for the active page.
+        */
+       public static function disableNotices() {
+               self::$disableNotices = true;
+       }
 }
index db7514d7008b76cf8b0c35f6c6cbc275b26e9335..8525b4efdc69e65024ded7d3ccb73bc386cf63b6 100644 (file)
@@ -6,6 +6,7 @@ use wcf\system\exception\AJAXException;
 use wcf\system\exception\IllegalLinkException;
 use wcf\system\exception\NamedUserException;
 use wcf\system\exception\SystemException;
+use wcf\system\notice\NoticeHandler;
 use wcf\system\SingletonFactory;
 use wcf\system\WCF;
 use wcf\util\FileUtil;
@@ -79,6 +80,7 @@ class RequestHandler extends SingletonFactory {
                                        else {
                                                @header('HTTP/1.1 503 Service Unavailable');
                                                BoxHandler::disablePageLayout();
+                                               NoticeHandler::disableNotices();
                                                WCF::getTPL()->assign([
                                                        'templateName' => 'offline',
                                                        'templateNameApplication' => 'wcf'