Skip to content

Commit c8cb253

Browse files
[HttpKernel] Fix mem usage when stripping the prod container
1 parent 6d5dbf7 commit c8cb253

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class PhpDumper extends Dumper
5353
private $reservedVariables = array('instance', 'class');
5454
private $targetDirRegex;
5555
private $targetDirMaxMatches;
56+
private $docStar;
5657

5758
/**
5859
* @var \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface
@@ -97,7 +98,9 @@ public function dump(array $options = array())
9798
$options = array_merge(array(
9899
'class' => 'ProjectServiceContainer',
99100
'base_class' => 'Container',
101+
'debug' => true,
100102
), $options);
103+
$this->docStar = $options['debug'] ? '*' : '';
101104

102105
if (!empty($options['file']) && is_dir($dir = dirname($options['file']))) {
103106
// Build a regexp where the first root dirs are mandatory,
@@ -589,7 +592,7 @@ private function addService($id, $definition)
589592
$visibility = $isProxyCandidate ? 'public' : 'protected';
590593
$code = <<<EOF
591594
592-
/**
595+
/*{$this->docStar}
593596
* Gets the '$id' service.$doc
594597
*$lazyInitializationDoc
595598
* $return
@@ -699,7 +702,7 @@ private function addServiceSynchronizer($id, Definition $definition)
699702

700703
return <<<EOF
701704
702-
/**
705+
/*{$this->docStar}
703706
* Updates the '$id' service.
704707
*/
705708
protected function synchronize{$this->camelize($id)}Service()
@@ -760,7 +763,7 @@ private function startClass($class, $baseClass)
760763
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
761764
$bagClass
762765
763-
/**
766+
/*{$this->docStar}
764767
* $class.
765768
*
766769
* This class has been auto-generated
@@ -786,7 +789,7 @@ private function addConstructor()
786789

787790
$code = <<<EOF
788791
789-
/**
792+
/*{$this->docStar}
790793
* Constructor.
791794
*/
792795
public function __construct()
@@ -823,7 +826,7 @@ private function addFrozenConstructor()
823826

824827
$code = <<<EOF
825828
826-
/**
829+
/*{$this->docStar}
827830
* Constructor.
828831
*/
829832
public function __construct()
@@ -970,11 +973,14 @@ public function getParameterBag()
970973
return $this->parameterBag;
971974
}
972975
EOF;
976+
if ('' === $this->docStar) {
977+
$code = str_replace('/**', '/*', $code);
978+
}
973979
}
974980

975981
$code .= <<<EOF
976982
977-
/**
983+
/*{$this->docStar}
978984
* Gets the default parameters.
979985
*
980986
* @return array An array of the default parameters

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container
650650
$dumper->setProxyDumper(new ProxyDumper(md5((string) $cache)));
651651
}
652652

653-
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => (string) $cache));
654-
if (!$this->debug) {
655-
$content = static::stripComments($content);
656-
}
653+
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => (string) $cache, 'debug' => $this->debug));
657654

658655
$cache->write($content, $container->getResources());
659656
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy