Merge branch '2.8' into 3.0
* 2.8: [Finder] Partially revert #17134 to fix a regression [HttpKernel] Fix mem usage when stripping the prod container exception when registering bags for started sessions Conflicts: src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php src/Symfony/Component/Validator/composer.json
This commit is contained in:
commit
1c3e14fc4c
@ -25,6 +25,7 @@ use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface as
|
||||
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper;
|
||||
use Symfony\Component\DependencyInjection\ExpressionLanguage;
|
||||
use Symfony\Component\ExpressionLanguage\Expression;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
/**
|
||||
* PhpDumper dumps a service container as a PHP class.
|
||||
@ -56,6 +57,7 @@ class PhpDumper extends Dumper
|
||||
private $expressionLanguage;
|
||||
private $targetDirRegex;
|
||||
private $targetDirMaxMatches;
|
||||
private $docStar;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface
|
||||
@ -102,7 +104,9 @@ class PhpDumper extends Dumper
|
||||
'class' => 'ProjectServiceContainer',
|
||||
'base_class' => 'Container',
|
||||
'namespace' => '',
|
||||
'debug' => true,
|
||||
), $options);
|
||||
$this->docStar = $options['debug'] ? '*' : '';
|
||||
|
||||
if (!empty($options['file']) && is_dir($dir = dirname($options['file']))) {
|
||||
// Build a regexp where the first root dirs are mandatory,
|
||||
@ -227,9 +231,15 @@ class PhpDumper extends Dumper
|
||||
array($this->getProxyDumper(), 'isProxyCandidate')
|
||||
);
|
||||
$code = '';
|
||||
$strip = '' === $this->docStar && method_exists('Symfony\Component\HttpKernel\Kernel', 'stripComments');
|
||||
|
||||
foreach ($definitions as $definition) {
|
||||
$code .= "\n".$this->getProxyDumper()->getProxyCode($definition);
|
||||
$proxyCode = "\n".$this->getProxyDumper()->getProxyCode($definition);
|
||||
if ($strip) {
|
||||
$proxyCode = "<?php\n".$proxyCode;
|
||||
$proxyCode = substr(Kernel::stripComments($proxyCode), 5);
|
||||
}
|
||||
$code .= $proxyCode;
|
||||
}
|
||||
|
||||
return $code;
|
||||
@ -617,7 +627,7 @@ EOF;
|
||||
$visibility = $isProxyCandidate ? 'public' : 'protected';
|
||||
$code = <<<EOF
|
||||
|
||||
/**
|
||||
/*{$this->docStar}
|
||||
* Gets the '$id' service.$doc
|
||||
*$lazyInitializationDoc
|
||||
* $return
|
||||
@ -740,7 +750,7 @@ use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||
$bagClass
|
||||
|
||||
/**
|
||||
/*{$this->docStar}
|
||||
* $class.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
@ -766,7 +776,7 @@ EOF;
|
||||
|
||||
$code = <<<EOF
|
||||
|
||||
/**
|
||||
/*{$this->docStar}
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
@ -797,7 +807,7 @@ EOF;
|
||||
|
||||
$code = <<<EOF
|
||||
|
||||
/**
|
||||
/*{$this->docStar}
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
@ -829,7 +839,7 @@ EOF;
|
||||
{
|
||||
return <<<EOF
|
||||
|
||||
/**
|
||||
/*{$this->docStar}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function compile()
|
||||
@ -950,11 +960,14 @@ EOF;
|
||||
}
|
||||
|
||||
EOF;
|
||||
if ('' === $this->docStar) {
|
||||
$code = str_replace('/**', '/*', $code);
|
||||
}
|
||||
}
|
||||
|
||||
$code .= <<<EOF
|
||||
|
||||
/**
|
||||
/*{$this->docStar}
|
||||
* Gets the default parameters.
|
||||
*
|
||||
* @return array An array of the default parameters
|
||||
|
@ -39,11 +39,18 @@ abstract class FilterIterator extends \FilterIterator
|
||||
while ($iterator instanceof \OuterIterator) {
|
||||
$innerIterator = $iterator->getInnerIterator();
|
||||
|
||||
if ($innerIterator instanceof \FilesystemIterator) {
|
||||
if ($innerIterator instanceof RecursiveDirectoryIterator) {
|
||||
// this condition is necessary for iterators to work properly with non-local filesystems like ftp
|
||||
if ($innerIterator->isRewindable()) {
|
||||
$innerIterator->next();
|
||||
$innerIterator->rewind();
|
||||
}
|
||||
} elseif ($innerIterator instanceof \FilesystemIterator) {
|
||||
$innerIterator->next();
|
||||
$innerIterator->rewind();
|
||||
}
|
||||
$iterator = $iterator->getInnerIterator();
|
||||
|
||||
$iterator = $innerIterator;
|
||||
}
|
||||
|
||||
parent::rewind();
|
||||
|
@ -236,6 +236,10 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
*/
|
||||
public function registerBag(SessionBagInterface $bag)
|
||||
{
|
||||
if ($this->started) {
|
||||
throw new \LogicException('Cannot register a bag when the session is already started.');
|
||||
}
|
||||
|
||||
$this->bags[$bag->getName()] = $bag;
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,16 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||
$storage->getBag('non_existing');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
*/
|
||||
public function testRegisterBagForAStartedSessionThrowsException()
|
||||
{
|
||||
$storage = $this->getStorage();
|
||||
$storage->start();
|
||||
$storage->registerBag(new AttributeBag());
|
||||
}
|
||||
|
||||
public function testGetId()
|
||||
{
|
||||
$storage = $this->getStorage();
|
||||
|
@ -629,10 +629,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
$dumper->setProxyDumper(new ProxyDumper(md5($cache->getPath())));
|
||||
}
|
||||
|
||||
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath()));
|
||||
if (!$this->debug) {
|
||||
$content = static::stripComments($content);
|
||||
}
|
||||
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath(), 'debug' => $this->debug));
|
||||
|
||||
$cache->write($content, $container->getResources());
|
||||
}
|
||||
|
Reference in New Issue
Block a user