Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix EZP-24135: Output buffer gets cleared after legacy call
Moved hasInstance() method from \eZ\Publish\Core\MVC\Legacy\Kernel to ezpKernel
Use hasInstance() in eZScript
Use hasInstance() in Kernel::instance()
CS fix in Kernel::instance()
  • Loading branch information
glye committed Mar 23, 2015
1 parent 61a1831 commit 97d6a72
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
7 changes: 5 additions & 2 deletions kernel/classes/ezscript.php
Expand Up @@ -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();
Expand Down
17 changes: 14 additions & 3 deletions kernel/private/classes/ezpkernel.php
Expand Up @@ -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.
*
Expand All @@ -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;
}
}

0 comments on commit 97d6a72

Please sign in to comment.