Skip to content

kernel.name parameter will differ if cache warmup is used #16180

@matthewpeach

Description

@matthewpeach

Because a "TempKernel" with a name that differs to the real kernel name is used to warm up the cache in CacheClearCommand, the kernel.name container parameter will be cached with a different value depending on whether warmup has occurred.

Simple demonstration:

# install latest symfony into a fresh project
php composer.phar create-project symfony/framework-standard-edition warmup-bug "2.7.*" --stability=dev

# clear the cache and warmup
php app/console cache:clear

# kernel.name is now "ap_"
grep kernel.name app/cache/dev/appDevDebugProjectContainer.php

# clear the cache without warmup
php app/console cache:clear --no-warmup

# run console with no arguments to cause a cache build
php app/console

# kernel.name is now "app"
grep kernel.name app/cache/dev/appDevDebugProjectContainer.php

Related code from CacheClearCommand->getTempKernel:

// the temp kernel class name must have the same length than the real one
// to avoid the many problems in serialized resources files
$class = substr($parentClass, 0, -1).'_';
// the temp kernel name must be changed too
$name = var_export(substr($parent->getName(), 0, -1).'_', true);
public function getName()
{
    return $name;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions