Skip to content

Commit

Permalink
Merge branch '2.1' into 2.2
Browse files Browse the repository at this point in the history
* 2.1:
  #7106 - fix for ZTS builds
  Added '@@' escaping strategy for YamlFileLoader and YamlDumper
  [Yaml] fixed bugs with folded scalar parsing
  [Form] made DefaultCsrfProvider using session_status() when available
  Added unit tests to Dumper
  Update .travis.yml (closes #7355)
  [HttpFoudantion] fixed Request::getPreferredLanguage()
  Revert "merged branch jfsimon/issue-6928 (PR #7378)"
  Routing issue with installation in a sub-directory ref: symfony/symfony#7129

Conflicts:
	.travis.yml
	src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
	src/Symfony/Component/Routing/RouteCollection.php
  • Loading branch information
fabpot committed Mar 23, 2013
2 parents 847f610 + 07a4b55 commit 31af841
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dumper/YamlDumper.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private function prepareParameters($parameters, $escape = true)
foreach ($parameters as $key => $value) { foreach ($parameters as $key => $value) {
if (is_array($value)) { if (is_array($value)) {
$value = $this->prepareParameters($value, $escape); $value = $this->prepareParameters($value, $escape);
} elseif ($value instanceof Reference) { } elseif ($value instanceof Reference || is_string($value) && 0 === strpos($value, '@')) {
$value = '@'.$value; $value = '@'.$value;
} }


Expand Down
9 changes: 7 additions & 2 deletions Loader/YamlFileLoader.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ private function resolveServices($value)
if (is_array($value)) { if (is_array($value)) {
$value = array_map(array($this, 'resolveServices'), $value); $value = array_map(array($this, 'resolveServices'), $value);
} elseif (is_string($value) && 0 === strpos($value, '@')) { } elseif (is_string($value) && 0 === strpos($value, '@')) {
if (0 === strpos($value, '@?')) { if (0 === strpos($value, '@@')) {
$value = substr($value, 1);
$invalidBehavior = null;
} elseif (0 === strpos($value, '@?')) {
$value = substr($value, 2); $value = substr($value, 2);
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
} else { } else {
Expand All @@ -305,7 +308,9 @@ private function resolveServices($value)
$strict = true; $strict = true;
} }


$value = new Reference($value, $invalidBehavior, $strict); if (null !== $invalidBehavior) {
$value = new Reference($value, $invalidBehavior, $strict);
}
} }


return $value; return $value;
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/containers/container8.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'FOO' => '%baz%', 'FOO' => '%baz%',
'baz' => 'bar', 'baz' => 'bar',
'bar' => 'foo is %%foo bar', 'bar' => 'foo is %%foo bar',
'escape' => '@escapeme',
'values' => array(true, false, null, 0, 1000.3, 'true', 'false', 'null'), 'values' => array(true, false, null, 0, 1000.3, 'true', 'false', 'null'),
))); )));


Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/php/services8.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ protected function getDefaultParameters()
'foo' => '%baz%', 'foo' => '%baz%',
'baz' => 'bar', 'baz' => 'bar',
'bar' => 'foo is %%foo bar', 'bar' => 'foo is %%foo bar',
'escape' => '@escapeme',
'values' => array( 'values' => array(
0 => true, 0 => true,
1 => false, 1 => false,
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/xml/services8.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<parameter key="foo">%baz%</parameter> <parameter key="foo">%baz%</parameter>
<parameter key="baz">bar</parameter> <parameter key="baz">bar</parameter>
<parameter key="bar">foo is %%foo bar</parameter> <parameter key="bar">foo is %%foo bar</parameter>
<parameter key="escape">@escapeme</parameter>
<parameter key="values" type="collection"> <parameter key="values" type="collection">
<parameter>true</parameter> <parameter>true</parameter>
<parameter>false</parameter> <parameter>false</parameter>
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/yaml/services2.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ parameters:
- 0 - 0
- 1000.3 - 1000.3
bar: foo bar: foo
escape: @@escapeme
foo_bar: @foo_bar foo_bar: @foo_bar
MixedCase: MixedCase:
MixedCaseKey: value MixedCaseKey: value
1 change: 1 addition & 0 deletions Tests/Fixtures/yaml/services8.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ parameters:
foo: '%baz%' foo: '%baz%'
baz: bar baz: bar
bar: 'foo is %%foo bar' bar: 'foo is %%foo bar'
escape: '@@escapeme'
values: [true, false, null, 0, 1000.3, 'true', 'false', 'null'] values: [true, false, null, 0, 1000.3, 'true', 'false', 'null']


4 changes: 2 additions & 2 deletions Tests/Loader/YamlFileLoaderTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testLoadParameters()
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('services2.yml'); $loader->load('services2.yml');
$this->assertEquals(array('foo' => 'bar', 'mixedcase' => array('MixedCaseKey' => 'value'), 'values' => array(true, false, 0, 1000.3), 'bar' => 'foo', 'foo_bar' => new Reference('foo_bar')), $container->getParameterBag()->all(), '->load() converts YAML keys to lowercase'); $this->assertEquals(array('foo' => 'bar', 'mixedcase' => array('MixedCaseKey' => 'value'), 'values' => array(true, false, 0, 1000.3), 'bar' => 'foo', 'escape' => '@escapeme', 'foo_bar' => new Reference('foo_bar')), $container->getParameterBag()->all(), '->load() converts YAML keys to lowercase');
} }


public function testLoadImports() public function testLoadImports()
Expand All @@ -99,7 +99,7 @@ public function testLoadImports()
$loader->load('services4.yml'); $loader->load('services4.yml');


$actual = $container->getParameterBag()->all(); $actual = $container->getParameterBag()->all();
$expected = array('foo' => 'bar', 'values' => array(true, false), 'bar' => '%foo%', 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value'), 'imported_from_ini' => true, 'imported_from_xml' => true); $expected = array('foo' => 'bar', 'values' => array(true, false), 'bar' => '%foo%', 'escape' => '@escapeme', 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value'), 'imported_from_ini' => true, 'imported_from_xml' => true);
$this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files'); $this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files');


// Bad import throws no exception due to ignore_errors value. // Bad import throws no exception due to ignore_errors value.
Expand Down

0 comments on commit 31af841

Please sign in to comment.