8000 Merge branch '2.3' into 2.7 · symfony/symfony@4bc282d · GitHub
[go: up one dir, main page]

Skip to content

Commit 4bc282d

Browse files
Merge branch '2.3' into 2.7
* 2.3: [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/HttpKernel/Kernel.php
2 parents 1d9815f + fd4edff commit 4bc282d

File tree

6 files changed

+46
-15
lines changed

6 files changed

+46
-15
lines changed

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

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Symfony\Component\DependencyInjection\ExpressionLanguage;
2727
use Symfony\Component\ExpressionLanguage\Expression;
2828
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
29+
use Symfony\Component\HttpKernel\Kernel;
2930

3031
/**
3132
* PhpDumper dumps a service container as a PHP class.
@@ -57,6 +58,7 @@ class PhpDumper extends Dumper
5758
private $expressionLanguage;
5859
private $targetDirRegex;
5960
private $targetDirMaxMatches;
61+
private $docStar;
6062

6163
/**
6264
* @var ExpressionFunctionProviderInterface[]
@@ -108,7 +110,9 @@ public function dump(array $options = array())
108110
'class' => 'ProjectServiceContainer',
109111
'base_class' => 'Container',
110112
'namespace' => '',
113+
'debug' => true,
111114
), $options);
115+
$this->docStar = $options['debug'] ? '*' : '';
112116

113117
if (!empty($options['file']) && is_dir($dir = dirname($options['file']))) {
114118
// Build a regexp where the first root dirs are mandatory,
@@ -233,9 +237,15 @@ private function addProxyClasses()
233237
array($this->getProxyDumper(), 'isProxyCandidate')
234238
);
235239
$code = '';
240+
$strip = '' === $this->docStar && method_exists('Symfony\Component\HttpKernel\Kernel', 'stripComments');
236241

237242
foreach ($definitions as $definition) {
238-
$code .= "\n".$this->getProxyDumper()->getProxyCode($definition);
243+
$proxyCode = "\n".$this->getProxyDumper()->getProxyCode($definition);
244+
if ($strip) {
245+
$proxyCode = "<?php\n".$proxyCode;
246+
$proxyCode = substr(Kernel::stripComments($proxyCode), 5);
247+
}
248+
$code .= $proxyCode;
239249
}
240250

241251
return $code;
@@ -621,7 +631,7 @@ private function addService($id, $definition)
621631
$visibility = $isProxyCandidate ? 'public' : 'protected';
622632
$code = <<<EOF
623633
624-
/**
634+
/*{$this->docStar}
625635
* Gets the '$id' service.$doc
626636
*$lazyInitializationDoc
627637
* $return
@@ -737,7 +747,7 @@ private function addServiceSynchronizer($id, Definition $definition)
737747

738748
return <<<EOF
739749
740-
/**
750+
/*{$this->docStar}
741751
* Updates the '$id' service.
742752
*/
743753
protected function synchronize{$this->camelize($id)}Service()
@@ -829,7 +839,7 @@ private function startClass($class, $baseClass, $namespace)
829839
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
830840
$bagClass
831841
832-
/**
842+
/*{$this->docStar}
833843
* $class.
834844
*
835845
* This class has been auto-generated
@@ -855,7 +865,7 @@ private function addConstructor()
855865

856866
$code = <<<EOF
857867
858-
/**
868+
/*{$this->docStar}
859869
* Constructor.
860870
*/
861871
public function __construct()
@@ -892,7 +902,7 @@ private function addFrozenConstructor()
892902

893903
$code = <<<EOF
894904
895-
/**
905+
/*{$this->docStar}
896906
* Constructor.
897907
*/
898908
public function __construct()
@@ -939,7 +949,7 @@ private function addFrozenCompile()
939949
{
940950
return <<<EOF
941951
942-
/**
952+
/*{$this->docStar}
943953
* {@inheritdoc}
944954
*/
945955
public function compile()
@@ -1060,11 +1070,14 @@ public function getParameterBag()
10601070
}
10611071

10621072
EOF;
1073+
if ('' === $this->docStar) {
1074+
$code = str_replace('/**', '/*', $code);
1075+
}
10631076
}
10641077

10651078
$code .= <<<EOF
10661079
1067-
/**
1080+
/*{$this->docStar}
10681081
* Gets the default parameters.
10691082
*
10701083
* @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
@@ -260,6 +260,10 @@ public function clear()
260260
*/
261261
public function registerBag(SessionBagInterface $bag)
262262
{
263+
if ($this->started) {
264+
throw new \LogicException('Cannot register a bag when the session is already started.');
265+
}
266+
263267
$this->bags[$bag->getName()] = $bag;
264268
}
265269

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

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

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

src/Symfony/Component/HttpKernel/Kernel.php

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

665-
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath()));
666-
if (!$this->debug) {
667-
$content = static::stripComments($content);
668-
}
665+
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath(), 'debug' => $this->debug));
669666

670667
$cache->write($content, $container->getResources());
671668
}

src/Symfony/Component/Validator/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require-dev": {
< 5FE9 /code>
2323
"doctrine/common": "~2.3",
2424
"symfony/http-foundation": "~2.1",
25-
"symfony/intl": "~2.7.4",
25+
"symfony/intl": "~2.7.4|~2.8",
2626
"symfony/yaml": "~2.0,>=2.0.5",
2727
"symfony/config": "~2.2",
2828
"symfony/property-access": "~2.3",

0 commit comments

Comments
 (0)
0