diff --git a/index.php b/index.php index 482d9fe84330..201a21aa5183 100644 --- a/index.php +++ b/index.php @@ -49,18 +49,22 @@ OC::handleRequest(); } catch(\OC\ServiceUnavailableException $ex) { + \OC::loadDefaultEnabledAppTheme(); \OC::$server->getLogger()->logException($ex, array('app' => 'index')); //show the user a detailed error page OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); OC_Template::printExceptionErrorPage($ex); } catch (\OC\HintException $ex) { + \OC::loadDefaultEnabledAppTheme(); OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); OC_Template::printErrorPage($ex->getMessage(), $ex->getHint()); } catch (\OC\User\LoginException $ex) { + \OC::loadDefaultEnabledAppTheme(); OC_Response::setStatus(OC_Response::STATUS_FORBIDDEN); OC_Template::printErrorPage($ex->getMessage()); } catch (Exception $ex) { + \OC::loadDefaultEnabledAppTheme(); try { \OC::$server->getLogger()->logException($ex, array('app' => 'index')); @@ -76,6 +80,7 @@ echo(''); } } catch (Error $ex) { + \OC::loadDefaultEnabledAppTheme(); \OC::$server->getLogger()->logException($ex, array('app' => 'index')); OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR); OC_Template::printExceptionErrorPage($ex); diff --git a/lib/base.php b/lib/base.php index 8fe7964fab63..4b55826811ec 100644 --- a/lib/base.php +++ b/lib/base.php @@ -825,6 +825,22 @@ protected static function registerAutoloaderCache() { } } + /** + * Enables the defaultEnabled app theme + * __do not__ call this for every request, as this parses all apps info.xml + * files in order to determine which app is a default enabled theme while + * not accessing the database which might not be available. + */ + public static function loadDefaultEnabledAppTheme() { + $defaultEnabledAppTheme = \OC_App::getDefaultEnabledAppTheme(); + + if ($defaultEnabledAppTheme !== false) { + /** @var \OC\Theme\ThemeService $themeService */ + $themeService = \OC::$server->query('ThemeService'); + $themeService->setAppTheme($defaultEnabledAppTheme); + } + } + /** * Handle the request */ @@ -843,13 +859,7 @@ public static function handleRequest() { \OC::$server->getL10N('lib'), new \OC_Defaults(), \OC::$server->getLogger(), \OC::$server->getSecureRandom()); - $defaultEnabledAppTheme = \OC_App::getDefaultEnabledAppTheme(); - - if ($defaultEnabledAppTheme !== false) { - /** @var \OC\Theme\ThemeService $themeService */ - $themeService = \OC::$server->query('ThemeService'); - $themeService->setAppTheme($defaultEnabledAppTheme); - } + self::loadDefaultEnabledAppTheme(); $controller = new OC\Core\Controller\SetupController($setupHelper); $controller->run($_POST);