From: Tim Düsterhus Date: Thu, 8 Nov 2012 21:29:48 +0000 (+0100) Subject: Fix error in case the database is not available X-Git-Tag: 2.0.0_Beta_1~790^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=96e82a733ca0afd72efc025f52674ff71325413c;p=GitHub%2FWoltLab%2FWCF.git Fix error in case the database is not available --- diff --git a/wcfsetup/install/files/lib/system/SingletonFactory.class.php b/wcfsetup/install/files/lib/system/SingletonFactory.class.php index cb592a7e80..27a26f92ee 100644 --- a/wcfsetup/install/files/lib/system/SingletonFactory.class.php +++ b/wcfsetup/install/files/lib/system/SingletonFactory.class.php @@ -58,4 +58,15 @@ abstract class SingletonFactory { return self::$__singletonObjects[$className]; } + + /** + * Returns whether this singleton is already initialized. + * + * @return boolean + */ + public static final function isSingletonInitialized() { + $className = get_called_class(); + + return isset(self::$__singletonObjects[$className]); + } } diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index e100988299..775492cd1e 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -123,10 +123,13 @@ class WCF { * Replacement of the "__destruct()" method. * Seems that under specific conditions (windows) the destructor is not called automatically. * So we use the php register_shutdown_function to register an own destructor method. - * Flushs the output, updates the session and executes the shutdown queries. + * Flushs the output, closes caches and updates the session. */ public static function destruct() { - // flush ouput + // database has to be initialized + if (!is_object(self::$dbObj)) return; + + // flush output if (ob_get_level() && ini_get('output_handler')) { ob_flush(); } @@ -140,7 +143,7 @@ class WCF { } // close cache source - if (is_object(CacheHandler::getInstance()) && is_object(CacheHandler::getInstance()->getCacheSource())) { + if (CacheHandler::isSingletonInitialized() && is_object(CacheHandler::getInstance()) && is_object(CacheHandler::getInstance()->getCacheSource())) { CacheHandler::getInstance()->getCacheSource()->close(); }