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 1f2d6fb

Browse filesBrowse files
Merge branch '2.7' into 2.8
* 2.7: [HttpKernel] fixed internal subrequests having an if-modified-since-header [Validator] Added additional MasterCard range to the CardSchemeValidator Make the exception message more clear. [Form] fixed bug - name in ButtonBuilder [ClassLoader] Fix declared classes being computed when not needed
2 parents 0bac08a + 7c39ac1 commit 1f2d6fb
Copy full SHA for 1f2d6fb

File tree

Expand file treeCollapse file tree

8 files changed

+102
-9
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+102
-9
lines changed

‎src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ClassLoader/ClassCollectionLoader.php
+12-6Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
4343

4444
self::$loaded[$name] = true;
4545

46-
$declared = array_merge(get_declared_classes(), get_declared_interfaces());
47-
if (function_exists('get_declared_traits')) {
48-
$declared = array_merge($declared, get_declared_traits());
49-
}
50-
5146
if ($adaptive) {
47+
$declared = array_merge(get_declared_classes(), get_declared_interfaces());
48+
if (function_exists('get_declared_traits')) {
49+
$declared = array_merge($declared, get_declared_traits());
50+
}
51+
5252
// don't include already declared classes
5353
$classes = array_diff($classes, $declared);
5454

@@ -87,11 +87,17 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
8787
}
8888
}
8989

90-
if (!$reload && is_file($cache)) {
90+
if (!$reload && file_exists($cache)) {
9191
require_once $cache;
9292

9393
return;
9494
}
95+
if (!$adaptive) {
96+
$declared = array_merge(get_declared_classes(), get_declared_interfaces());
97+
if (function_exists('get_declared_traits')) {
98+
$declared = array_merge($declared, get_declared_traits());
99+
}
100+
}
95101

96102
$files = array();
97103
$content = '';

‎src/Symfony/Component/Form/ButtonBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/ButtonBuilder.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
6262
*/
6363
public function __construct($name, array $options = array())
6464
{
65-
if (empty($name) && 0 != $name) {
65+
$name = (string) $name;
66+
if ('' === $name) {
6667
throw new InvalidArgumentException('Buttons cannot have empty names.');
6768
}
6869

69-
$this->name = (string) $name;
70+
$this->name = $name;
7071
$this->options = $options;
7172
}
7273

+61Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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\Form\Tests;
13+
14+
use Symfony\Component\Form\ButtonBuilder;
15+
16+
/**
17+
* @author Alexander Cheprasov <cheprasov.84@ya.ru>
18+
*/
19+
class ButtonBuilderTest extends \PHPUnit_Framework_TestCase
20+
{
21+
public function getValidNames()
22+
{
23+
return array(
24+
array('reset'),
25+
array('submit'),
26+
array('foo'),
27+
array('0'),
28+
array(0),
29+
array('button[]'),
30+
);
31+
}
32+
33+
/**
34+
* @dataProvider getValidNames
35+
*/
36+
public function testValidNames($name)
37+
{
38+
$this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder($name));
39+
}
40+
41+
public function getInvalidNames()
42+
{
43+
return array(
44+
array(''),
45+
array(false),
46+
array(null),
47+
);
48+
}
49+
50+
/**
51+
* @dataProvider getInvalidNames
52+
*/
53+
public function testInvalidNames($name)
54+
{
55+
$this->setExpectedException(
56+
'\Symfony\Component\Form\Exception\InvalidArgumentException',
57+
'Buttons cannot have empty names.'
58+
);
59+
new ButtonBuilder($name);
60+
}
61+
}

‎src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ protected function createSubRequest($uri, Request $request)
129129
}
130130

131131
$server['REMOTE_ADDR'] = '127.0.0.1';
132+
unset($server['HTTP_IF_MODIFIED_SINCE']);
133+
unset($server['HTTP_IF_NONE_MATCH']);
132134

133135
$subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server);
134136
if ($request->headers->has('Surrogate-Capability')) {

‎src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@ public function testESIHeaderIsKeptInSubrequestWithTrustedHeaderDisabled()
197197

198198
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName);
199199
}
200+
201+
public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest()
202+
{
203+
$expectedSubRequest = Request::create('/');
204+
if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
205+
$expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
206+
$expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
207+
}
208+
209+
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
210+
$request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*'));
211+
$strategy->render('/', $request);
212+
}
200213
}
201214

202215
class Bar

‎src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ class CardSchemeValidator extends ConstraintValidator
7474
'/^6[0-9]{11,18}$/',
7575
),
7676
// All MasterCard numbers start with the numbers 51 through 55. All have 16 digits.
77+
// October 2016 MasterCard numbers can also start with 222100 through 272099.
7778
'MASTERCARD' => array(
7879
'/^5[1-5][0-9]{14}$/',
80+
'/^2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12})$/',
7981
),
8082
// All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13.
8183
'VISA' => array(

‎src/Symfony/Component/Validator/Mapping/PropertyMetadata.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Mapping/PropertyMetadata.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PropertyMetadata extends MemberMetadata
3939
public function __construct($class, $name)
4040
{
4141
if (!property_exists($class, $name)) {
42-
throw new ValidatorException(sprintf('Property %s does not exist in class %s', $name, $class));
42+
throw new ValidatorException(sprintf('Property "%s" does not exist in class "%s"', $name, $class));
4343
}
4444

4545
parent::__construct($class, $name, $name);

‎src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ public function getValidNumbers()
102102
array('MAESTRO', '6594371785970435599'),
103103
array('MASTERCARD', '5555555555554444'),
104104
array('MASTERCARD', '5105105105105100'),
105+
array('MASTERCARD', '2221005555554444'),
106+
array('MASTERCARD', '2230000000000000'),
107+
array('MASTERCARD', '2300000000000000'),
108+
array('MASTERCARD', '2699999999999999'),
109+
array('MASTERCARD', '2709999999999999'),
110+
array('MASTERCARD', '2720995105105100'),
105111
array('VISA', '4111111111111111'),
106112
array('VISA', '4012888888881881'),
107113
array('VISA', '4222222222222'),
@@ -129,6 +135,8 @@ public function getInvalidNumbers()
129135
array('AMEX', '000000000000', CardScheme::INVALID_FORMAT_ERROR), // a lone number
130136
array('DINERS', '3056930', CardScheme::INVALID_FORMAT_ERROR), // only first part of the number
131137
array('DISCOVER', '1117', CardScheme::INVALID_FORMAT_ERROR), // only last 4 digits
138+
array('MASTERCARD', '2721001234567890', CardScheme::INVALID_FORMAT_ERROR), // Not assigned yet
139+
array('MASTERCARD', '2220991234567890', CardScheme::INVALID_FORMAT_ERROR), // Not assigned yet
132140
);
133141
}
134142
}

0 commit comments

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