Skip to content

Commit 0e6fbad

Browse files
committed
Merge branch '2.1' into 2.2
* 2.1: Fix default value handling for multi-value options [HttpKernel] truncate profiler token to 6 chars (see #7665) Disabled APC on Travis for PHP 5.5+ as it is not available [HttpFoundation] do not use server variable PATH_INFO because it is already decoded and thus symfony is fragile to double encoding of the path [Yaml] improved boolean naming ($notEOF -> !$EOF) [Yaml] fixed handling an empty value [Routing][XML Loader] Add a possibility to set a default value to null The /e modifier for preg_replace() is deprecated in PHP 5.5; replace with preg_replace_callback() [HttpFoundation] Fixed bug in key searching for NamespacedAttributeBag [Form] DateTimeToRfc3339Transformer use proper transformation exteption in reverse transformation Update PhpEngine.php [HttpFoundation] getClientIp is fixed. Conflicts: .travis.yml src/Symfony/Component/Routing/Loader/XmlFileLoader.php src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
2 parents 17ba72b + f1b5c69 commit 0e6fbad

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

ApacheRequest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,4 @@ protected function prepareBaseUrl()
4040

4141
return $baseUrl;
4242
}
43-
44-
/**
45-
* {@inheritdoc}
46-
*/
47-
protected function preparePathInfo()
48-
{
49-
return $this->server->get('PATH_INFO') ?: substr($this->prepareRequestUri(), strlen($this->prepareBaseUrl())) ?: '/';
50-
}
5143
}

Request.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,10 @@ public function getClientIp()
721721
$clientIps[] = $ip;
722722

723723
$trustedProxies = self::$trustProxy && !self::$trustedProxies ? array($ip) : self::$trustedProxies;
724+
$ip = $clientIps[0];
724725
$clientIps = array_diff($clientIps, $trustedProxies);
725726

726-
return array_pop($clientIps);
727+
return $clientIps ? array_pop($clientIps) : $ip;
727728
}
728729

729730
/**

Session/Attribute/NamespacedAttributeBag.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public function has($name)
4646
$attributes = $this->resolveAttributePath($name);
4747
$name = $this->resolveKey($name);
4848

49+
if (null === $attributes) {
50+
return false;
51+
}
52+
4953
return array_key_exists($name, $attributes);
5054
}
5155

@@ -57,6 +61,10 @@ public function get($name, $default = null)
5761
$attributes = $this->resolveAttributePath($name);
5862
$name = $this->resolveKey($name);
5963

64+
if (null === $attributes) {
65+
return $default;
66+
}
67+
6068
return array_key_exists($name, $attributes) ? $attributes[$name] : $default;
6169
}
6270

@@ -120,12 +128,8 @@ protected function &resolveAttributePath($name, $writeContext = false)
120128
unset($parts[count($parts)-1]);
121129

122130
foreach ($parts as $part) {
123-
if (!array_key_exists($part, $array)) {
124-
if (!$writeContext) {
125-
return $array;
126-
}
127-
128-
$array[$part] = array();
131+
if (null !== $array && !array_key_exists($part, $array)) {
132+
$array[$part] = $writeContext ? array() : null;
129133
}
130134

131135
$array = & $array[$part];

Tests/RequestTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,7 @@ public function testGetClientIpProvider()
778778
{
779779
return array(
780780
array('88.88.88.88', false, '88.88.88.88', null, null),
781+
array('88.88.88.88', true, '88.88.88.88', null, null),
781782
array('127.0.0.1', false, '127.0.0.1', null, null),
782783
array('::1', false, '::1', null, null),
783784
array('127.0.0.1', false, '127.0.0.1', '88.88.88.88', null),
@@ -786,6 +787,8 @@ public function testGetClientIpProvider()
786787
array('88.88.88.88', true, '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', null),
787788
array('87.65.43.21', true, '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', array('123.45.67.89', '88.88.88.88')),
788789
array('87.65.43.21', false, '123.45.67.89', '127.0.0.1, 87.65.43.21, 88.88.88.88', array('123.45.67.89', '88.88.88.88')),
790+
array('88.88.88.88', true, '123.45.67.89', '88.88.88.88', array('123.45.67.89', '88.88.88.88')),
791+
array('88.88.88.88', false, '123.45.67.89', '88.88.88.88', array('123.45.67.89', '88.88.88.88')),
789792
);
790793
}
791794

Tests/Session/Attribute/NamespacedAttributeBagTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ public function attributesProvider()
160160
array('csrf.token/b', '4321', true),
161161
array('category', array('fishing' => array('first' => 'cod', 'second' => 'sole')), true),
162162
array('category/fishing', array('first' => 'cod', 'second' => 'sole'), true),
163+
array('category/fishing/missing/first', null, false),
163164
array('category/fishing/first', 'cod', true),
164165
array('category/fishing/second', 'sole', true),
166+
array('category/fishing/missing/second', null, false),
165167
array('user2.login', null, false),
166168
array('never', null, false),
167169
array('bye', null, false),

0 commit comments

Comments
 (0)