Skip to content

Commit

Permalink
Fix EZP-24135: Output buffer gets cleared after legacy call
Browse files Browse the repository at this point in the history
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()

(cherry picked from commit 97d6a72)
  • Loading branch information
glye authored and andrerom committed Apr 16, 2015
1 parent 02b16e1 commit eba0c2b
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 eba0c2b

Please sign in to comment.