Skip to content

Commit

Permalink
Merge branch '6.13' into 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Aug 13, 2018
2 parents 198c39c + 3fe2967 commit bd4f00b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
@@ -0,0 +1,50 @@
<?php

/**
* File containing the ConsoleCacheWarmupPass class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* Cache related compiler pass.
*
* Ensures class cache warmup is disabled in console mode.
*/
class ConsoleCacheWarmupPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
// This pass is CLI only as CLI class cache warmup conflicts with web access, see EZP-29034
if (PHP_SAPI !== 'cli' ||
!$container->hasDefinition('kernel.class_cache.cache_warmer')) {
return;
}

$warmers = array();
foreach ($container->findTaggedServiceIds('kernel.cache_warmer') as $id => $attributes) {
if ($id === 'kernel.class_cache.cache_warmer') {
continue;
}

$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
$warmers[$priority][] = new Reference($id);
}

if (empty($warmers)) {
return;
}

// sort by priority and flatten
krsort($warmers);
$warmers = \call_user_func_array('array_merge', $warmers);

$container->getDefinition('cache_warmer')->replaceArgument(0, $warmers);
}
}
2 changes: 2 additions & 0 deletions eZ/Bundle/EzPublishCoreBundle/EzPublishCoreBundle.php
Expand Up @@ -12,6 +12,7 @@
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\BinaryContentDownloadPass;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\ComplexSettingsPass;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\ConfigResolverParameterPass;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\ConsoleCacheWarmupPass;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\FieldTypeParameterProviderRegistryPass;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\FragmentPass;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\NotificationRendererPass;
Expand Down Expand Up @@ -84,6 +85,7 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new ViewProvidersPass());
$container->addCompilerPass(new PlaceholderProviderPass());
$container->addCompilerPass(new NotificationRendererPass());
$container->addCompilerPass(new ConsoleCacheWarmupPass());

// Storage passes
$container->addCompilerPass(new ExternalStorageRegistryPass());
Expand Down

0 comments on commit bd4f00b

Please sign in to comment.