Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2205eac

Browse files
Merge branch '2.7' into 2.8
* 2.7: [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/Validator/composer.json
2 parents bb5b696 + 4bc282d commit 2205eac

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;
@@ -637,7 +647,7 @@ private function addService($id, $definition)
637647
$visibility = $isProxyCandidate ? 'public' : 'protected';
638648
$code = <<<EOF
639649
640-
/**
650+
/*{$this->docStar}
641651
* Gets the '$id' service.$doc
642652
*$lazyInitializationDoc
643653
* $return
@@ -757,7 +767,7 @@ private function addServiceSynchronizer($id, Definition $definition)
757767

758768
return <<<EOF
759769
760-
/**
770+
/*{$this->docStar}
761771
* Updates the '$id' service.
762772
*/
763773
protected function synchronize{$this->camelize($id)}Service()
@@ -849,7 +859,7 @@ private function startClass($class, $baseClass, $namespace)
849859
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
850860
$bagClass
851861
852-
/**
862+
/*{$this->docStar}
853863
* $class.
854864
*
855865
* This class has been auto-generated
@@ -875,7 +885,7 @@ private function addConstructor()
875885

876886
$code = <<<EOF
877887
878-
/**
888+
/*{$this->docStar}
879889
* Constructor.
880890
*/
881891
public function __construct()
@@ -912,7 +922,7 @@ private function addFrozenConstructor()
912922

913923
$code = <<<EOF
914924
915-
/**
925+
/*{$this->docStar}
916926
* Constructor.
917927
*/
918928
public function __construct()
@@ -959,7 +969,7 @@ private function addFrozenCompile()
959969
{
960970
return <<<EOF
961971
962-
/**
972+
/*{$this->docStar}
963973
* {@inheritdoc}
964974
*/
965975
public function compile()
@@ -1080,11 +1090,14 @@ public function getParameterBag()
10801090
}
10811091

10821092
EOF;
1093+
if ('' === $this->docStar) {
1094+
$code = str_replace('/**', '/*', $code);
1095+
}
10831096
}
10841097

10851098
$code .= <<<EOF
10861099
1087-
/**
1100+
/*{$this->docStar}
10881101
* Gets the default parameters.
10891102
*
10901103
* @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
@@ -256,6 +256,10 @@ public function clear()
256256
*/
257257
public function registerBag(SessionBagInterface $bag)
258258
{
259+
if ($this->started) {
260+
throw new \LogicException('Cannot register a bag when the session is already started.');
261+
}
262+
259263
$this->bags[$bag->getName()] = $bag;
260264
}
261265

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
@@ -663,10 +663,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container
663663
$dumper->setProxyDumper(new ProxyDumper(md5($cache->getPath())));
664664
}
665665

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

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

src/Symfony/Component/Validator/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"require-dev": {
2323
"symfony/http-foundation": "~2.1|~3.0.0",
24-
"symfony/intl": "~2.4|~3.0.0",
24+
"symfony/intl": "~2.7.4|~2.8|~3.0.0",
2525
"symfony/yaml": "~2.0,>=2.0.5|~3.0.0",
2626
"symfony/config": "~2.2|~3.0.0",
2727
"symfony/property-access": "~2.3|~3.0.0",

0 commit comments

Comments
 (0)