8000 Merge branch '2.8' into 3.0 · symfony/symfony@1c3e14f · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1c3e14f

Browse files
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
2 parents 5380d68 + 2205eac commit 1c3e14f

File tree

5 files changed

+44
-13
lines changed

5 files changed

+44
-13
lines changed

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper;
2626
use Symfony\Component\DependencyInjection\ExpressionLanguage;
2727
use Symfony\Component\ExpressionLanguage\Expression;
28+
use Symfony\Component\HttpKernel\Kernel;
2829

2930
/**
3031
* PhpDumper dumps a service container as a PHP class.
@@ -56,6 +57,7 @@ class PhpDumper extends Dumper
5657
private $expressionLanguage;
5758
private $targetDirRegex;
5859
private $targetDirMaxMatches;
60+
private $docStar;
5961

6062
/**
6163
* @var \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface
@@ -102,7 +104,9 @@ public function dump(array $options = array())
102104
'class' => 'ProjectServiceContainer',
103105
'base_class' => 'Container',
104106
'namespace' => '',
107+
'debug' => true,
105108
), $options);
109+
$this->docStar = $options['debug'] ? '*' : '';
106110

107111
if (!empty($options['file']) && is_dir($dir = dirname($options['file']))) {
108112
// Build a regexp where the first root dirs are mandatory,
@@ -227,9 +231,15 @@ private function addProxyClasses()
227231
array($this->getProxyDumper(), 'isProxyCandidate')
228232
);
229233
$code = '';
234+
$strip = '' === $this->docStar && method_exists('Symfony\Component\HttpKernel\Kernel', 'stripComments');
230235

231236
foreach ($definitions as $definition) {
232-
$code .= "\n".$this->getProxyDumper()->getProxyCode($definition);
237+
$proxyCode = "\n".$this->getProxyDumper()->getProxyCode($definition);
238+
if ($strip) {
239+
$proxyCode = "<?php\n".$proxyCode;
240+
$proxyCode = substr(Kernel::stripComments($proxyCode), 5);
241+
}
242+
$code .= $proxyCode;
233243
}
234244

235245
return $code;
@@ -617,7 +627,7 @@ private function addService($id, $definition)
617627
$visibility = $isProxyCandidate ? 'public' : 'protected';
618628
$code = <<<EOF
619629
620-
/**
630+
/*{$this->docStar}
621631
* Gets the '$id' service.$doc
622632
*$lazyInitializationDoc
623633
* $return
@@ -740,7 +750,7 @@ private function startClass($class, $baseClass, $namespace)
740750
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
741751
$bagClass
742752
743-
/**
753+
/*{$this->docStar}
744754
* $class.
745755
*
746756
* This class has been auto-generated
@@ -766,7 +776,7 @@ private function addConstructor()
766776

767777
$code = <<<EOF
768778
769-
/**
779+
/*{$this->docStar}
770780
* Constructor.
771781
*/
772782
public function __construct()
@@ -797,7 +807,7 @@ private function addFrozenConstructor()
797807

798808
$code = <<<EOF
799809
800-
/**
810+
/*{$this->docStar}
801811
* Constructor.
802812
*/
803813
public function __construct()
@@ -829,7 +839,7 @@ private function addFrozenCompile()
829839
{
830840
return <<<EOF
831841
832-
/**
842+
/*{$this->docStar}
833843
* {@inheritdoc}
834844
*/
835845
public function compile()
@@ -950,11 +960,14 @@ public function getParameterBag()
950960
}
951961

952962
EOF;
963+
if ('' === $this->docStar) {
964+
$code = str_replace('/**', '/*', $code);
965+
}
953966
}
954967

955968
$code .= <<<EOF
956969
957-
/**
970+
/*{$this->docStar}
958971
* Gets the default parameters.
959972
*
960973
* @return array An array of the default parameters

src/Symfony/Component/Finder/Iterator/FilterIterator.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,18 @@ public function rewind()
3939
while ($iterator instanceof \OuterIterator) {
4040
$innerIterator = $iterator->getInnerIterator();
4141

42-
if ($innerIterator instanceof \FilesystemIterator) {
42+
if ($innerIterator instanceof RecursiveDirectoryIterator) {
43+
// this condition is necessary for iterators to work properly with non-local filesystems like ftp
44+
if ($innerIterator->isRewindable()) {
45+
$innerIterator->next();
46+
$innerIterator->rewind();
47+
}
48+
} elseif ($innerIterator instanceof \FilesystemIterator) {
4349
$innerIterator->next();
4450
$innerIterator->rewind();
4551
}
46-
$iterator = $iterator->getInnerIterator();
52+
53+
$iterator = $innerIterator;
4754
}
4855

4956
parent::rewind();

src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ public function clear()
236236
*/
237237
public function registerBag(SessionBagInterface $bag)
238238
{
239+
if ($this->started) {
240+
throw new \LogicException('Cannot register a bag when the session is already started.');
241+
}
242+
239243
$this->bags[$bag->getName()] = $bag;
240244
}
241245

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ public function testRegisterBagException()
8282
$storage->getBag('non_existing');
8383
}
8484

85+
/**
86+
* @expectedException \LogicException
87+
*/
88+
public function testRegisterBagForAStartedSessionThrowsException()
89+
{
90+
$storage = $this->getStorage();
91+
$storage->start();
92+
$storage->registerBag(new AttributeBag());
93+
}
94+
8595
public function testGetId()
8696
{
8797
$storage = $this->getStorage();

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container
629629
$dumper->setProxyDumper(new ProxyDumper(md5($cache->getPath())));
630630
}
631631

632-
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath()));
633-
if (!$this->debug) {
634-
$content = static::stripComments($content);
635-
}
632+
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath(), 'debug' => $this->debug));
636633

637634
$cache->write($content, $container->getResources());
638635
}

0 commit comments

Comments
 (0)
0