diff --git a/kernel/classes/ezscript.php b/kernel/classes/ezscript.php index ace63f09376..2e6ef35f712 100644 --- a/kernel/classes/ezscript.php +++ b/kernel/classes/ezscript.php @@ -235,8 +235,11 @@ function startup() */ function initialize() { - if( ob_get_length() != 0 ) - ob_end_clean(); + if ( !ezpKernel::hasInstance() ) + { + if ( ob_get_length() != 0 ) + ob_end_clean(); + } // Initialize text codec settings $this->updateTextCodecSettings(); diff --git a/kernel/private/classes/ezpkernel.php b/kernel/private/classes/ezpkernel.php index dd6ec168339..e1e35ab4e9c 100644 --- a/kernel/private/classes/ezpkernel.php +++ b/kernel/private/classes/ezpkernel.php @@ -119,6 +119,16 @@ public function getServiceContainer() return $this->kernelHandler->getServiceContainer(); } + /** + * Checks if the kernel has already been instantiated. + * + * @return bool + */ + public static function hasInstance() + { + return self::$instance !== null; + } + /** * Returns the current instance of ezpKernel. * @@ -127,14 +137,15 @@ public function getServiceContainer() */ public static function instance() { - if ( self::$instance === null ) + if ( !self::hasInstance() ) { throw new LogicException( 'Cannot return the instance of ' - . __CLASS__ - . ', it has not been instantiated' + . __CLASS__ + . ', it has not been instantiated' ); } return self::$instance; } } +