Details
-
Bug
-
Resolution: Fixed
-
Medium
-
2015.01, 5.3.4, 5.4.1.1
-
None
-
eZ Publish 5.3.4
Description
Using public API, if we perform a legacy call the output buffer gets cleared for some reason.
This doesn't seems the correct behavior.
Steps to reproduce:
Create a bundle, and add a command to it, containing the following code:
// Generate output buffer ob_start(); echo "test\n"; $levelBefore = ob_get_level(); // This legacy call will clean the ob and discard our output of 'test' $closure = $this->getContainer()->get('ezpublish_legacy.kernel'); $legacyKernel = $closure(); $legacyKernel->runCallback( function () { }, false, false ); // Dump differences $levelAfter = ob_get_level(); $content = ob_get_clean(); printf("ob_get_level() before legacy call: %d\n", $levelBefore); printf("ob_get_level() after legacy call: %d\n", $levelAfter); printf("Content: %s\n", $content);
The content of $levelAfter should be the same as $levelBefore, but it isn't, because the output buffer has been flushed.
The same can be tested with ob_get_contents():
// Generate output buffer ob_start(); echo "test\n"; $bufferBefore = ob_get_contents(); // This legacy call will clean the ob and discard our output of 'test' $closure = $this->getContainer()->get('ezpublish_legacy.kernel'); $legacyKernel = $closure(); $legacyKernel->runCallback( function () { }, false, false ); // Dump differences $bufferAfter = ob_get_contents(); $content = ob_get_clean(); var_dump($bufferBefore); var_dump($bufferAfter); printf("Content: %s\n", $content);
Which will output:
string(5) "test " bool(false) Content:
bool(false) will be returned when dumping $bufferAfter because the output buffer has been flushed after the legacy call.