add more entropy to generated classnames

- use proxy destination filename to create and md5 salt
- apply fabbot patch
- inline salt generation
This commit is contained in:
Berny Cantos 2015-05-02 20:46:11 +02:00
parent 3cdb539360
commit afc39ee11f
2 changed files with 12 additions and 4 deletions

View File

@ -26,6 +26,11 @@ use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
*/
class ProxyDumper implements DumperInterface
{
/**
* @var string
*/
private $salt;
/**
* @var LazyLoadingValueHolderGenerator
*/
@ -38,9 +43,12 @@ class ProxyDumper implements DumperInterface
/**
* Constructor.
*
* @param string $salt
*/
public function __construct()
public function __construct($salt = '')
{
$this->salt = $salt;
$this->proxyGenerator = new LazyLoadingValueHolderGenerator();
$this->classGenerator = new BaseGeneratorStrategy();
}
@ -109,6 +117,6 @@ EOF;
*/
private function getProxyClassName(Definition $definition)
{
return str_replace('\\', '', $definition->getClass()).'_'.spl_object_hash($definition);
return str_replace('\\', '', $definition->getClass()).'_'.spl_object_hash($definition).$this->salt;
}
}

View File

@ -243,7 +243,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
}
/**
* {@inheritDoc}
* {@inheritdoc}
*
* @throws \RuntimeException if a custom resource is hidden by a resource in a derived bundle
*/
@ -683,7 +683,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
$dumper = new PhpDumper($container);
if (class_exists('ProxyManager\Configuration')) {
$dumper->setProxyDumper(new ProxyDumper());
$dumper->setProxyDumper(new ProxyDumper(md5((string) $cache)));
}
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => (string) $cache));