From ca46bd3805f4f4927218749d9509e6e07b791c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81ro=CC=82me=20Vieilledent?= Date: Wed, 29 Jan 2014 18:09:03 +0100 Subject: [PATCH] EZP-22152: Don't retrieve legacy templates list if legacy kernel ain't booted --- .../Collector/TemplateDebugInfo.php | 13 ++++++++++--- eZ/Publish/Core/MVC/Legacy/Kernel.php | 10 ++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/eZ/Bundle/EzPublishDebugBundle/Collector/TemplateDebugInfo.php b/eZ/Bundle/EzPublishDebugBundle/Collector/TemplateDebugInfo.php index 522f7e3967b..5daf0480308 100644 --- a/eZ/Bundle/EzPublishDebugBundle/Collector/TemplateDebugInfo.php +++ b/eZ/Bundle/EzPublishDebugBundle/Collector/TemplateDebugInfo.php @@ -9,7 +9,7 @@ namespace eZ\Bundle\EzPublishDebugBundle\Collector; -use Symfony\Component\DependencyInjection\ContainerInterface; +use eZ\Publish\Core\MVC\Legacy\Kernel as LegacyKernel; use eZTemplate; /** @@ -64,11 +64,19 @@ public static function getTemplatesList() /** * Returns array of loaded legacy templates * - * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * @param \Closure $legacyKernel + * * @return array */ public static function getLegacyTemplatesList( \Closure $legacyKernel ) { + $templateList = array( 'compact' => array(), 'full' => array() ); + // Only retrieve legacy templates list if the kernel has been booted at least once. + if ( !LegacyKernel::hasInstance() ) + { + return $templateList; + } + $templateStats = $legacyKernel()->runCallback( function () { @@ -76,7 +84,6 @@ function () } ); - $templateList = array( 'compact' => array(), 'full' => array() ); foreach ( $templateStats as $tplInfo ) { $requestedTpl = $tplInfo["requested-template-name"]; diff --git a/eZ/Publish/Core/MVC/Legacy/Kernel.php b/eZ/Publish/Core/MVC/Legacy/Kernel.php index e3220e88f73..474b7ed7bf3 100644 --- a/eZ/Publish/Core/MVC/Legacy/Kernel.php +++ b/eZ/Publish/Core/MVC/Legacy/Kernel.php @@ -50,6 +50,16 @@ public function __construct( ezpKernelHandler $kernelHandler, $legacyRootDir, $w $this->setUseExceptions( true ); } + /** + * Checks if LegacyKernel has already been instantiated. + * + * @return bool + */ + public static function hasInstance() + { + return static::$instance !== null; + } + /** * Changes the current working directory to the legacy root dir. * Calling this method is mandatory to use legacy kernel since a lot of resources in eZ Publish 4.x relatively defined.