Move the check for offline mode into a dedicated method
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 6 Jul 2021 09:19:37 +0000 (11:19 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 6 Jul 2021 09:22:45 +0000 (11:22 +0200)
wcfsetup/install/files/lib/system/request/RequestHandler.class.php

index 5f3308fb9953cfd0f08e78ad7294c5120fb69df7..162d9a65c61eac2eefe66d24f5da17abc1e92f72 100644 (file)
@@ -86,34 +86,7 @@ class RequestHandler extends SingletonFactory
                 throw new IllegalLinkException();
             }
 
-            // handle offline mode
-            if (!$this->isACPRequest() && \defined('OFFLINE') && OFFLINE) {
-                if (
-                    !WCF::getSession()->getPermission('admin.general.canViewPageDuringOfflineMode')
-                    && !$this->getActiveRequest()->isAvailableDuringOfflineMode()
-                ) {
-                    if (
-                        isset($_SERVER['HTTP_X_REQUESTED_WITH'])
-                        && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')
-                    ) {
-                        throw new AJAXException(
-                            WCF::getLanguage()->getDynamicVariable('wcf.ajax.error.permissionDenied'),
-                            AJAXException::INSUFFICIENT_PERMISSIONS
-                        );
-                    } else {
-                        @\header('HTTP/1.1 503 Service Unavailable');
-                        BoxHandler::disablePageLayout();
-                        NoticeHandler::disableNotices();
-                        WCF::getTPL()->assign([
-                            'templateName' => 'offline',
-                            'templateNameApplication' => 'wcf',
-                        ]);
-                        WCF::getTPL()->display('offline');
-                    }
-
-                    exit;
-                }
-            }
+            $this->checkOfflineMode();
 
             // start request
             $this->getActiveRequest()->execute();
@@ -284,6 +257,37 @@ class RequestHandler extends SingletonFactory
         }
     }
 
+    protected function checkOfflineMode()
+    {
+        if (!$this->isACPRequest() && \defined('OFFLINE') && OFFLINE) {
+            if (
+                !WCF::getSession()->getPermission('admin.general.canViewPageDuringOfflineMode')
+                && !$this->getActiveRequest()->isAvailableDuringOfflineMode()
+            ) {
+                if (
+                    isset($_SERVER['HTTP_X_REQUESTED_WITH'])
+                    && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')
+                ) {
+                    throw new AJAXException(
+                        WCF::getLanguage()->getDynamicVariable('wcf.ajax.error.permissionDenied'),
+                        AJAXException::INSUFFICIENT_PERMISSIONS
+                    );
+                } else {
+                    @\header('HTTP/1.1 503 Service Unavailable');
+                    BoxHandler::disablePageLayout();
+                    NoticeHandler::disableNotices();
+                    WCF::getTPL()->assign([
+                        'templateName' => 'offline',
+                        'templateNameApplication' => 'wcf',
+                    ]);
+                    WCF::getTPL()->display('offline');
+                }
+
+                exit;
+            }
+        }
+    }
+
     /**
      * Redirects to the actual URL, e.g. controller has been aliased or mistyped (boardlist instead of board-list).
      *