8000 Merge branch '2.7' into 2.8 · symfony/symfony@68fdb02 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 68fdb02

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Debug] cleanup ExceptionHandlerTest bumped Symfony version to 2.7.4 updated VERSION for 2.7.3 updated CHANGELOG for 2.7.3 fixed typo in translation keys Fix the return value on error for intl methods returning arrays Fix merge Fix missing _route parameter notice in RouterListener logging case Conflicts: src/Symfony/Component/Debug/composer.json src/Symfony/Component/HttpKernel/Kernel.php
2 parents 839e925 + 9058904 commit 68fdb02

File tree

13 files changed

+173
-68
lines changed

13 files changed

+173
-68
lines changed

CHANGELOG-2.7.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ in 2.7 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.7.0...v2.7.1
99

10+
* 2.7.3 (2015-07-31)
11+
12+
* bug #15413 Fix the return value on error for intl methods returning arrays (stof)
13+
* bug #15392 Fix missing _route parameter notice in RouterListener logging case (Haehnchen)
14+
* bug #15390 [php7] Fix for substr() always returning a string (nicolas-grekas)
15+
* bug #15386 [php7] Fix for substr() always returning a string (nicolas-grekas)
16+
* bug #15355 [Security] Do not save the target path in the session for a stateless firewall (lyrixx)
17+
* bug #15306 [HttpKernel] [HttpCache] Fix deprecated error in HttpCache#getSurrogate (m14t)
18+
* bug #15369 [TwigBridge] type-dependent path discovery (marcosdsanchez, xabbuh)
19+
* bug #15361 [Yaml] throw a ParseException on invalid data type (xabbuh)
20+
* bug #15345 [Twig+FrameworkBundle] Fix forward compat with Form 2.8 (nicolas-grekas)
21+
* bug #15330 [Console] Fix console output with closed stdout (jakzal)
22+
* bug #15339 [Serializer] Fix 2 bugs regarding private setters (dunglas)
23+
* bug #15326 [Security] fix check for empty usernames (xabbuh)
24+
* bug #15291 [HttpFoundation] Fix Response::closeOutputBuffers() for HHVM 3.3 (nicolas-grekas)
25+
* bug #15249 [HttpFoundation] [PSR-7] Allow to use resources as content body and to return resources from string content (dunglas)
26+
* bug #15282 [HttpFoundation] Behaviour change in PHP7 for substr (Nicofuma)
27+
* bug #15277 [Form] Fix a BC break in the entity (jakzal)
28+
* bug #15271 fix broken ChoiceQuestion (sstok)
29+
* bug #15250 [PropertyAccess] BC Break since 2.6.5 (Nicolas Macherey)
30+
1031
* 2.7.2 (2015-07-13)
1132

1233
* bug #15248 Added 'default' color (jaytaph)

src/Symfony/Component/Debug/ExceptionHandler.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ExceptionHandler
3838

3939
public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
4040
{
41-
if (false !== strpos($charset, '%') xor false === strpos($fileLinkFormat, '%')) {
41+
if (false !== strpos($charset, '%')) {
4242
// Swap $charset and $fileLinkFormat for BC reasons
4343
$pivot = $fileLinkFormat;
4444
$fileLinkFormat = $charset;
@@ -153,19 +153,22 @@ public function handle(\Exception $exception)
153153
* it will fallback to plain PHP functions.
154154
*
155155
* @param \Exception $exception An \Exception instance
156-
*
157-
* @see sendPhpResponse()
158-
* @see createResponse()
159156
*/
160157
private function failSafeHandle(\Exception $exception)
161158
{
162-
if (class_exists('Symfony\Component\HttpFoundation\Response', false)) {
159+
if (class_exists('Symfony\Component\HttpFoundation\Response', false)
160+
&& __CLASS__ !== get_class($this)
161+
&& ($reflector = new \ReflectionMethod($this, 'createResponse'))
162+
&& __CLASS__ !== $reflector->class
163+
) {
163164
$response = $this->createResponse($exception);
164165
$response->sendHeaders();
165166
$response->sendContent();
166-
} else {
167-
$this->sendPhpResponse($exception);
167+
168+
return;
168169
}
170+
171+
$this->sendPhpResponse($exception);
169172
}
170173

171174
/**

src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php

Lines changed: 61 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,71 +13,97 @@
1313

1414
use Symfony\Component\Debug\ExceptionHandler;
1515
use Symfony\Component\Debug\Exception\OutOfMemoryException;
16-
use Symfony\Component\HttpFoundation\Response;
1716
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1817
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
1918

19+
require_once __DIR__.'/HeaderMock.php';
20+
2021
class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase
2122
{
23+
protected function setUp()
24+
{
25+
testHeader();
26+
}
27+
28+
protected function tearDown()
29+
{
30+
testHeader();
31+
}
32+
2233
public function testDebug()
2334
{
2435
$handler = new ExceptionHandler(false);
25-
$response = $handler->createResponse(new \RuntimeException('Foo'));
2636

27-
$this->assertContains('<h1>Whoops, looks like something went wrong.</h1>', $response->getContent());
28-
$this->assertNotContains('<h2 class="block_exception clear_fix">', $response->getContent());
37+
ob_start();
38+
$handler->sendPhpResponse(new \RuntimeException('Foo'));
39+
$response = ob_get_clean();
40+
41+
$this->assertContains('<h1>Whoops, looks like something went wrong.</h1>', $response);
42+
$this->assertNotContains('<h2 class="block_exception clear_fix">', $response);
2943

3044
$handler = new ExceptionHandler(true);
31-
$response = $handler->createResponse(new \RuntimeException('Foo'));
3245

33-
$this->assertContains('<h1>Whoops, looks like something went wrong.</h1>', $response->getContent());
34-
$this->assertContains('<h2 class="block_exception clear_fix">', $response->getContent());
46+
ob_start();
47+
$handler->sendPhpResponse(new \RuntimeException('Foo'));
48+
$response = ob_get_clean();
49+
50+
$this->assertContains('<h1>Whoops, looks like something went wrong.</h1>', $response);
51+
$this->assertContains('<h2 class="block_exception clear_fix">', $response);
3552
}
3653

3754
public function testStatusCode()
3855
{
39-
$handler = new ExceptionHandler(false);
56+
$handler = new ExceptionHandler(false, 'iso8859-1');
57+
58+
ob_start();
59+
$handler->sendPhpResponse(new NotFoundHttpException('Foo'));
60+
$response = ob_get_clean();
61+
62+
$this->assertContains('Sorry, the page you are looking for could not be found.', $response);
4063

41-
$response = $handler->createResponse(new \RuntimeException('Foo'));
42-
$this->assertEquals('500', $response->getStatusCode());
43-
$this->assertContains('Whoops, looks like something went wrong.', $response->getContent());
64+
$expectedHeaders = array(
65+
array('HTTP/1.0 404', true, null),
66+
array('Content-Type: text/html; charset=iso8859-1', true, null),
67+
);
4468

45-
$response = $handler->createResponse(new NotFoundHttpException('Foo'));
46-
$this->assertEquals('404', $response->getStatusCode());
47-
$this->assertContains('Sorry, the page you are looking for could not be found.', $response->getContent());
69+
$this->assertSame($expectedHeaders, testHeader());
4870
}
4971

5072
public function testHeaders()
5173
{
52-
$handler = new ExceptionHandler(false);
74+
$handler = new ExceptionHandler(false, 'iso8859-1');
75+
76+
ob_start();
77+
$handler->sendPhpResponse(new MethodNotAllowedHttpException(array('POST')));
78+
$response = ob_get_clean();
5379

54-
$response = $handler->createResponse(new MethodNotAllowedHttpException(array('POST')));
55-
$this->assertEquals('405', $response->getStatusCode());
56-
$this->assertEquals('POST', $response->headers->get('Allow'));
80+
$expectedHeaders = array(
81+
array('HTTP/1.0 405', true, null),
82+
array('Allow: POST', false, null),
83+
array('Content-Type: text/html; charset=iso8859-1', true, null),
84+
);
85+
86+
$this->assertSame($expectedHeaders, testHeader());
5787
}
5888

5989
public function testNestedExceptions()
6090
{
6191
$handler = new ExceptionHandler(true);
62-
$response = $handler->createResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar')));
92+
ob_start();
93+
$handler->sendPhpResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar')));
94+
$response = ob_get_clean();
95+
96+
$this->assertStringMatchesFormat('%A<span class="exception_message">Foo</span>%A<span cl F438 ass="exception_message">Bar</span>%A', $response);
6397
}
6498

6599
public function testHandle()
66100
{
67101
$exception = new \Exception('foo');
68102

69-
if (class_exists('Symfony\Component\HttpFoundation\Response')) {
70-
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('createResponse'));
71-
$handler
72-
->expects($this->exactly(2))
73-
->method('createResponse')
74-
->will($this->returnValue(new Response()));
75-
} else {
76-
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
77-
$handler
78-
->expects($this->exactly(2))
79-
->method('sendPhpResponse');
80-
}
103+
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
104+
$handler
105+
->expects($this->exactly(2))
106+
->method('sendPhpResponse');
81107

82108
$handler->handle($exception);
83109

@@ -93,18 +119,10 @@ public function testHandleOutOfMemoryException()
93119
{
94120
$exception = new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__);
95121

96-
if (class_exists('Symfony\Component\HttpFoundation\Response')) {
97-
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('createResponse'));
98-
$handler
99-
->expects($this->once())
100-
->method('createResponse')
101-
->will($this->returnValue(new Response()));
102-
} else {
103-
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
104-
$handler
105-
->expects($this->once())
106-
->method('sendPhpResponse');
107-
}
122+
$handler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('sendPhpResponse'));
123+
$handler
124+
->expects($this->once())
125+
->method('sendPhpResponse');
108126

109127
$that = $this;
110128
$handler->setHandler(function ($e) use ($that) {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Debug;
13+
14+
function headers_sent()
15+
{
16+
return false;
17+
}
18+
19+
function header($str, $replace = true, $status = null)
20+
{
21+
Tests\testHeader($str, $replace, $status);
22+
}
23+
24+
namespace Symfony\Component\Debug\Tests;
25+
26+
function testHeader()
27+
{
28+
static $headers = array();
29+
30+
if (!$h = func_get_args()) {
31+
$h = $headers;
32+
$headers = array();
33+
34+
return $h;
35+
}
36+
37+
$headers[] = func_get_args();
38+
}

src/Symfony/Component/Debug/composer.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@
2525
"require-dev": {
2626
"symfony/phpunit-bridge": "~2.7|~3.0.0",
2727
"symfony/class-loader": "~2.2|~3.0.0",
28-
"symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2|~3.0.0",
29-
"symfony/http-foundation": "~2.1|~3.0.0"
30-
},
31-
"suggest": {
32-
"symfony/http-foundation": "",
33-
"symfony/http-kernel": ""
28+
"symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2|~3.0.0"
3429
},
3530
"autoload": {
3631
"psr-4": { "Symfony\\Component\\Debug\\": "" }

src/Symfony/Component/HttpKernel/EventListener/RouterListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function onKernelRequest(GetResponseEvent $event)
140140
}
141141

142142
if (null !== $this->logger) {
143-
$this->logger->info(sprintf('Matched route "%s".', $parameters['_route']), array(
143+
$this->logger->info(sprintf('Matched route "%s".', isset($parameters['_route']) ? $parameters['_route'] : 'n/a'), array(
144144
'route_parameters' => $parameters,
145145
'request_uri' => $request->getUri(),
146146
));

src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,34 @@ public function testSubRequestWithDifferentMethod()
128128

129129
$this->assertEquals( 10000 'GET', $context->getMethod());
130130
}
131+
132+
/**
133+
* @dataProvider getLoggingParameterData
134+
*/
135+
public function testLoggingParameter($parameter, $log)
136+
{
137+
$requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface');
138+
$requestMatcher->expects($this->once())
139+
->method('matchRequest')
140+
->will($this->returnValue($parameter));
141+
142+
$logger = $this->getMock('Psr\Log\LoggerInterface');
143+
$logger->expects($this->once())
144+
->method('info')
145+
->with($this->equalTo($log));
146+
147+
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
148+
$request = Request::create('http://localhost/');
149+
150+
$listener = new RouterListener($requestMatcher, new RequestContext(), $logger, $this->requestStack);
151+
$listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
152+
}
153+
154+
public function getLoggingParameterData()
155+
{
156+
return array(
157+
array(array('_route' => 'foo'), 'Matched route "foo".'),
158+
array(array(), 'Matched route "n/a".'),
159+
);
160+
}
131161
}

src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function getCurrencyNames($displayLocale = null)
7676
try {
7777
return $this->getNames($displayLocale);
7878
} catch (MissingResourceException $e) {
79-
return;
79+
return array();
8080
}
8181
}
8282

@@ -112,7 +112,7 @@ public function getLocales()
112112
try {
113113
return $this->localeProvider->getLocales();
114114
} catch (MissingResourceException $e) {
115-
return;
115+
return array();
116116
}
117117
}
118118
}

src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function getLanguageNames($displayLocale = null)
8080
try {
8181
return $this->getNames($displayLocale);
8282
} catch (MissingResourceException $e) {
83-
return;
83+
return array();
8484
}
8585
}
8686

@@ -104,7 +104,7 @@ public function getScriptNames($displayLocale = null)
104104
try {
105105
return $this->scriptProvider->getNames($displayLocale);
106106
} catch (MissingResourceException $e) {
107-
return;
107+
return array();
108108
}
109109
}
110110

@@ -116,7 +116,7 @@ public function getLocales()
116116
try {
117117
return $this->localeProvider->getLocales();
118118
} catch (MissingResourceException $e) {
119-
return;
119+
return array();
120120
}
121121
}
122122
}

src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function getLocales()
3131
try {
3232
return parent::getLocales();
3333
} catch (MissingResourceException $e) {
34-
return;
34+
return array();
3535
}
3636
}
3737

@@ -55,7 +55,7 @@ public function getLocaleNames($displayLocale = null)
5555
try {
5656
return $this->getNames($displayLocale);
5757
} catch (MissingResourceException $e) {
58-
return;
58+
return array();
5959
}
6060
}
6161
}

src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getCountryNames($displayLocale = null)
6464
try {
6565
return $this->getNames($displayLocale);
6666
} catch (MissingResourceException $e) {
67-
return;
67+
return array();
6868
}
6969
}
7070

@@ -76,7 +76,7 @@ public function getLocales()
7676
try {
7777
return $this->localeProvider->getLocales();
7878
} catch (MissingResourceException $e) {
79-
return;
79+
return array();
8080
}
8181
}
8282
}

0 commit comments

Comments
 (0)
0