From c4a5b67a5af04bfd57b9b203ee2685cf33b42d90 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 5 Mar 2016 08:50:24 +0100 Subject: [PATCH 1/3] exception when registering bags for started sessions --- .../Session/Storage/NativeSessionStorage.php | 4 ++++ .../Tests/Session/Storage/NativeSessionStorageTest.php | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index 137f0e8e1c..aa4a237cdd 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -260,6 +260,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; } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 121cff37a1..160b575862 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -83,6 +83,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(); From 4fa58440be9577d2e33ed8e41364ca01bfc49b65 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 7 Mar 2016 16:45:39 +0100 Subject: [PATCH 2/3] [HttpKernel] Fix mem usage when stripping the prod container --- .../DependencyInjection/Dumper/PhpDumper.php | 27 ++++++++++++++----- src/Symfony/Component/HttpKernel/Kernel.php | 5 +--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 4f65e0f9a3..d239b7d7d5 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -23,6 +23,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface as ProxyDumper; use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper; +use Symfony\Component\HttpKernel\Kernel; /** * PhpDumper dumps a service container as a PHP class. @@ -53,6 +54,7 @@ class PhpDumper extends Dumper private $reservedVariables = array('instance', 'class'); private $targetDirRegex; private $targetDirMaxMatches; + private $docStar; /** * @var \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface @@ -97,7 +99,9 @@ class PhpDumper extends Dumper $options = array_merge(array( 'class' => 'ProjectServiceContainer', 'base_class' => 'Container', + '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, @@ -219,9 +223,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 = "docStar} * Gets the '$id' service.$doc *$lazyInitializationDoc * $return @@ -699,7 +709,7 @@ EOF; return <<docStar} * Updates the '$id' service. */ protected function synchronize{$this->camelize($id)}Service() @@ -760,7 +770,7 @@ use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; $bagClass -/** +/*{$this->docStar} * $class. * * This class has been auto-generated @@ -786,7 +796,7 @@ EOF; $code = <<docStar} * Constructor. */ public function __construct() @@ -823,7 +833,7 @@ EOF; $code = <<docStar} * Constructor. */ public function __construct() @@ -970,11 +980,14 @@ EOF; return $this->parameterBag; } EOF; + if ('' === $this->docStar) { + $code = str_replace('/**', '/*', $code); + } } $code .= <<docStar} * Gets the default parameters. * * @return array An array of the default parameters diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 56c87d77f6..0edc40b4ca 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -650,10 +650,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface $dumper->setProxyDumper(new ProxyDumper(md5((string) $cache))); } - $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => (string) $cache)); - if (!$this->debug) { - $content = static::stripComments($content); - } + $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => (string) $cache, 'debug' => $this->debug)); $cache->write($content, $container->getResources()); } From ead1824d3e0f18b62ab157db13bfae3a724c1a24 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 8 Mar 2016 15:56:51 +0000 Subject: [PATCH 3/3] [Finder] Partially revert #17134 to fix a regression --- .../Component/Finder/Iterator/FilterIterator.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Finder/Iterator/FilterIterator.php b/src/Symfony/Component/Finder/Iterator/FilterIterator.php index 24adeb68f9..3c3c3fbec0 100644 --- a/src/Symfony/Component/Finder/Iterator/FilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FilterIterator.php @@ -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();