+ if (!empty($configCache->get('system', 'maintenance')) ||
+ // Don't use Config or Configuration here because we're possibly BEFORE initializing the Configuration,
+ // so this could lead to a dependency circle
+ !empty($database->selectFirst('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])['v'])) {
+ return new Mode($mode);
+ }
+
+ $mode |= Mode::MAINTENANCEDISABLED;
+
+ return new Mode($mode, $this->isBackend, $this->isAjax, $this->isMobile, $this->isTablet);
+ }
+
+ /**
+ * Checks if the site is called via a backend process
+ *
+ * @param bool $isBackend True, if the call is from a backend script (daemon, worker, ...)
+ * @param ModuleController $module The pre-loaded module (just name, not class!)
+ * @param array $server The $_SERVER variable
+ * @param MobileDetect $mobileDetect The mobile detection library
+ *
+ * @return Mode returns the determined mode
+ */
+ public function determineRunMode(bool $isBackend, ModuleController $module, array $server, MobileDetect $mobileDetect)
+ {
+ foreach (self::BACKEND_CONTENT_TYPES as $type) {
+ if (strpos(strtolower($server['HTTP_ACCEPT'] ?? ''), $type) !== false) {
+ $isBackend = true;
+ }