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

Skip to content

Commit 2850fca

Browse files
committed
Merge branch '2.1' into 2.2
* 2.1: [FrameworkBundle] Fixes invalid serialized objects in cache remove dead code in yaml component fixed typo RedisProfilerStorage wrong db-number/index-number selected [DependencyInjection] added a test for the previous merge (refs #7261) Unset loading[$id] in ContainerBuilder on exception [Console] fixed StringInput binding [Console] added string input test Revert "merged branch jfsimon/issue-6749 (PR #7220)" fixed CS Conflicts: src/Symfony/Component/Console/Tests/Input/StringInputTest.php src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php
2 parents f2af1ea + 5f2cea3 commit 2850fca

File tree

9 files changed

+76
-24
lines changed

9 files changed

+76
-24
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,31 @@ protected function warmup($warmupDir, $enableOptionalWarmers = true)
104104

105105
$warmer->warmUp($warmupDir);
106106

107+
foreach (Finder::create()->files()->name('*.meta')->in($warmupDir) as $file) {
108+
// fix meta references to the Kernel
109+
$content = preg_replace(
110+
'/C\:\d+\:"'.preg_quote($class.$this->getTempKernelSuffix(), '"/').'"/',
111+
sprintf('C:%s:"%s"', strlen($class), $class),
112+
file_get_contents($file)
113+
);
114+
115+
// fix meta references to cache files
116+
$realWarmupDir = substr($warmupDir, 0, -4);
117+
$content = preg_replace_callback(
118+
'/s\:\d+\:"'.preg_quote($warmupDir, '/').'([^"]+)"/',
119+
function (array $matches) use ($realWarmupDir) {
120+
$path = $realWarmupDir.$matches[1];
121+
return sprintf('s:%s:"%s"', strlen($path), $path);
122+
},
123+
$content
124+
);
125+
126+
file_put_contents($file, $content);
127+
}
128+
107129
// fix container files and classes
108130
$regex = '/'.preg_quote($this->getTempKernelSuffix(), '/').'/';
109-
$finder = new Finder();
110-
foreach ($finder->files()->name(get_class($kernel->getContainer()).'*')->in($warmupDir) as $file) {
131+
foreach (Finder::create()->files()->name(get_class($kernel->getContainer()).'*')->in($warmupDir) as $file) {
111132
$content = file_get_contents($file);
112133
$content = preg_replace($regex, '', $content);
113134

@@ -117,16 +138,6 @@ protected function warmup($warmupDir, $enableOptionalWarmers = true)
117138
file_put_contents(preg_replace($regex, '', $file), $content);
118139
unlink($file);
119140
}
120-
121-
// fix meta references to the Kernel
122-
foreach ($finder->files()->name('*.meta')->in($warmupDir) as $file) {
123-
$content = preg_replace(
124-
'/C\:\d+\:"'.preg_quote($class.$this->getTempKernelSuffix(), '"/').'"/',
125-
sprintf('C:%s:"%s"', strlen($class), $class),
126-
file_get_contents($file)
127-
);
128-
file_put_contents($file, $content);
129-
}
130141
}
131142

132143
protected function getTempKernelSuffix()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
269269
$loader->load('routing.xml');
270270

271271
$container->setParameter('router.resource', $config['resource']);
272+
$container->setParameter('router.cache_class_prefix', $container->getParameter('kernel.name').ucfirst($container->getParameter('kernel.environment')));
272273
$router = $container->findDefinition('router.default');
273-
274274
$argument = $router->getArgument(2);
275275
$argument['strict_requirements'] = $config['strict_requirements'];
276276
if (isset($config['type'])) {

src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
<parameter key="router.options.matcher_base_class">Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher</parameter>
2020
<parameter key="router.options.matcher_dumper_class">Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper</parameter>
2121
<parameter key="router.cache_warmer.class">Symfony\Bundle\FrameworkBundle\CacheWarmer\RouterCacheWarmer</parameter>
22-
<parameter key="router.options.matcher.cache_class">%kernel.name%%kernel.environment%UrlMatcher</parameter>
23-
<parameter key="router.options.generator.cache_class">%kernel.name%%kernel.environment%UrlGenerator</parameter>
22+
<parameter key="router.options.matcher.cache_class">%router.cache_class_prefix%UrlMatcher</parameter>
23+
<parameter key="router.options.generator.cache_class">%router.cache_class_prefix%UrlGenerator</parameter>
2424
<parameter key="router_listener.class">Symfony\Component\HttpKernel\EventListener\RouterListener</parameter>
2525
<parameter key="router.request_context.host">localhost</parameter>
2626
<parameter key="router.request_context.scheme">http</parameter>

src/Symfony/Component/Console/Input/StringInput.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ class StringInput extends ArgvInput
3939
*/
4040
public function __construct($input, InputDefinition $definition = null)
4141
{
42-
parent::__construct(array(), $definition);
42+
parent::__construct(array(), null);
4343

4444
$this->setTokens($this->tokenize($input));
45+
46+
if (null !== $definition) {
47+
$this->bind($definition);
48+
}
4549
}
4650

4751
/**

src/Symfony/Component/Console/Tests/Input/StringInputTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ public function testInputOptionWithGivenString()
3535
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
3636
);
3737

38+
// call to bind
3839
$input = new StringInput('--foo=bar');
3940
$input->bind($definition);
40-
$actual = $input->getOption('foo');
41+
$this->assertEquals('bar', $input->getOption('foo'));
4142

42-
$this->assertEquals('bar', $actual);
43+
// definition in constructor
44+
$input = new StringInput('--foo=bar', $definition);
45+
$this->assertEquals('bar', $input->getOption('foo'));
4346
}
4447

4548
public function getTokenizeData()

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,12 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
431431

432432
$this->loading[$id] = true;
433433

434-
$service = $this->createService($definition, $id);
434+
try {
435+
$service = $this->createService($definition, $id);
436+
} catch (\Exception $e) {
437+
unset($this->loading[$id]);
438+
throw $e;
439+
}
435440

436441
unset($this->loading[$id]);
437442

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\DependencyInjection\ContainerBuilder;
2020
use Symfony\Component\DependencyInjection\ContainerInterface;
2121
use Symfony\Component\DependencyInjection\Definition;
22+
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
2223
use Symfony\Component\DependencyInjection\Reference;
2324
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
2425
use Symfony\Component\Config\Resource\FileResource;
@@ -116,6 +117,26 @@ public function testGet()
116117
$this->assertTrue($builder->get('bar') === $builder->get('bar'), '->get() always returns the same instance if the service is shared');
117118
}
118119

120+
/**
121+
* @covers \Symfony\Component\DependencyInjection\ContainerBuilder::get
122+
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
123+
* @expectedExceptionMessage You have requested a synthetic service ("foo"). The DIC does not know how to construct this service.
124+
*/
125+
public function testGetUnsetLoadingServiceWhenCreateServiceThrowsAnException()
126+
{
127+
$builder = new ContainerBuilder();
128+
$builder->register('foo', 'stdClass')->setSynthetic(true);
129+
130+
// we expect a RuntimeException here as foo is synthetic
131+
try {
132+
$builder->get('foo');
133+
} catch (RuntimeException $e) {
134+
}
135+
136+
// we must also have the same RuntimeException here
137+
$builder->get('foo');
138+
}
139+
119140
/**
120141
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::getServiceIds
121142
*/

src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,17 @@ private function storeData($key, $value)
238238

239239
return true;
240240
}
241+
242+
public function select($dbnum)
243+
{
244+
if (!$this->connected) {
245+
return false;
246+
}
247+
248+
if (0 > $dbnum) {
249+
return false;
250+
}
251+
252+
return true;
253+
}
241254
}

src/Symfony/Component/Yaml/Inline.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,6 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter
237237
*/
238238
private static function parseQuotedScalar($scalar, &$i)
239239
{
240-
// Only check the current item we're dealing with (for sequences)
241-
$subject = substr($scalar, $i);
242-
$items = preg_split('/[\'"]\s*(?:[,:]|[}\]]\s*,)/', $subject);
243-
$subject = substr($subject, 0, strlen($items[0]) + 1);
244-
245240
if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
246241
throw new ParseException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i)));
247242
}

0 commit comments

Comments
 (0)