Merge branch '3.3' into 3.4

* 3.3:
  fix merge
  fixed wrong description in a phpdoc
  19 digits VISA card numbers are valid
  Add missing @ in phpdoc return statement
  Don't right trim the deprecation message
  [HttpKernel] Fixed test name
  [Debug] prevent infinite loop with faulty exception handlers
  Add the missing `enabled` session attribute
  [HttpKernel] Turn bad hosts into 400 instead of 500
This commit is contained in:
Nicolas Grekas 2018-01-13 15:04:53 +01:00
commit 3316e42797
11 changed files with 46 additions and 15 deletions

View File

@ -228,7 +228,7 @@ class DeprecationErrorHandler
uasort($deprecations[$group], $cmp); uasort($deprecations[$group], $cmp);
foreach ($deprecations[$group] as $msg => $notices) { foreach ($deprecations[$group] as $msg => $notices) {
echo "\n", rtrim($msg, '.'), ': ', $notices['count'], "x\n"; echo "\n ", $notices['count'], 'x: ', $msg, "\n";
arsort($notices); arsort($notices);

View File

@ -63,20 +63,20 @@ $foo->testNonLegacyBar();
--EXPECTF-- --EXPECTF--
Unsilenced deprecation notices (3) Unsilenced deprecation notices (3)
unsilenced foo deprecation: 2x 2x: unsilenced foo deprecation
2x in FooTestCase::testLegacyFoo 2x in FooTestCase::testLegacyFoo
unsilenced bar deprecation: 1x 1x: unsilenced bar deprecation
1x in FooTestCase::testNonLegacyBar 1x in FooTestCase::testNonLegacyBar
Remaining deprecation notices (1) Remaining deprecation notices (1)
silenced bar deprecation: 1x 1x: silenced bar deprecation
1x in FooTestCase::testNonLegacyBar 1x in FooTestCase::testNonLegacyBar
Legacy deprecation notices (1) Legacy deprecation notices (1)
Other deprecation notices (1) Other deprecation notices (1)
root deprecation: 1x 1x: root deprecation

View File

@ -55,20 +55,20 @@ $foo->testNonLegacyBar();
--EXPECTF-- --EXPECTF--
Unsilenced deprecation notices (3) Unsilenced deprecation notices (3)
unsilenced foo deprecation: 2x 2x: unsilenced foo deprecation
2x in FooTestCase::testLegacyFoo 2x in FooTestCase::testLegacyFoo
unsilenced bar deprecation: 1x 1x: unsilenced bar deprecation
1x in FooTestCase::testNonLegacyBar 1x in FooTestCase::testNonLegacyBar
Remaining deprecation notices (1) Remaining deprecation notices (1)
silenced bar deprecation: 1x 1x: silenced bar deprecation
1x in FooTestCase::testNonLegacyBar 1x in FooTestCase::testNonLegacyBar
Legacy deprecation notices (1) Legacy deprecation notices (1)
Other deprecation notices (1) Other deprecation notices (1)
root deprecation: 1x 1x: root deprecation

View File

@ -103,6 +103,7 @@
</xsd:complexType> </xsd:complexType>
<xsd:complexType name="session"> <xsd:complexType name="session">
<xsd:attribute name="enabled" type="xsd:boolean" />
<xsd:attribute name="storage-id" type="xsd:string" /> <xsd:attribute name="storage-id" type="xsd:string" />
<xsd:attribute name="handler-id" type="xsd:string" /> <xsd:attribute name="handler-id" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" />

View File

@ -31,7 +31,7 @@ interface AdapterInterface extends CacheItemPoolInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* return \Traversable|CacheItem[] * @return \Traversable|CacheItem[]
*/ */
public function getItems(array $keys = array()); public function getItems(array $keys = array());
} }

View File

@ -28,7 +28,7 @@ class StringInput extends ArgvInput
const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')'; const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
/** /**
* @param string $input An array of parameters from the CLI (in the argv format) * @param string $input A string representing the parameters from the CLI
*/ */
public function __construct($input) public function __construct($input)
{ {

View File

@ -596,6 +596,8 @@ class ErrorHandler
$handler = self::$reservedMemory = null; $handler = self::$reservedMemory = null;
$handlers = array(); $handlers = array();
$previousHandler = null;
$sameHandlerLimit = 10;
while (!is_array($handler) || !$handler[0] instanceof self) { while (!is_array($handler) || !$handler[0] instanceof self) {
$handler = set_exception_handler('var_dump'); $handler = set_exception_handler('var_dump');
@ -605,7 +607,14 @@ class ErrorHandler
break; break;
} }
restore_exception_handler(); restore_exception_handler();
array_unshift($handlers, $handler);
if ($handler !== $previousHandler) {
array_unshift($handlers, $handler);
$previousHandler = $handler;
} elseif (0 === --$sameHandlerLimit) {
$handler = null;
break;
}
} }
foreach ($handlers as $h) { foreach ($handlers as $h) {
set_exception_handler($h); set_exception_handler($h);

View File

@ -17,6 +17,7 @@ use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
@ -76,7 +77,11 @@ class RouterListener implements EventSubscriberInterface
private function setCurrentRequest(Request $request = null) private function setCurrentRequest(Request $request = null)
{ {
if (null !== $request) { if (null !== $request) {
$this->context->fromRequest($request); try {
$this->context->fromRequest($request);
} catch (\UnexpectedValueException $e) {
throw new BadRequestHttpException($e->getMessage(), $e, $e->getCode());
}
} }
} }

View File

@ -208,4 +208,19 @@ class RouterListenerTest extends TestCase
$this->assertSame(404, $response->getStatusCode()); $this->assertSame(404, $response->getStatusCode());
$this->assertContains('Welcome', $response->getContent()); $this->assertContains('Welcome', $response->getContent());
} }
/**
* @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
*/
public function testRequestWithBadHost()
{
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$request = Request::create('http://bad host %22/');
$event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
$listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext());
$listener->onKernelRequest($event);
}
} }

View File

@ -78,9 +78,9 @@ class CardSchemeValidator extends ConstraintValidator
'/^5[1-5][0-9]{14}$/', '/^5[1-5][0-9]{14}$/',
'/^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})$/', '/^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})$/',
), ),
// All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13. // All Visa card numbers start with a 4 and have a length of 13, 16, or 19 digits.
'VISA' => array( 'VISA' => array(
'/^4([0-9]{12}|[0-9]{15})$/', '/^4([0-9]{12}|[0-9]{15}|[0-9]{18})$/',
), ),
); );

View File

@ -106,6 +106,7 @@ class CardSchemeValidatorTest extends ConstraintValidatorTestCase
array('VISA', '4111111111111111'), array('VISA', '4111111111111111'),
array('VISA', '4012888888881881'), array('VISA', '4012888888881881'),
array('VISA', '4222222222222'), array('VISA', '4222222222222'),
array('VISA', '4917610000000000003'),
array(array('AMEX', 'VISA'), '4111111111111111'), array(array('AMEX', 'VISA'), '4111111111111111'),
array(array('AMEX', 'VISA'), '378282246310005'), array(array('AMEX', 'VISA'), '378282246310005'),
array(array('JCB', 'MASTERCARD'), '5105105105105100'), array(array('JCB', 'MASTERCARD'), '5105105105105100'),