8000 Merge branch '2.6' into 2.7 · symfony/symfony@6d605a7 · GitHub
[go: up one dir, main page]

Skip to content {"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}

Commit 6d605a7

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: [HttpFoundation] MongoDbSessionHandler::read() now checks for valid session age Changed visibility of setUp() and tearDown to protected [WebProfilerBundle] Set debug+charset on the ExceptionHandler fallback Added default button class used HTML5 meta charset tag and removed hardcoded ones Revert "bug #13715 Enforce UTF-8 charset for core controllers (WouterJ)" fixed XSS in the exception handler Php Inspections (EA Extended) - static code analysis includes: [2.3] Remove most refs uses Test with local components instead of waiting for the subtree-splitter when possible Conflicts: .travis.yml
2 parents 6963887 + 43efb1a commit 6d605a7

File tree

51 files changed

+228
-222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+228
-222
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ phpunit.xml
22
composer.lock
33
composer.phar
44
autoload.php
5+
package*.tar
6+
packages.json
57
/vendor/

.travis.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
branch=$1
2+
if [ -z "$branch" ]; then
3+
echo 'Usage: branch dir1 dir2 ... dirN'
4+
exit 1
5+
fi
6+
shift
7+
components=$*
8+
if [ -z "$components" ]; then
9+
echo 'Usage: branch dir1 dir2 ... dirN'
10+
exit 1
11+
fi
12+
echo '{"packages": {' > packages.json
13+
components=$(
14+
for c in $components; do
15+
sed -i ':a;N;$!ba;s#^{\n\(\s*\)\("name"\)#{\n\1"repositories": \[{ "type": "composer", "url": "file://'$(pwd)'/" }\],\n\1\2#' $c/composer.json
16+
n=$(php -r '$n=json_decode(file_get_contents("'$c'/composer.json"));echo $n->name;')
17+
echo '"'$n'": {"'$branch'.x-dev": ' >> packages.json
18+
cat $c/composer.json >> packages.json
19+
echo '"version": "'$branch.x-dev'",\n "dist": {"type": "tar", "url": "file://'$(pwd)/$c'/package'$branch'.tar"}\n}},' >> packages.json
20+
echo $c
21+
done;
22+
)
23+
sed -i ':a;N;$!ba;s/\n}\n"/,\n "/g' packages.json
24+
sed -i ':a;N;$!ba;s/}},$/\n}}\n}}/' packages.json
25+
echo "$components" | parallel --gnu "cd {}; tar -cf package$branch.tar --exclude='package*.tar' *"

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ before_install:
3939

4040
install:
4141
- if [ "$deps" = "no" ]; then composer --prefer-source install; fi;
42+
- components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
43+
- if [ "$deps" != "no" ]; then sh .travis.sh $TRAVIS_BRANCH $components; fi;
4244

4345
script:
4446
- components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')

src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ private function sanitizeQueries($connectionName, $queries)
117117
private function sanitizeQuery($connectionName, $query)
118118
{
119119
$query['explainable'] = true;
120-
$query['params'] = (array) $query['params'];
121-
foreach ($query['params'] as $j => &$param) {
120+
if (!is_array($query['params'])) {
121+
$query['params'] = array($query['params']);
122+
}
123+
foreach ($query['params'] as $j => $param) {
122124
if (isset($query['types'][$j])) {
123125
// Transform the param according to the type
124126
$type = $query['types'][$j];
@@ -131,7 +133,7 @@ private function sanitizeQuery($connectionName, $query)
131133
}
132134
}
133135

134-
list($param, $explainable) = $this->sanitizeParam($param);
136+
list($query['params'][$j], $explainable) = $this->sanitizeParam($param);
135137
if (!$explainable) {
136138
$query['explainable'] = false;
137139
}

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Instantiator/RuntimeInstantiatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class RuntimeInstantiatorTest extends \PHPUnit_Framework_TestCase
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function setUp()
34+
protected function setUp()
3535
{
3636
$this->instantiator = new RuntimeInstantiator();
3737
}

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ProxyDumperTest extends \PHPUnit_Framework_TestCase
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function setUp()
34+
protected function setUp()
3535
{
3636
$this->dumper = new ProxyDumper();
3737
}

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
{%- endblock textarea_widget %}
1616

1717
{% block button_widget -%}
18-
{% set attr = attr|merge({class: (attr.class|default('') ~ ' btn')|trim}) %}
18+
{% set attr = attr|merge({class: (attr.class|default('btn-default') ~ ' btn')|trim}) %}
1919
{{- parent() -}}
2020
{%- endblock %}
2121

src/Symfony/Bridge/Twig/Translation/TwigExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function extractTemplate($template, MessageCatalogue $catalogue)
8484
$this->twig->parse($this->twig->tokenize($template));
8585

8686
foreach ($visitor->getMessages() as $message) {
87-
$catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ? $message[1] : $this->defaultDomain);
87+
$catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ?: $this->defaultDomain);
8888
}
8989

9090
$visitor->disable();

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function setUp()
2929
$this->loader->register();
3030
}
3131

32-
public function tearDown()
32+
protected function tearDown()
3333
{
3434
spl_autoload_unregister(array($this->loader, 'loadClass'));
3535

src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected function setUp()
2626
$this->deleteTmpDir();
2727
}
2828

29-
public function tearDown()
29+
protected function tearDown()
3030
{
3131
$this->deleteTmpDir();
3232
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/Resources/views/base.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta charset="UTF-8" />
4+
<meta charset="{{ _charset }}" />
55
<title>{% block title %}Welcome!{% endblock %}</title>
66
{% block stylesheets %}{% endblock %}
77
</head>

src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function showAction(Request $request, FlattenException $exception, DebugL
6262

6363
$code = $exception->getStatusCode();
6464

65-
return Response::create($this->twig->render(
65+
return new Response($this->twig->render(
6666
$this->findTemplate($request, $request->getRequestFormat(), $code, $showException),
6767
array(
6868
'status_code' => $code,
@@ -71,7 +71,7 @@ public function showAction(Request $request, FlattenException $exception, DebugL
7171
'logger' => $logger,
7272
'currentContent' => $currentContent,
7373
)
74-
))->setCharset('UTF-8');
74+
));
7575
}
7676

7777
/**

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ public function load(array $configs, ContainerBuilder $container)
3636
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
3737
$loader->load('twig.xml');
3838

39-
foreach ($configs as &$config) {
39+
foreach ($configs as $key => $config) {
4040
if (isset($config['globals'])) {
4141
foreach ($config['globals'] as $name => $value) {
4242
if (is_array($value) && isset($value['key'])) {
43-
$config['globals'][$name] = array(
43+
$configs[$key]['globals'][$name] = array(
4444
'key' => $name,
45-
'value' => $config['globals'][$name],
45+
'value' => $value,
4646
);
4747
}
4848
}

src/Symfony/Bundle/TwigBundle/Resources/views/Exception/error.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta charset="UTF-8" />
4+
<meta charset="{{ _charset }}" />
55
<title>An Error Occurred: {{ status_text }}</title>
66
</head>
77
<body>

src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ public function testOnlyClearOwnOutputBuffers()
4040
$request->headers->set('X-Php-Ob-Level', 1);
4141

4242
$controller = new ExceptionController($twig, false);
43-
$response = $controller->showAction($request, $flatten);
44-
$this->assertEquals('UTF-8', $response->getCharset(), 'Request charset is explicitly set to UTF-8');
43+
$controller->showAction($request, $flatten);
4544
}
4645

4746
public function testShowActionCanBeForcedToShowErrorPage()

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TwigLoaderPassTest extends \PHPUnit_Framework_TestCase
2929
*/
3030
private $pass;
3131

32-
public function setUp()
32+
protected function setUp()
3333
{
3434
$this->builder = $this->getMock(
3535
'Symfony\Component\DependencyInjection\ContainerBuilder',

src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class LegacyRenderTokenParserTest extends TestCase
1919
{
20-
public function setUp()
20+
protected function setUp()
2121
{
2222
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
2323
}

src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,23 @@ public function showAction($token)
5555
$template = $this->getTemplate();
5656

5757
if (!$this->twig->getLoader()->exists($template)) {
58-
$handler = new ExceptionHandler();
58+
$handler = new ExceptionHandler($this->debug, $this->twig->getCharset());
5959

6060
return new Response($handler->getContent($exception), 200, array('Content-Type' => 'text/html'));
6161
}
6262

6363
$code = $exception->getStatusCode();
6464

65-
return Response::create(
66-
$this->twig->render($template, array(
65+
return new Response($this->twig->render(
66+
$template,
67+
array(
6768
'status_code' => $code,
6869
'status_text' => Response::$statusTexts[$code],
6970
'exception' => $exception,
7071
'logger' => null,
7172
'currentContent' => '',
72-
)),
73-
200,
74-
array('Content-Type' => 'text/html')
75-
)->setCharset('UTF-8');
73+
)
74+
), 200, array('Content-Type' => 'text/html'));
7675
}
7776

7877
/**
@@ -96,16 +95,12 @@ public function cssAction($token)
9695
$template = $this->getTemplate();
9796

9897
if (!$this->templateExists($template)) {
99-
$handler = new ExceptionHandler();
98+
$handler = new ExceptionHandler($this->debug, $this->twig->getCharset());
10099

101-
$response = new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css'));
102-
} else {
103-
$response = new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css'));
100+
return new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css'));
104101
}
105102

106-
$response->setCharset('UTF-8');
107-
108-
return $response;
103+
return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css'));
109104
}
110105

111106
protected function getTemplate()

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 35 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,16 @@ public function panelAction(Request $request, $token)
9999
throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token));
100100
}
101101

102-
return Response::create(
103-
$this->twig->render($this->getTemplateManager()->getName($profile, $panel), array(
104-
'token' => $token,
105-
'profile' => $profile,
106-
'collector' => $profile->getCollector($panel),
107-
'panel' => $panel,
108-
'page' => $page,
109-
'request' => $request,
110-
'templates' => $this->getTemplateManager()->getTemplates($profile),
111-
'is_ajax' => $request->isXmlHttpRequest(),
112-
)),
113-
200,
114-
array('Content-Type' => 'text/html')
115-
)->setCharset('UTF-8');
102+
return new Response($this->twig->render($this->getTemplateManager()->getName($profile, $panel), array(
103+
'token' => $token,
104+
'profile' => $profile,
105+
'collector' => $profile->getCollector($panel),
106+
'panel' => $panel,
107+
'page' => $page,
108+
'request' => $request,
109+
'templates' => $this->getTemplateManager()->getTemplates($profile),
110+
'is_ajax' => $request->isXmlHttpRequest(),
111+
)), 200, array('Content-Type' => 'text/html'));
116112
}
117113

118114
/**
@@ -151,13 +147,9 @@ public function infoAction($about)
151147

152148
$this->profiler->disable();
153149

154-
return Response::create(
155-
$this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
156-
'about' => $about,
157-
)),
158-
200,
159-
array('Content-Type' => 'text/html')
160-
)->setCharset('UTF-8');
150+
return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array(
151+
'about' => $about,
152+
)), 200, array('Content-Type' => 'text/html'));
161153
}
162154

163155
/**
@@ -205,17 +197,13 @@ public function toolbarAction(Request $request, $token)
205197
// the profiler is not enabled
206198
}
207199

208-
return Response::create(
209-
$this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(
210-
'position' => $position,
211-
'profile' => $profile,
212-
'templates' => $this->getTemplateManager()->getTemplates($profile),
213-
'profiler_url' => $url,
214-
'token' => $token,
215-
)),
216-
200,
217-
array('Content-Type' => 'text/html')
218-
)->setCharset('UTF-8');
200+
return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array(
201+
'position' => $position,
202+
'profile' => $profile,
203+
'templates' => $this->getTemplateManager()->getTemplates($profile),
204+
'profiler_url' => $url,
205+
'token' => $token,
206+
)), 200, array('Content-Type' => 'text/html'));
219207
}
220208

221209
/**
@@ -253,7 +241,7 @@ public function searchBarAction(Request $request)
253241
$token = $session->get('_profiler_search_token');
254242
}
255243

256-
return Response::create(
244+
return new Response(
257245
$this->twig->render('@WebProfiler/Profiler/search.html.twig', array(
258246
'token' => $token,
259247
'ip' => $ip,
@@ -266,7 +254,7 @@ public function searchBarAction(Request $request)
266254
)),
267255
200,
268256
array('Content-Type' => 'text/html')
269-
)->setCharset(< 10000 span class="pl-s">'UTF-8');
257+
);
270258
}
271259

272260
/**
@@ -296,22 +284,18 @@ public function searchResultsAction(Request $request, $token)
296284
$end = $request->query->get('end', null);
297285
$limit = $request->query->get('limit');
298286

299-
return Response::create(
300-
$this->twig->render('@WebProfiler/Profiler/results.html.twig', array(
301-
'token' => $token,
302-
'profile' => $profile,
303-
'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end),
304-
'ip' => $ip,
305-
'method' => $method,
306-
'url' => $url,
307-
'start' => $start,
308-
'end' => $end,
309-
'limit' => $limit,
310-
'panel' => null,
311-
)),
312-
200,
313-
array('Content-Type' => 'text/html')
314-
)->setCharset('UTF-8');
287+
return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', array(
288+
'token' => $token,
289+
'profile' => $profile,
290+
'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end),
291+
'ip' => $ip,
292+
'method' => $method,
293+
'url' => $url,
294+
'start' => $start,
295+
'end' => $end,
296+
'limit' => $limit,
297+
'panel' => null,
298+
)), 200, array('Content-Type' => 'text/html'));
315299
}
316300

317301
/**
@@ -385,7 +369,7 @@ public function phpinfoAction()
385369
phpinfo();
386370
$phpinfo = ob_get_clean();
387371

388-
return Response::create($phpinfo, 200, array('Content-Type' => 'text/html'))->setCharset('UTF-8');
372+
return new Response($phpinfo, 200, array('Content-Type' => 'text/html'));
389373
}
390374

391375
/**

0 commit comments

Comments
 (0)
0