Skip to content

Commit 17de127

Browse files
Merge branch '3.0' into 3.1
* 3.0: [VarDumper] Fix dumping jsons casted as arrays PassConfig::getMergePass is not an array Revert "bug symfony#19114 [HttpKernel] Dont close the reponse stream in debug (nicolas-grekas)" Fix the retrieval of the last username when using forwarding [Yaml] Fix PHPDoc of the Yaml class [HttpFoundation] Add OPTIONS and TRACE to the list of safe methods Update getAbsoluteUri() for query string uris Conflicts: src/Symfony/Component/Yaml/Yaml.php
2 parents cf691fb + 8a2d5cd commit 17de127

File tree

14 files changed

+215
-45
lines changed

14 files changed

+215
-45
lines changed

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,9 @@ protected function getAbsoluteUri($uri)
542542
return parse_url($currentUri, PHP_URL_SCHEME).':'.$uri;
543543
}
544544

545-
// anchor?
546-
if (!$uri || '#' == $uri[0]) {
547-
return preg_replace('/#.*?$/', '', $currentUri).$uri;
545+
// anchor or query string parameters?
546+
if (!$uri || '#' == $uri[0] || '?' == $uri[0]) {
547+
return preg_replace('/[#?].*?$/', '', $currentUri).$uri;
548548
}
549549

550550
if ('/' !== $uri[0]) {

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,15 @@ public function testRequestURIConversion()
212212
$client->request('GET', 'http://www.example.com/');
213213
$client->request('GET', 'http');
214214
$this->assertEquals('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs');
215+
216+
$client = new TestClient();
217+
$client->request('GET', 'http://www.example.com/foo');
218+
$client->request('GET', '?');
219+
$this->assertEquals('http://www.example.com/foo?', $client->getRequest()->getUri(), '->request() uses the previous request for ?');
220+
$client->request('GET', '?');
221+
$this->assertEquals('http://www.example.com/foo?', $client->getRequest()->getUri(), '->request() uses the previous request for ?');
222+
$client->request('GET', '?foo=bar');
223+
$this->assertEquals('http://www.example.com/foo?foo=bar', $client->getRequest()->getUri(), '->request() uses the previous request for ?');
215224
}
216225

217226
public function testRequestReferer()

src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ public function getRemovingPasses()
153153
}
154154

155155
/**
156-
* Gets all passes for the Merge pass.
156+
* Gets the Merge pass.
157157
*
158-
* @return array An array of passes
158+
* @return CompilerPassInterface The merge pass
159159
*/
160160
public function getMergePass()
161161
{

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ public function isMethod($method)
14791479
*/
14801480
public function isMethodSafe()
14811481
{
1482-
return in_array($this->getMethod(), array('GET', 'HEAD'));
1482+
return in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
14831483
}
14841484

14851485
/**

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,12 @@ public function send()
377377
$this->sendHeaders();
378378
$this->sendContent();
379379

380+
if (function_exists('fastcgi_finish_request')) {
381+
fastcgi_finish_request();
382+
} elseif ('cli' !== PHP_SAPI) {
383+
static::closeOutputBuffers(0, true);
384+
}
385+
380386
return $this;
381387
}
382388

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,32 @@ public function getLongHostNames()
19511951
array(str_repeat(':', 101)),
19521952
);
19531953
}
1954+
1955+
/**
1956+
* @dataProvider methodSafeProvider
1957+
*/
1958+
public function testMethodSafe($method, $safe)
1959+
{
1960+
$request = new Request();
1961+
$request->setMethod($method);
1962+
$this->assertEquals($safe, $request->isMethodSafe());
1963+
}
1964+
1965+
public function methodSafeProvider()
1966+
{
1967+
return array(
1968+
array('HEAD', true),
1969+
array('GET', true),
1970+
array('POST', false),
1971+
array('PUT', false),
1972+
array('PATCH', false),
1973+
array('DELETE', false),
1974+
array('PURGE', false),
1975+
array('OPTIONS', true),
1976+
array('TRACE', true),
1977+
array('CONNECT', false),
1978+
);
1979+
}
19541980
}
19551981

19561982
class RequestContentProxy extends Request

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,6 @@ public function terminate(Request $request, Response $response)
134134
}
135135

136136
if ($this->getHttpKernel() instanceof TerminableInterface) {
137-
if (!$this->debug) {
138-
if (function_exists('fastcgi_finish_request')) {
139-
fastcgi_finish_request();
140-
} elseif ('cli' !== PHP_SAPI) {
141-
Response::closeOutputBuffers(0, true);
142-
}
143-
}
144-
145137
$this->getHttpKernel()->terminate($request, $response);
146138
}
147139
}

src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ public function getLastAuthenticationError($clearSession = true)
6565
*/
6666
public function getLastUsername()
6767
{
68-
$session = $this->getRequest()->getSession();
68+
$request = $this->getRequest();
69+
70+
if ($request->attributes->has(Security::LAST_USERNAME)) {
71+
return $request->attributes->get(Security::LAST_USERNAME);
72+
}
73+
74+
$session = $request->getSession();
6975

7076
return null === $session ? '' : $session->get(Security::LAST_USERNAME);
7177
}

src/Symfony/Component/VarDumper/Caster/Caster.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ public static function castObject($obj, \ReflectionClass $reflector)
4545
{
4646
if ($reflector->hasMethod('__debugInfo')) {
4747
$a = $obj->__debugInfo();
48+
} elseif ($obj instanceof \Closure) {
49+
$a = array();
4850
} else {
4951
$a = (array) $obj;
5052
}
5153

5254
if ($a) {
5355
$p = array_keys($a);
5456
foreach ($p as $i => $k) {
55-
if (!isset($k[0]) || ("\0" !== $k[0] && !$reflector->hasProperty($k))) {
57+
if (isset($k[0]) && "\0" !== $k[0] && !$reflector->hasProperty($k)) {
5658
$p[$i] = self::PREFIX_DYNAMIC.$k;
5759
} elseif (isset($k[16]) && "\0" === $k[16] && 0 === strpos($k, "\0class@anonymous\0")) {
5860
$p[$i] = "\0".$reflector->getParentClass().'@anonymous'.strrchr($k, "\0");

src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static function castClosure(\Closure $c, array $a, Stub $stub, $isNested)
5858
}
5959

6060
$prefix = Caster::PREFIX_DYNAMIC;
61-
unset($a['name'], $a[$prefix.'0'], $a[$prefix.'this'], $a[$prefix.'parameter'], $a[Caster::PREFIX_VIRTUAL.'extra']);
61+
unset($a['name'], $a[$prefix.'this'], $a[$prefix.'parameter'], $a[Caster::PREFIX_VIRTUAL.'extra']);
6262

6363
return $a;
6464
}

0 commit comments

Comments
 (0)