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 d7b3a62

Browse filesBrowse files
Merge branch '2.7' into 2.8
* 2.7: Fix 7.2 compat layer Fix PHP 7.2 support [HttpFoundation] Add missing session.lazy_write config option [HttpFoundation] Combine Cache-Control headers [Form] fix parsing invalid floating point numbers Escape command usage when displaying it in the text descriptor Use for=ID on radio/checkbox label.
2 parents 8151760 + aaa5999 commit d7b3a62
Copy full SHA for d7b3a62

File tree

Expand file treeCollapse file tree

25 files changed

+169
-40
lines changed
Filter options
Expand file treeCollapse file tree

25 files changed

+169
-40
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ matrix:
2525
- php: 5.5
2626
- php: 5.6
2727
- php: 7.0
28-
env: deps=high
2928
- php: 7.1
29+
env: deps=high
30+
- php: 7.2
3031
env: deps=low
3132
fast_finish: true
3233

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,14 @@
148148
{% endblock %}
149149

150150
{% block checkbox_label -%}
151+
{%- set label_attr = label_attr|merge({'for': id}) -%}
152+
151153
{{- block('checkbox_radio_label') -}}
152154
{%- endblock checkbox_label %}
153155

154156
{% block radio_label -%}
157+
{%- set label_attr = label_attr|merge({'for': id}) -%}
158+
155159
{{- block('checkbox_radio_label') -}}
156160
{%- endblock radio_label %}
157161

‎src/Symfony/Bridge/Twig/Tests/AppVariableTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/AppVariableTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public function testEnvironment()
4444
$this->assertEquals('dev', $this->appVariable->getEnvironment());
4545
}
4646

47+
/**
48+
* @runInSeparateProcess
49+
*/
4750
public function testGetSession()
4851
{
4952
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();

‎src/Symfony/Bridge/Twig/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/composer.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"symfony/asset": "~2.7|~3.0.0",
2424
"symfony/finder": "~2.3|~3.0.0",
2525
"symfony/form": "^2.8.23",
26+
"symfony/http-foundation": "^2.8.29|~3.0.0",
2627
"symfony/http-kernel": "~2.8|~3.0.0",
2728
"symfony/polyfill-intl-icu": "~1.0",
2829
"symfony/routing": "~2.2|~3.0.0",

‎src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testCacheIsFreshAfterCacheClearedWithWarmup()
5555
$finder = new Finder();
5656
$metaFiles = $finder->files()->in($this->kernel->getCacheDir())->name('*.php.meta');
5757
// simply check that cache is warmed up
58-
$this->assertGreaterThanOrEqual(1, count($metaFiles));
58+
$this->assertNotEmpty($metaFiles);
5959
$configCacheFactory = new ConfigCacheFactory(true);
6060
$that = $this;
6161

‎src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ public function testRedirectToRoute()
223223
$this->assertSame(302, $response->getStatusCode());
224224
}
225225

226+
/**
227+
* @runInSeparateProcess
228+
*/
226229
public function testAddFlash()
227230
{
228231
$flashBag = new FlashBag();

‎src/Symfony/Bundle/FrameworkBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"symfony/config": "~2.8",
2525
"symfony/event-dispatcher": "~2.8|~3.0.0",
2626
"symfony/finder": "^2.0.5|~3.0.0",
27-
"symfony/http-foundation": "~2.7",
27+
"symfony/http-foundation": "~2.7.36|^2.8.29",
2828
"symfony/http-kernel": "^2.8.22",
2929
"symfony/polyfill-mbstring": "~1.0",
3030
"symfony/filesystem": "~2.3|~3.0.0",

‎src/Symfony/Component/Console/Descriptor/TextDescriptor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Descriptor/TextDescriptor.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ protected function describeCommand(Command $command, array $options = array())
143143
$this->writeText('<comment>Usage:</comment>', $options);
144144
foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
145145
$this->writeText("\n");
146-
$this->writeText(' '.$usage, $options);
146+
$this->writeText(' '.OutputFormatter::escape($usage), $options);
147147
}
148148
$this->writeText("\n");
149149

‎src/Symfony/Component/Console/Tests/Fixtures/command_2.txt

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Fixtures/command_2.txt
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<comment>Usage:</comment>
2-
descriptor:command2 [options] [--] <argument_name>
3-
descriptor:command2 -o|--option_name <argument_name>
4-
descriptor:command2 <argument_name>
2+
descriptor:command2 [options] [--] \<argument_name>
3+
descriptor:command2 -o|--option_name \<argument_name>
4+
descriptor:command2 \<argument_name>
55

66
<comment>Arguments:</comment>
77
<info>argument_name</info>

‎src/Symfony/Component/Console/Tests/Fixtures/command_mbstring.txt

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Fixtures/command_mbstring.txt
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<comment>Usage:</comment>
2-
descriptor:åèä [options] [--] <argument_åèä>
3-
descriptor:åèä -o|--option_name <argument_name>
4-
descriptor:åèä <argument_name>
2+
descriptor:åèä [options] [--] \<argument_åèä>
3+
descriptor:åèä -o|--option_name \<argument_name>
4+
descriptor:åèä \<argument_name>
55

66
<comment>Arguments:</comment>
77
<info>argument_åèä</info>

‎src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ public function testNotice()
8080
$this->assertEquals(E_NOTICE, $exception->getSeverity());
8181
$this->assertEquals(__FILE__, $exception->getFile());
8282
$this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage());
83-
$this->assertArrayHasKey('foobar', $exception->getContext());
83+
if (\PHP_VERSION_ID < 70200) {
84+
$this->assertArrayHasKey('foobar', $exception->getContext());
85+
}
8486

8587
$trace = $exception->getTrace();
8688
$this->assertEquals(__FILE__, $trace[0]['file']);
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<?php
22

3-
throw new \Exception('boo');
3+
if (!function_exists('__phpunit_run_isolated_test')) {
4+
throw new \Exception('boo');
5+
}

‎src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ public function testExtensionInPhar()
438438
if (extension_loaded('suhosin') && false === strpos(ini_get('suhosin.executor.include.whitelist'), 'phar')) {
439439
$this->markTestSkipped('To run this test, add "phar" to the "suhosin.executor.include.whitelist" settings in your php.ini file.');
440440
}
441+
if (defined('HHVM_VERSION')) {
442+
$this->markTestSkipped('HHVM makes this test conflict with those run in separate processes.');
443+
}
441444

442445
require_once self::$fixturesPath.'/includes/ProjectWithXsdExtensionInPhar.phar';
443446

‎src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php
+30-3Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public function reverseTransform($value)
116116
return;
117117
}
118118

119+
$position = 0;
119120
$formatter = $this->getNumberFormatter();
120121
$groupSep = $formatter->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL);
121122
$decSep = $formatter->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
@@ -129,18 +130,44 @@ public function reverseTransform($value)
129130
$value = str_replace(',', $decSep, $value);
130131
}
131132

133+
if (false !== strpos($value, $decSep)) {
134+
$type = \NumberFormatter::TYPE_DOUBLE;
135+
} else {
136+
$type = \PHP_INT_SIZE === 8 ? \NumberFormatter::TYPE_INT64 : \NumberFormatter::TYPE_INT32;
137+
}
138+
132139
// replace normal spaces so that the formatter can read them
133-
$value = $formatter->parse(str_replace(' ', "\xc2\xa0", $value));
140+
$result = $formatter->parse(str_replace(' ', "\xc2\xa0", $value), $type, $position);
134141

135142
if (intl_is_failure($formatter->getErrorCode())) {
136143
throw new TransformationFailedException($formatter->getErrorMessage());
137144
}
138145

139146
if (self::FRACTIONAL == $this->type) {
140-
$value /= 100;
147+
$result /= 100;
141148
}
142149

143-
return $value;
150+
if (\function_exists('mb_detect_encoding') && false !== $encoding = mb_detect_encoding($value, null, true)) {
151+
$length = mb_strlen($value, $encoding);
152+
$remainder = mb_substr($value, $position, $length, $encoding);
153+
} else {
154+
$length = \strlen($value);
155+
$remainder = substr($value, $position, $length);
156+
}
157+
158+
// After parsing, position holds the index of the character where the
159+
// parsing stopped
160+
if ($position < $length) {
161+
// Check if there are unrecognized characters at the end of the
162+
// number (excluding whitespace characters)
163+
$remainder = trim($remainder, " \t\n\r\0\x0b\xc2\xa0");
164+
165+
if ('' !== $remainder) {
166+
throw new TransformationFailedException(sprintf('The number contains unrecognized characters: "%s"', $remainder));
167+
}
168+
}
169+
170+
return $result;
144171
}
145172

146173
/**

‎src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php
+68-2Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot()
141141
*/
142142
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot()
143143
{
144-
// Since we test against "de_AT", we need the full implementation
144+
// Since we test against "de_DE", we need the full implementation
145145
IntlTestHelper::requireFullIntl($this, '4.8.1.1');
146146

147-
\Locale::setDefault('de_AT');
147+
\Locale::setDefault('de_DE');
148148

149149
$transformer = new PercentToLocalizedStringTransformer(1, 'integer');
150150

@@ -236,4 +236,70 @@ public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsCommaButNoGro
236236
$this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
237237
$this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
238238
}
239+
240+
/**
241+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
242+
*/
243+
public function testReverseTransformDisallowsLeadingExtraCharacters()
244+
{
245+
$transformer = new PercentToLocalizedStringTransformer();
246+
247+
$transformer->reverseTransform('foo123');
248+
}
249+
250+
/**
251+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
252+
* @expectedExceptionMessage The number contains unrecognized characters: "foo3"
253+
*/
254+
public function testReverseTransformDisallowsCenteredExtraCharacters()
255+
{
256+
$transformer = new PercentToLocalizedStringTransformer();
257+
258+
$transformer->reverseTransform('12foo3');
259+
}
260+
261+
/**
262+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
263+
* @expectedExceptionMessage The number contains unrecognized characters: "foo8"
264+
* @requires extension mbstring
265+
*/
266+
public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte()
267+
{
268+
// Since we test against other locales, we need the full implementation
269+
IntlTestHelper::requireFullIntl($this, false);
270+
271+
\Locale::setDefault('ru');
272+
273+
$transformer = new PercentToLocalizedStringTransformer();
274+
275+
$transformer->reverseTransform("12\xc2\xa0345,67foo8");
276+
}
277+
278+
/**
279+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
280+
* @expectedExceptionMessage The number contains unrecognized characters: "foo"
281+
*/
282+
public function testReverseTransformDisallowsTrailingExtraCharacters()
283+
{
284+
$transformer = new PercentToLocalizedStringTransformer();
285+
286+
$transformer->reverseTransform('123foo');
287+
}
288+
289+
/**
290+
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
291+
* @expectedExceptionMessage The number contains unrecognized characters: "foo"
292+
* @requires extension mbstring
293+
*/
294+
public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte()
295+
{
296+
// Since we test against other locales, we need the full implementation
297+
IntlTestHelper::requireFullIntl($this, false);
298+
299+
\Locale::setDefault('ru');
300+
301+
$transformer = new PercentToLocalizedStringTransformer();
302+
303+
$transformer->reverseTransform("12\xc2\xa0345,678foo");
304+
}
239305
}

‎src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacyDefaultCsrfProviderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacyDefaultCsrfProviderTest.php
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ class LegacyDefaultCsrfProviderTest extends TestCase
2323
{
2424
protected $provider;
2525

26-
public static function setUpBeforeClass()
27-
{
28-
ini_set('session.save_handler', 'files');
29-
ini_set('session.save_path', sys_get_temp_dir());
30-
}
31-
3226
protected function setUp()
3327
{
3428
$this->provider = new DefaultCsrfProvider('SECRET');

‎src/Symfony/Component/HttpFoundation/HeaderBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/HeaderBag.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function set($key, $values, $replace = true)
146146
}
147147

148148
if ('cache-control' === $key) {
149-
$this->cacheControl = $this->parseCacheControl($values[0]);
149+
$this->cacheControl = $this->parseCacheControl(implode(', ', $this->headers[$key]));
150150
}
151151
}
152152

‎src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
+19-3Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class NativeSessionStorage implements SessionStorageInterface
7676
* gc_probability, "1"
7777
* hash_bits_per_character, "4"
7878
* hash_function, "0"
79+
* lazy_write, "1"
7980
* name, "PHPSESSID"
8081
* referer_check, ""
8182
* serialize_handler, "php"
@@ -101,8 +102,11 @@ class NativeSessionStorage implements SessionStorageInterface
101102
*/
102103
public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null)
103104
{
104-
session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used)
105-
ini_set('session.use_cookies', 1);
105+
$options += array(
106+
// disable by default because it's managed by HeaderBag (if used)
107+
'cache_limiter' => '',
108+
'use_cookies' => 1,
109+
);
106110

107111
session_register_shutdown();
108112

@@ -204,6 +208,10 @@ public function regenerate($destroy = false, $lifetime = null)
204208
return false;
205209
}
206210

211+
if (headers_sent()) {
212+
return false;
213+
}
214+
207215
if (null !== $lifetime) {
208216
ini_set('session.cookie_lifetime', $lifetime);
209217
}
@@ -328,12 +336,16 @@ public function isStarted()
328336
*/
329337
public function setOptions(array $options)
330338
{
339+
if (headers_sent()) {
340+
return;
341+
}
342+
331343
$validOptions = array_flip(array(
332344
'cache_limiter', 'cookie_domain', 'cookie_httponly',
333345
'cookie_lifetime', 'cookie_path', 'cookie_secure',
334346
'entropy_file', 'entropy_length', 'gc_divisor',
335347
'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character',
336-
'hash_function', 'name', 'referer_check',
348+
'hash_function', 'lazy_write', 'name', 'referer_check',
337349
'serialize_handler', 'use_strict_mode', 'use_cookies',
338350
'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled',
339351
'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name',
@@ -379,6 +391,10 @@ public function setSaveHandler($saveHandler = null)
379391
throw new \InvalidArgumentException('Must be instance of AbstractProxy or NativeSessionHandler; implement \SessionHandlerInterface; or be null.');
380392
}
381393

394+
if (headers_sent($file, $line)) {
395+
throw new \RuntimeException(sprintf('Failed to set the session handler because headers have already been sent by "%s" at line %d.', $file, $line));
396+
}
397+
382398
// Wrap $saveHandler in proxy and prevent double wrapping of proxy
383399
if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) {
384400
$saveHandler = new SessionHandlerProxy($saveHandler);

‎src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ public function testCacheControlHeader()
110110
$bag = new ResponseHeaderBag();
111111
$bag->set('Last-Modified', 'abcde');
112112
$this->assertEquals('private, must-revalidate', $bag->get('Cache-Control'));
113+
114+
$bag = new ResponseHeaderBag();
115+
$bag->set('Cache-Control', array('public', 'must-revalidate'));
116+
$this->assertCount(1, $bag->get('Cache-Control', null, false));
117+
$this->assertEquals('must-revalidate, public', $bag->get('Cache-Control'));
118+
119+
$bag = new ResponseHeaderBag();
120+
$bag->set('Cache-Control', 'public');
121+
$bag->set('Cache-Control', 'must-revalidate', false);
122+
$this->assertCount(1, $bag->get('Cache-Control', null, false));
123+
$this->assertEquals('must-revalidate, public', $bag->get('Cache-Control'));
113124
}
114125

115126
public function testToStringIncludesCookieHeaders()

‎src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ public function testSessionDestroy()
269269
$this->assertSame('', $data, 'Destroyed session returns empty string');
270270
}
271271

272+
/**
273+
* @runInSeparateProcess
274+
*/
272275
public function testSessionGC()
273276
{
274277
$previousLifeTime = ini_set('session.gc_maxlifetime', 1000);

‎src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public function testDefaultLocaleWithoutSession()
3838
public function testLocaleFromRequestAttribute()
3939
{
4040
$request = Request::create('/');
41-
session_name('foo');
42-
$request->cookies->set('foo', 'value');
41+
$request->cookies->set(session_name(), 'value');
4342

4443
$request->attributes->set('_locale', 'es');
4544
$listener = new LocaleListener($this->requestStack, 'fr');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.