From 154a278cc2be08e0b209a30066d0793b09a227cb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 17 Nov 2019 19:31:35 +0100 Subject: [PATCH 001/104] updated version to 5.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3d5681a4d9..7c9b62bf6f 100644 --- a/composer.json +++ b/composer.json @@ -74,7 +74,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "5.1-dev" } } } From 9c317d5597b88af507ccdaa75ddfbe7e84a11cca Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 17 Nov 2019 21:26:07 +0100 Subject: [PATCH 002/104] Fix version in Kernel --- Kernel.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Kernel.php b/Kernel.php index 6c38e9e96d..17ab07e203 100644 --- a/Kernel.php +++ b/Kernel.php @@ -68,15 +68,15 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.0.0-DEV'; - const VERSION_ID = 50000; + const VERSION = '5.1.0-DEV'; + const VERSION_ID = 50100; const MAJOR_VERSION = 5; - const MINOR_VERSION = 0; + const MINOR_VERSION = 1; const RELEASE_VERSION = 0; const EXTRA_VERSION = 'DEV'; - const END_OF_MAINTENANCE = '07/2020'; - const END_OF_LIFE = '07/2020'; + const END_OF_MAINTENANCE = '01/2021'; + const END_OF_LIFE = '01/2021'; public function __construct(string $environment, bool $debug) { From b9b933752ea9b2b97f81716a5f5addf24c2e89bd Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 8 Dec 2019 14:14:17 +0100 Subject: [PATCH 003/104] [FrameworkBundle] Allow using the kernel as a registry of controllers and service factories --- .../RegisterControllerArgumentLocatorsPass.php | 11 +++++++---- ...egisterControllerArgumentLocatorsPassTest.php | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index a3f5012e32..475b5d756a 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -170,11 +170,14 @@ public function process(ContainerBuilder $container) $message .= ' Did you forget to add a use statement?'; } - throw new InvalidArgumentException($message); - } + $container->register($erroredId = '.errored.'.$container->hash($message), $type) + ->addError($message); - $target = ltrim($target, '\\'); - $args[$p->name] = $type ? new TypedReference($target, $type, $invalidBehavior, $p->name) : new Reference($target, $invalidBehavior); + $args[$p->name] = new Reference($erroredId, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE); + } else { + $target = ltrim($target, '\\'); + $args[$p->name] = $type ? new TypedReference($target, $type, $invalidBehavior, $p->name) : new Reference($target, $invalidBehavior); + } } // register the maps as a per-method service-locators if ($args) { diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index a3b7969be1..0746643036 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -197,7 +197,7 @@ public function testSkipSetContainer() public function testExceptionOnNonExistentTypeHint() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException('RuntimeException'); $this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClass". Did you forget to add a use statement?'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -207,11 +207,17 @@ public function testExceptionOnNonExistentTypeHint() $pass = new RegisterControllerArgumentLocatorsPass(); $pass->process($container); + + $error = $container->getDefinition('argument_resolver.service')->getArgument(0); + $error = $container->getDefinition($error)->getArgument(0)['foo::fooAction']->getValues()[0]; + $error = $container->getDefinition($error)->getArgument(0)['nonExistent']->getValues()[0]; + + $container->get($error); } public function testExceptionOnNonExistentTypeHintDifferentNamespace() { - $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); + $this->expectException('RuntimeException'); $this->expectExceptionMessage('Cannot determine controller argument for "Symfony\Component\HttpKernel\Tests\DependencyInjection\NonExistentClassDifferentNamespaceController::fooAction()": the $nonExistent argument is type-hinted with the non-existent class or interface: "Acme\NonExistentClass".'); $container = new ContainerBuilder(); $container->register('argument_resolver.service')->addArgument([]); @@ -221,6 +227,12 @@ public function testExceptionOnNonExistentTypeHintDifferentNamespace() $pass = new RegisterControllerArgumentLocatorsPass(); $pass->process($container); + + $error = $container->getDefinition('argument_resolver.service')->getArgument(0); + $error = $container->getDefinition($error)->getArgument(0)['foo::fooAction']->getValues()[0]; + $error = $container->getDefinition($error)->getArgument(0)['nonExistent']->getValues()[0]; + + $container->get($error); } public function testNoExceptionOnNonExistentTypeHintOptionalArg() From 0adcc6ada48edff331fed1d11db5b18458cb9244 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Thu, 9 Jan 2020 17:25:47 +0100 Subject: [PATCH 004/104] Simplify UriSigner when working with HttpFoundation's Request --- EventListener/FragmentListener.php | 3 +-- Tests/UriSignerTest.php | 10 ++++++++++ UriSigner.php | 10 ++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/EventListener/FragmentListener.php b/EventListener/FragmentListener.php index afe5cb163d..14c6aa63d1 100644 --- a/EventListener/FragmentListener.php +++ b/EventListener/FragmentListener.php @@ -83,8 +83,7 @@ protected function validateRequest(Request $request) } // is the Request signed? - // we cannot use $request->getUri() here as we want to work with the original URI (no query string reordering) - if ($this->signer->check($request->getSchemeAndHttpHost().$request->getBaseUrl().$request->getPathInfo().(null !== ($qs = $request->server->get('QUERY_STRING')) ? '?'.$qs : ''))) { + if ($this->signer->checkRequest($request)) { return; } diff --git a/Tests/UriSignerTest.php b/Tests/UriSignerTest.php index b2eb59206b..4801776cce 100644 --- a/Tests/UriSignerTest.php +++ b/Tests/UriSignerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\UriSigner; class UriSignerTest extends TestCase @@ -52,6 +53,15 @@ public function testCheckWithDifferentArgSeparator() $this->assertTrue($signer->check($signer->sign('http://example.com/foo?foo=bar&baz=bay'))); } + public function testCheckWithRequest() + { + $signer = new UriSigner('foobar'); + + $this->assertTrue($signer->checkRequest(Request::create($signer->sign('http://example.com/foo')))); + $this->assertTrue($signer->checkRequest(Request::create($signer->sign('http://example.com/foo?foo=bar')))); + $this->assertTrue($signer->checkRequest(Request::create($signer->sign('http://example.com/foo?foo=bar&0=integer')))); + } + public function testCheckWithDifferentParameter() { $signer = new UriSigner('foobar', 'qux'); diff --git a/UriSigner.php b/UriSigner.php index 4dfb2bbefc..df08dd69fc 100644 --- a/UriSigner.php +++ b/UriSigner.php @@ -11,6 +11,8 @@ namespace Symfony\Component\HttpKernel; +use Symfony\Component\HttpFoundation\Request; + /** * Signs URIs. * @@ -78,6 +80,14 @@ public function check(string $uri) return hash_equals($this->computeHash($this->buildUrl($url, $params)), $hash); } + public function checkRequest(Request $request): bool + { + $qs = ($qs = $request->server->get('QUERY_STRING')) ? '?'.$qs : ''; + + // we cannot use $request->getUri() here as we want to work with the original URI (no query string reordering) + return $this->check($request->getSchemeAndHttpHost().$request->getBaseUrl().$request->getPathInfo().$qs); + } + private function computeHash(string $uri): string { return base64_encode(hash_hmac('sha256', $uri, $this->secret, true)); From 6a9a71ddb956dab6018cc551db47143b3f01eac0 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 22 Jan 2020 19:52:26 +0100 Subject: [PATCH 005/104] Improve displaying anonymous classes --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 69ccc569a7..7357b99cb6 100644 --- a/Kernel.php +++ b/Kernel.php @@ -219,7 +219,7 @@ public function getBundle(string $name) { if (!isset($this->bundles[$name])) { $class = \get_class($this); - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class; + $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).'@anonymous' : $class; throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, $class)); } @@ -394,7 +394,7 @@ protected function build(ContainerBuilder $container) protected function getContainerClass() { $class = \get_class($this); - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; + $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; $class = str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) { throw new \InvalidArgumentException(sprintf('The environment "%s" contains invalid characters, it can only contain characters allowed in PHP class names.', $this->environment)); From cd9e14d99fffcc242234f0718d57d4e7a9aea7ae Mon Sep 17 00:00:00 2001 From: Florian Hermann Date: Wed, 22 Jan 2020 17:51:35 +0100 Subject: [PATCH 006/104] Sort the KernelEvents constants to match the lifecycle of the framework --- KernelEvents.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/KernelEvents.php b/KernelEvents.php index 682561c324..0e1c9083e5 100644 --- a/KernelEvents.php +++ b/KernelEvents.php @@ -39,17 +39,6 @@ final class KernelEvents */ const EXCEPTION = 'kernel.exception'; - /** - * The VIEW event occurs when the return value of a controller - * is not a Response instance. - * - * This event allows you to create a response for the return value of the - * controller. - * - * @Event("Symfony\Component\HttpKernel\Event\ViewEvent") - */ - const VIEW = 'kernel.view'; - /** * The CONTROLLER event occurs once a controller was found for * handling a request. @@ -71,6 +60,17 @@ final class KernelEvents */ const CONTROLLER_ARGUMENTS = 'kernel.controller_arguments'; + /** + * The VIEW event occurs when the return value of a controller + * is not a Response instance. + * + * This event allows you to create a response for the return value of the + * controller. + * + * @Event("Symfony\Component\HttpKernel\Event\ViewEvent") + */ + const VIEW = 'kernel.view'; + /** * The RESPONSE event occurs once a response was created for * replying to a request. @@ -82,15 +82,6 @@ final class KernelEvents */ const RESPONSE = 'kernel.response'; - /** - * The TERMINATE event occurs once a response was sent. - * - * This event allows you to run expensive post-response jobs. - * - * @Event("Symfony\Component\HttpKernel\Event\TerminateEvent") - */ - const TERMINATE = 'kernel.terminate'; - /** * The FINISH_REQUEST event occurs when a response was generated for a request. * @@ -100,4 +91,13 @@ final class KernelEvents * @Event("Symfony\Component\HttpKernel\Event\FinishRequestEvent") */ const FINISH_REQUEST = 'kernel.finish_request'; + + /** + * The TERMINATE event occurs once a response was sent. + * + * This event allows you to run expensive post-response jobs. + * + * @Event("Symfony\Component\HttpKernel\Event\TerminateEvent") + */ + const TERMINATE = 'kernel.terminate'; } From 06d999d7a5ade9843bfb613340493ebd752c69d0 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 2 Feb 2020 17:25:17 +0100 Subject: [PATCH 007/104] [HttpKernel] allow using public aliases to reference controllers --- CHANGELOG.md | 5 +++++ .../RegisterControllerArgumentLocatorsPass.php | 11 +++++++++++ ...emoveEmptyControllerArgumentLocatorsPass.php | 5 +++++ ...gisterControllerArgumentLocatorsPassTest.php | 17 +++++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index adcbe66f66..17b7122023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.1.0 +----- + + * allowed using public aliases to reference controllers + 5.0.0 ----- diff --git a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index 475b5d756a..f7ddb870f1 100644 --- a/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -53,6 +53,13 @@ public function process(ContainerBuilder $container) $parameterBag = $container->getParameterBag(); $controllers = []; + $publicAliases = []; + foreach ($container->getAliases() as $id => $alias) { + if ($alias->isPublic()) { + $publicAliases[(string) $alias][] = $id; + } + } + foreach ($container->findTaggedServiceIds($this->controllerTag, true) as $id => $tags) { $def = $container->getDefinition($id); $def->setPublic(true); @@ -182,6 +189,10 @@ public function process(ContainerBuilder $container) // register the maps as a per-method service-locators if ($args) { $controllers[$id.'::'.$r->name] = ServiceLocatorTagPass::register($container, $args); + + foreach ($publicAliases[$id] ?? [] as $alias) { + $controllers[$alias.'::'.$r->name] = clone $controllers[$id.'::'.$r->name]; + } } } } diff --git a/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php b/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php index 596b6188f6..71bb23bbf8 100644 --- a/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php +++ b/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php @@ -43,6 +43,11 @@ public function process(ContainerBuilder $container) // any methods listed for call-at-instantiation cannot be actions $reason = false; list($id, $action) = explode('::', $controller); + + if ($container->hasAlias($id)) { + continue; + } + $controllerDef = $container->getDefinition($id); foreach ($controllerDef->getMethodCalls() as list($method)) { if (0 === strcasecmp($action, $method)) { diff --git a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php index 0746643036..2cda6c4f56 100644 --- a/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php +++ b/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php @@ -379,6 +379,23 @@ public function testNotTaggedControllerServiceReceivesLocatorArgument() $this->assertInstanceOf(Reference::class, $locatorArgument); } + + public function testAlias() + { + $container = new ContainerBuilder(); + $resolver = $container->register('argument_resolver.service')->addArgument([]); + + $container->register('foo', RegisterTestController::class) + ->addTag('controller.service_arguments'); + + $container->setAlias(RegisterTestController::class, 'foo')->setPublic(true); + + $pass = new RegisterControllerArgumentLocatorsPass(); + $pass->process($container); + + $locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0); + $this->assertSame([RegisterTestController::class.'::fooAction', 'foo::fooAction'], array_keys($locator)); + } } class RegisterTestController From 8a4340ab28bdce38a0d85e6c53b0e561748de47c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 4 Feb 2020 11:11:20 +0100 Subject: [PATCH 008/104] Fix bad merge --- Kernel.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1d5e7177cd..709e2e6151 100644 --- a/Kernel.php +++ b/Kernel.php @@ -393,13 +393,8 @@ protected function build(ContainerBuilder $container) */ protected function getContainerClass() { -<<<<<<< HEAD $class = \get_class($this); $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; -======= - $class = static::class; - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; ->>>>>>> 5.0 $class = str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) { throw new \InvalidArgumentException(sprintf('The environment "%s" contains invalid characters, it can only contain characters allowed in PHP class names.', $this->environment)); From e2b971ddb23f04ab193e85c0ee5ead572fcd7bc4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 4 Feb 2020 11:11:53 +0100 Subject: [PATCH 009/104] Fix CS --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 709e2e6151..aea2806b7d 100644 --- a/Kernel.php +++ b/Kernel.php @@ -218,7 +218,7 @@ public function getBundles() public function getBundle(string $name) { if (!isset($this->bundles[$name])) { - $class = \get_class($this); + $class = static::class; $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).'@anonymous' : $class; throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, $class)); @@ -393,7 +393,7 @@ protected function build(ContainerBuilder $container) */ protected function getContainerClass() { - $class = \get_class($this); + $class = static::class; $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; $class = str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) { From b05435ffa8847cd90cde3c593b3e9e6cf5d5f0e7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 7 Feb 2020 15:12:51 +0100 Subject: [PATCH 010/104] [HttpKernel] Make ErrorListener unaware of the event dispatcher. --- EventListener/ErrorListener.php | 22 +++++++++++++--------- Tests/EventListener/ErrorListenerTest.php | 1 - 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/EventListener/ErrorListener.php b/EventListener/ErrorListener.php index 26c361f754..6192a452e3 100644 --- a/EventListener/ErrorListener.php +++ b/EventListener/ErrorListener.php @@ -14,11 +14,11 @@ use Psr\Log\LoggerInterface; use Symfony\Component\Debug\Exception\FlattenException as LegacyFlattenException; use Symfony\Component\ErrorHandler\Exception\FlattenException; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent; use Symfony\Component\HttpKernel\Event\ExceptionEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; @@ -33,7 +33,7 @@ class ErrorListener implements EventSubscriberInterface protected $logger; protected $debug; - public function __construct($controller, LoggerInterface $logger = null, $debug = false) + public function __construct($controller, LoggerInterface $logger = null, bool $debug = false) { $this->controller = $controller; $this->logger = $logger; @@ -47,7 +47,7 @@ public function logKernelException(ExceptionEvent $event) $this->logException($event->getThrowable(), sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), $e->getFile(), $e->getLine())); } - public function onKernelException(ExceptionEvent $event, string $eventName = null, EventDispatcherInterface $eventDispatcher = null) + public function onKernelException(ExceptionEvent $event) { if (null === $this->controller) { return; @@ -79,12 +79,15 @@ public function onKernelException(ExceptionEvent $event, string $eventName = nul $event->setResponse($response); - if ($this->debug && $eventDispatcher instanceof EventDispatcherInterface) { - $cspRemovalListener = function ($event) use (&$cspRemovalListener, $eventDispatcher) { - $event->getResponse()->headers->remove('Content-Security-Policy'); - $eventDispatcher->removeListener(KernelEvents::RESPONSE, $cspRemovalListener); - }; - $eventDispatcher->addListener(KernelEvents::RESPONSE, $cspRemovalListener, -128); + if ($this->debug) { + $event->getRequest()->attributes->set('_remove_csp_headers', true); + } + } + + public function removeCspHeader(ResponseEvent $event): void + { + if ($this->debug && $event->getRequest()->attributes->get('_remove_csp_headers', false)) { + $event->getResponse()->headers->remove('Content-Security-Policy'); } } @@ -114,6 +117,7 @@ public static function getSubscribedEvents(): array ['logKernelException', 0], ['onKernelException', -128], ], + KernelEvents::RESPONSE => ['removeCspHeader', -128], ]; } diff --git a/Tests/EventListener/ErrorListenerTest.php b/Tests/EventListener/ErrorListenerTest.php index cdf6874f35..408b580630 100644 --- a/Tests/EventListener/ErrorListenerTest.php +++ b/Tests/EventListener/ErrorListenerTest.php @@ -155,7 +155,6 @@ public function testCSPHeaderIsRemoved() $dispatcher->dispatch($event, KernelEvents::RESPONSE); $this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed'); - $this->assertFalse($dispatcher->hasListeners(KernelEvents::RESPONSE), 'CSP removal listener has been removed'); } /** From 4f26013f78374c0df93f48b06a1a9482121d647b Mon Sep 17 00:00:00 2001 From: Mathias Arlaud Date: Fri, 14 Feb 2020 18:10:13 +0100 Subject: [PATCH 011/104] [FrameworkBundle][HttpFoundation] Add `_stateless` --- CHANGELOG.md | 1 + EventListener/AbstractSessionListener.php | 39 +++++++---- EventListener/SessionListener.php | 4 +- Exception/UnexpectedSessionUsageException.php | 19 ++++++ Tests/EventListener/SessionListenerTest.php | 66 +++++++++++++++++++ 5 files changed, 116 insertions(+), 13 deletions(-) create mode 100644 Exception/UnexpectedSessionUsageException.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 17b7122023..ada9fafe60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG ----- * allowed using public aliases to reference controllers + * added session usage reporting when the `_stateless` attribute of the request is set to `true` 5.0.0 ----- diff --git a/EventListener/AbstractSessionListener.php b/EventListener/AbstractSessionListener.php index 9c9c422e4e..871ffc61d5 100644 --- a/EventListener/AbstractSessionListener.php +++ b/EventListener/AbstractSessionListener.php @@ -18,6 +18,7 @@ use Symfony\Component\HttpKernel\Event\FinishRequestEvent; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\Event\ResponseEvent; +use Symfony\Component\HttpKernel\Exception\UnexpectedSessionUsageException; use Symfony\Component\HttpKernel\KernelEvents; /** @@ -41,10 +42,12 @@ abstract class AbstractSessionListener implements EventSubscriberInterface protected $container; private $sessionUsageStack = []; + private $debug; - public function __construct(ContainerInterface $container = null) + public function __construct(ContainerInterface $container = null, bool $debug = false) { $this->container = $container; + $this->debug = $debug; } public function onKernelRequest(RequestEvent $event) @@ -82,16 +85,6 @@ public function onKernelResponse(ResponseEvent $event) return; } - if ($session instanceof Session ? $session->getUsageIndex() !== end($this->sessionUsageStack) : $session->isStarted()) { - if ($autoCacheControl) { - $response - ->setExpires(new \DateTime()) - ->setPrivate() - ->setMaxAge(0) - ->headers->addCacheControlDirective('must-revalidate'); - } - } - if ($session->isStarted()) { /* * Saves the session, in case it is still open, before sending the response/headers. @@ -120,6 +113,30 @@ public function onKernelResponse(ResponseEvent $event) */ $session->save(); } + + if ($session instanceof Session ? $session->getUsageIndex() === end($this->sessionUsageStack) : !$session->isStarted()) { + return; + } + + if ($autoCacheControl) { + $response + ->setExpires(new \DateTime()) + ->setPrivate() + ->setMaxAge(0) + ->headers->addCacheControlDirective('must-revalidate'); + } + + if (!$event->getRequest()->attributes->get('_stateless', false)) { + return; + } + + if ($this->debug) { + throw new UnexpectedSessionUsageException('Session was used while the request was declared stateless.'); + } + + if ($this->container->has('logger')) { + $this->container->get('logger')->warning('Session was used while the request was declared stateless.'); + } } public function onFinishRequest(FinishRequestEvent $event) diff --git a/EventListener/SessionListener.php b/EventListener/SessionListener.php index a53ade797c..e982a795b2 100644 --- a/EventListener/SessionListener.php +++ b/EventListener/SessionListener.php @@ -28,9 +28,9 @@ */ class SessionListener extends AbstractSessionListener { - public function __construct(ContainerInterface $container) + public function __construct(ContainerInterface $container, bool $debug = false) { - $this->container = $container; + parent::__construct($container, $debug); } protected function getSession(): ?SessionInterface diff --git a/Exception/UnexpectedSessionUsageException.php b/Exception/UnexpectedSessionUsageException.php new file mode 100644 index 0000000000..0145b1691c --- /dev/null +++ b/Exception/UnexpectedSessionUsageException.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Exception; + +/** + * @author Mathias Arlaud + */ +class UnexpectedSessionUsageException extends \LogicException +{ +} diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index 8fc9f6bc9c..a155cc93ab 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ServiceLocator; use Symfony\Component\HttpFoundation\Request; @@ -24,6 +25,7 @@ use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener; use Symfony\Component\HttpKernel\EventListener\SessionListener; +use Symfony\Component\HttpKernel\Exception\UnexpectedSessionUsageException; use Symfony\Component\HttpKernel\HttpKernelInterface; class SessionListenerTest extends TestCase @@ -178,4 +180,68 @@ public function testSurrogateMasterRequestIsPublic() $this->assertTrue($response->headers->has('Expires')); $this->assertLessThanOrEqual((new \DateTime('now', new \DateTimeZone('UTC'))), (new \DateTime($response->headers->get('Expires')))); } + + public function testSessionUsageExceptionIfStatelessAndSessionUsed() + { + $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); + $session->expects($this->exactly(2))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1)); + + $container = new Container(); + $container->set('initialized_session', $session); + + $listener = new SessionListener($container, true); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock(); + + $request = new Request(); + $request->attributes->set('_stateless', true); + $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); + + $this->expectException(UnexpectedSessionUsageException::class); + $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new Response())); + } + + public function testSessionUsageLogIfStatelessAndSessionUsed() + { + $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); + $session->expects($this->exactly(2))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1)); + + $logger = $this->getMockBuilder(LoggerInterface::class)->disableOriginalConstructor()->getMock(); + $logger->expects($this->exactly(1))->method('warning'); + + $container = new Container(); + $container->set('initialized_session', $session); + $container->set('logger', $logger); + + $listener = new SessionListener($container, false); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock(); + + $request = new Request(); + $request->attributes->set('_stateless', true); + $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); + + $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new Response())); + } + + public function testSessionIsSavedWhenUnexpectedSessionExceptionThrown() + { + $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); + $session->method('isStarted')->willReturn(true); + $session->expects($this->exactly(2))->method('getUsageIndex')->will($this->onConsecutiveCalls(0, 1)); + $session->expects($this->exactly(1))->method('save'); + + $container = new Container(); + $container->set('initialized_session', $session); + + $listener = new SessionListener($container, true); + $kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock(); + + $request = new Request(); + $request->attributes->set('_stateless', true); + + $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST)); + + $response = new Response(); + $this->expectException(UnexpectedSessionUsageException::class); + $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response)); + } } From b77473be7d8eca4884a04ddfc534d935448b8a22 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 3 Mar 2020 20:07:47 +0100 Subject: [PATCH 012/104] Leverage PHP8's get_debug_type() --- Bundle/Bundle.php | 2 +- Controller/ArgumentResolver.php | 2 +- Controller/ArgumentResolver/VariadicValueResolver.php | 2 +- Controller/ControllerResolver.php | 6 +++--- DataCollector/RequestDataCollector.php | 4 ++-- Kernel.php | 5 ++--- composer.json | 1 + 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Bundle/Bundle.php b/Bundle/Bundle.php index e8057737ed..2e65f67c9d 100644 --- a/Bundle/Bundle.php +++ b/Bundle/Bundle.php @@ -69,7 +69,7 @@ public function getContainerExtension() if (null !== $extension) { if (!$extension instanceof ExtensionInterface) { - throw new \LogicException(sprintf('Extension "%s" must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', \get_class($extension))); + throw new \LogicException(sprintf('Extension "%s" must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', get_debug_type($extension))); } // check naming convention diff --git a/Controller/ArgumentResolver.php b/Controller/ArgumentResolver.php index 43bbe178d5..530a6f6ede 100644 --- a/Controller/ArgumentResolver.php +++ b/Controller/ArgumentResolver.php @@ -62,7 +62,7 @@ public function getArguments(Request $request, callable $controller): array } if (!$atLeastOne) { - throw new \InvalidArgumentException(sprintf('%s::resolve() must yield at least one value.', \get_class($resolver))); + throw new \InvalidArgumentException(sprintf('%s::resolve() must yield at least one value.', get_debug_type($resolver))); } // continue to the next controller argument diff --git a/Controller/ArgumentResolver/VariadicValueResolver.php b/Controller/ArgumentResolver/VariadicValueResolver.php index ed61420e67..a8f7e0f440 100644 --- a/Controller/ArgumentResolver/VariadicValueResolver.php +++ b/Controller/ArgumentResolver/VariadicValueResolver.php @@ -38,7 +38,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable $values = $request->attributes->get($argument->getName()); if (!\is_array($values)) { - throw new \InvalidArgumentException(sprintf('The action argument "...$%1$s" is required to be an array, the request attribute "%1$s" contains a type of "%2$s" instead.', $argument->getName(), \gettype($values))); + throw new \InvalidArgumentException(sprintf('The action argument "...$%1$s" is required to be an array, the request attribute "%1$s" contains a type of "%2$s" instead.', $argument->getName(), get_debug_type($values))); } yield from $values; diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 1f8354291b..d90cb3a76c 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -161,11 +161,11 @@ private function getControllerError($callable): string $availableMethods = $this->getClassMethodsWithoutMagicMethods($callable); $alternativeMsg = $availableMethods ? sprintf(' or use one of the available methods: "%s"', implode('", "', $availableMethods)) : ''; - return sprintf('Controller class "%s" cannot be called without a method name. You need to implement "__invoke"%s.', \get_class($callable), $alternativeMsg); + return sprintf('Controller class "%s" cannot be called without a method name. You need to implement "__invoke"%s.', get_debug_type($callable), $alternativeMsg); } if (!\is_array($callable)) { - return sprintf('Invalid type for controller given, expected string, array or object, got "%s".', \gettype($callable)); + return sprintf('Invalid type for controller given, expected string, array or object, got "%s".', get_debug_type($callable)); } if (!isset($callable[0]) || !isset($callable[1]) || 2 !== \count($callable)) { @@ -178,7 +178,7 @@ private function getControllerError($callable): string return sprintf('Class "%s" does not exist.', $controller); } - $className = \is_object($controller) ? \get_class($controller) : $controller; + $className = \is_object($controller) ? get_debug_type($controller) : $controller; if (method_exists($controller, $method)) { return sprintf('Method "%s" on class "%s" should be public and non-abstract.', $method, $className); diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index 9585c130f0..b92518d806 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -400,7 +400,7 @@ protected function parseController($controller) $r = new \ReflectionMethod($controller[0], $controller[1]); return [ - 'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0], + 'class' => \is_object($controller[0]) ? get_debug_type($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => $r->getFileName(), 'line' => $r->getStartLine(), @@ -409,7 +409,7 @@ protected function parseController($controller) if (\is_callable($controller)) { // using __call or __callStatic return [ - 'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0], + 'class' => \is_object($controller[0]) ? get_debug_type($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => 'n/a', 'line' => 'n/a', diff --git a/Kernel.php b/Kernel.php index 3aa197b767..680703a75b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -218,8 +218,7 @@ public function getBundles() public function getBundle(string $name) { if (!isset($this->bundles[$name])) { - $class = static::class; - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).'@anonymous' : $class; + $class = get_debug_type($this); throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, $class)); } @@ -394,7 +393,7 @@ protected function build(ContainerBuilder $container) protected function getContainerClass() { $class = static::class; - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; + $class = false !== strpos($class, "@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; $class = str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) { throw new \InvalidArgumentException(sprintf('The environment "%s" contains invalid characters, it can only contain characters allowed in PHP class names.', $this->environment)); diff --git a/composer.json b/composer.json index 4f2601134c..e60792f689 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "symfony/http-foundation": "^4.4|^5.0", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-php73": "^1.9", + "symfony/polyfill-php80": "^1.15", "psr/log": "~1.0" }, "require-dev": { From 4620b91e9a0f3079bbad3c6f9b62d6f5e544a830 Mon Sep 17 00:00:00 2001 From: Michel Roca Date: Sat, 21 Mar 2020 21:29:52 +0100 Subject: [PATCH 013/104] Fix profiler nullable string type --- Profiler/Profile.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Profiler/Profile.php b/Profiler/Profile.php index c18e9980a1..37b690ed86 100644 --- a/Profiler/Profile.php +++ b/Profiler/Profile.php @@ -101,7 +101,7 @@ public function getIp() return $this->ip; } - public function setIp(string $ip) + public function setIp(?string $ip) { $this->ip = $ip; } @@ -131,7 +131,7 @@ public function getUrl() return $this->url; } - public function setUrl(string $url) + public function setUrl(?string $url) { $this->url = $url; } From 76afa0883ada588397dad13c7558673af2dca7cf Mon Sep 17 00:00:00 2001 From: Mathias Arlaud Date: Tue, 25 Feb 2020 16:40:39 +0100 Subject: [PATCH 014/104] Improve UnexcpectedSessionUsageException backtrace --- CHANGELOG.md | 1 + EventListener/AbstractSessionListener.php | 31 +++++++++++ Tests/EventListener/SessionListenerTest.php | 59 +++++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ada9fafe60..d24bf8bfff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG * allowed using public aliases to reference controllers * added session usage reporting when the `_stateless` attribute of the request is set to `true` + * added `AbstractSessionListener::onSessionUsage()` to report when the session is used while a request is stateless 5.0.0 ----- diff --git a/EventListener/AbstractSessionListener.php b/EventListener/AbstractSessionListener.php index 871ffc61d5..1fe3264f7d 100644 --- a/EventListener/AbstractSessionListener.php +++ b/EventListener/AbstractSessionListener.php @@ -146,6 +146,37 @@ public function onFinishRequest(FinishRequestEvent $event) } } + public function onSessionUsage(): void + { + if (!$this->debug) { + return; + } + + if (!$requestStack = $this->container && $this->container->has('request_stack') ? $this->container->get('request_stack') : null) { + return; + } + + $stateless = false; + $clonedRequestStack = clone $requestStack; + while (null !== ($request = $clonedRequestStack->pop()) && !$stateless) { + $stateless = $request->attributes->get('_stateless'); + } + + if (!$stateless) { + return; + } + + if (!$session = $this->container && $this->container->has('initialized_session') ? $this->container->get('initialized_session') : $requestStack->getCurrentRequest()->getSession()) { + return; + } + + if ($session->isStarted()) { + $session->save(); + } + + throw new UnexpectedSessionUsageException('Session was used while the request was declared stateless.'); + } + public static function getSubscribedEvents(): array { return [ diff --git a/Tests/EventListener/SessionListenerTest.php b/Tests/EventListener/SessionListenerTest.php index a155cc93ab..8df2ce5169 100644 --- a/Tests/EventListener/SessionListenerTest.php +++ b/Tests/EventListener/SessionListenerTest.php @@ -244,4 +244,63 @@ public function testSessionIsSavedWhenUnexpectedSessionExceptionThrown() $this->expectException(UnexpectedSessionUsageException::class); $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response)); } + + public function testSessionUsageCallbackWhenDebugAndStateless() + { + $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); + $session->method('isStarted')->willReturn(true); + $session->expects($this->exactly(1))->method('save'); + + $requestStack = new RequestStack(); + + $request = new Request(); + $request->attributes->set('_stateless', true); + + $requestStack->push(new Request()); + $requestStack->push($request); + $requestStack->push(new Request()); + + $container = new Container(); + $container->set('initialized_session', $session); + $container->set('request_stack', $requestStack); + + $this->expectException(UnexpectedSessionUsageException::class); + (new SessionListener($container, true))->onSessionUsage(); + } + + public function testSessionUsageCallbackWhenNoDebug() + { + $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); + $session->method('isStarted')->willReturn(true); + $session->expects($this->exactly(0))->method('save'); + + $request = new Request(); + $request->attributes->set('_stateless', true); + + $requestStack = $this->getMockBuilder(RequestStack::class)->getMock(); + $requestStack->expects($this->never())->method('getMasterRequest')->willReturn($request); + + $container = new Container(); + $container->set('initialized_session', $session); + $container->set('request_stack', $requestStack); + + (new SessionListener($container))->onSessionUsage(); + } + + public function testSessionUsageCallbackWhenNoStateless() + { + $session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); + $session->method('isStarted')->willReturn(true); + $session->expects($this->never())->method('save'); + + $requestStack = new RequestStack(); + $requestStack->push(new Request()); + $requestStack->push(new Request()); + + $container = new Container(); + $container->set('initialized_session', $session); + $container->set('request_stack', $requestStack); + + (new SessionListener($container, true))->onSessionUsage(); + } } From 8efac445a9d97261cf579faa5c7080049334c7c0 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 25 Mar 2020 13:02:26 +0100 Subject: [PATCH 015/104] Fixed some typos --- Tests/Controller/ContainerControllerResolverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index 97d21e95a4..b03169de93 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -229,7 +229,7 @@ public function testExceptionWhenUsingControllerWithoutAnInvokeMethod() */ public function testGetControllerOnNonUndefinedFunction($controller, $exceptionName = null, $exceptionMessage = null) { - // All this logic needs to be duplicated, since calling parent::testGetControllerOnNonUndefinedFunction will override the expected excetion and not use the regex + // All this logic needs to be duplicated, since calling parent::testGetControllerOnNonUndefinedFunction will override the expected exception and not use the regex $resolver = $this->createControllerResolver(); $this->expectException($exceptionName); $this->expectExceptionMessageRegExp($exceptionMessage); From d9df6c0ceb0862a3814d2434abb2a7a304ded675 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 27 Mar 2020 17:16:43 +0100 Subject: [PATCH 016/104] [HttpKernel][LoggerDataCollector] Prevent keys collisions in the sanitized logs processing --- DataCollector/LoggerDataCollector.php | 2 +- Tests/DataCollector/LoggerDataCollectorTest.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DataCollector/LoggerDataCollector.php b/DataCollector/LoggerDataCollector.php index 99a9cf23e8..9c05daa36f 100644 --- a/DataCollector/LoggerDataCollector.php +++ b/DataCollector/LoggerDataCollector.php @@ -172,7 +172,7 @@ private function sanitizeLogs($logs) continue; } - $message = $log['message']; + $message = '_'.$log['message']; $exception = $log['context']['exception']; if ($exception instanceof SilencedErrorContext) { diff --git a/Tests/DataCollector/LoggerDataCollectorTest.php b/Tests/DataCollector/LoggerDataCollectorTest.php index 8b7fbe2a19..b46357ed55 100644 --- a/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/Tests/DataCollector/LoggerDataCollectorTest.php @@ -132,13 +132,15 @@ public function getCollectTestData() [ ['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'], ['message' => 'foo3', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'], + ['message' => '0', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'], ], [ ['message' => 'foo3', 'context' => ['exception' => ['warning', E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'], ['message' => 'foo3', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true], + ['message' => '0', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true], ], 0, - 1, + 2, ]; } } From c15b5acab571224b1bf792692ff2ad63239081fe Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Mar 2020 08:25:13 +0200 Subject: [PATCH 017/104] updated VERSION for 3.4.39 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 9d1d42eb19..7193c8b935 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.39-DEV'; + const VERSION = '3.4.39'; const VERSION_ID = 30439; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 39; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 73e886d8a9593b21e5fe4ff8db0d3bcec20be41f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Mar 2020 08:41:06 +0200 Subject: [PATCH 018/104] bumped Symfony version to 3.4.40 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7193c8b935..9422d90e9e 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.39'; - const VERSION_ID = 30439; + const VERSION = '3.4.40-DEV'; + const VERSION_ID = 30440; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 39; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 40; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From f356a489e51856b99908005eb7f2c51a1dfc95dc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Mar 2020 16:59:15 +0200 Subject: [PATCH 019/104] updated VERSION for 4.4.7 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index dfbd1c82c8..89198bd7cf 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.7-DEV'; + const VERSION = '4.4.7'; const VERSION_ID = 40407; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 7; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From aeaa78394daeacf6ea33ff30a160870c21bfa2ce Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Mar 2020 17:04:12 +0200 Subject: [PATCH 020/104] bumped Symfony version to 4.4.8 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 89198bd7cf..c583aa66d7 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.7'; - const VERSION_ID = 40407; + const VERSION = '4.4.8-DEV'; + const VERSION_ID = 40408; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 7; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 8; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From c3f25aea597542d307beccc16e89a9eb65020b2d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 Mar 2020 17:09:36 +0200 Subject: [PATCH 021/104] bumped Symfony version to 5.0.8 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index d03d4e1d0a..357209072b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -68,12 +68,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.0.7'; - const VERSION_ID = 50007; + const VERSION = '5.0.8-DEV'; + const VERSION_ID = 50008; const MAJOR_VERSION = 5; const MINOR_VERSION = 0; - const RELEASE_VERSION = 7; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 8; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '07/2020'; const END_OF_LIFE = '07/2020'; From 9b595b1d11b250853ed2747291bd3cae08f3dc69 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sun, 29 Mar 2020 16:22:37 +0200 Subject: [PATCH 022/104] [HttpKernel] Deprecate single-colon notation for controllers --- CHANGELOG.md | 7 ++++--- Controller/ContainerControllerResolver.php | 4 ++-- Tests/Controller/ContainerControllerResolverTest.php | 5 ++++- composer.json | 1 + 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ada9fafe60..fbffdce68c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ CHANGELOG 5.1.0 ----- + * deprecated support for `service:action` syntax to reference controllers, use `serviceOrFqcn::method` instead * allowed using public aliases to reference controllers * added session usage reporting when the `_stateless` attribute of the request is set to `true` @@ -11,8 +12,8 @@ CHANGELOG ----- * removed support for getting the container from a non-booted kernel - * removed the first and second constructor argument of `ConfigDataCollector` - * removed `ConfigDataCollector::getApplicationName()` + * removed the first and second constructor argument of `ConfigDataCollector` + * removed `ConfigDataCollector::getApplicationName()` * removed `ConfigDataCollector::getApplicationVersion()` * removed support for `Symfony\Component\Templating\EngineInterface` in `HIncludeFragmentRenderer`, use a `Twig\Environment` only * removed `TranslatorListener` in favor of `LocaleAwareListener` @@ -24,7 +25,7 @@ CHANGELOG * removed `GetResponseForControllerResultEvent`, use `ViewEvent` instead * removed `GetResponseForExceptionEvent`, use `ExceptionEvent` instead * removed `PostResponseEvent`, use `TerminateEvent` instead - * removed `SaveSessionListener` in favor of `AbstractSessionListener` + * removed `SaveSessionListener` in favor of `AbstractSessionListener` * removed `Client`, use `HttpKernelBrowser` instead * added method `getProjectDir()` to `KernelInterface` * removed methods `serialize` and `unserialize` from `DataCollector`, store the serialized state in the data property instead diff --git a/Controller/ContainerControllerResolver.php b/Controller/ContainerControllerResolver.php index 6e4ae20c34..3b9468465c 100644 --- a/Controller/ContainerControllerResolver.php +++ b/Controller/ContainerControllerResolver.php @@ -16,7 +16,7 @@ use Symfony\Component\DependencyInjection\Container; /** - * A controller resolver searching for a controller in a psr-11 container when using the "service:method" notation. + * A controller resolver searching for a controller in a psr-11 container when using the "service::method" notation. * * @author Fabien Potencier * @author Maxime Steinhausser @@ -36,7 +36,7 @@ protected function createController(string $controller) { if (1 === substr_count($controller, ':')) { $controller = str_replace(':', '::', $controller); - // TODO deprecate this in 5.1 + trigger_deprecation('symfony/http-kernel', '5.1', 'Referencing controllers with a single colon is deprecated. Use "%s" instead.', $controller); } return parent::createController($controller); diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index c39dac3ca5..85dd5fb671 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -19,6 +19,10 @@ class ContainerControllerResolverTest extends ControllerResolverTest { + /** + * @group legacy + * @expectedDeprecation Since symfony/http-kernel 5.1: Referencing controllers with a single colon is deprecated. Use "foo::action" instead. + */ public function testGetControllerServiceWithSingleColon() { $service = new ControllerTestService('foo'); @@ -145,7 +149,6 @@ public function getControllers() { return [ ['\\'.ControllerTestService::class.'::action'], - ['\\'.ControllerTestService::class.':action'], ]; } diff --git a/composer.json b/composer.json index e60792f689..ec5ea1277c 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ ], "require": { "php": "^7.2.5", + "symfony/deprecation-contracts": "^2.1", "symfony/error-handler": "^4.4|^5.0", "symfony/event-dispatcher": "^5.0", "symfony/http-foundation": "^4.4|^5.0", From af0f09dbb9c3716b38895611a92a099e21766386 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 25 Mar 2020 18:08:12 +0100 Subject: [PATCH 023/104] [HttpKernel] allow cache warmers to add to the list of preloaded classes and files --- CHANGELOG.md | 2 ++ CacheWarmer/CacheWarmerAggregate.php | 7 ++++++- CacheWarmer/WarmableInterface.php | 2 ++ Kernel.php | 7 ++++++- Tests/CacheWarmer/CacheWarmerTest.php | 5 +++++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44cff9bdaf..1b766484b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ CHANGELOG 5.1.0 ----- + * made `WarmableInterface::warmUp()` return a list of classes or files to preload on PHP 7.4+; + not returning an array is deprecated * deprecated support for `service:action` syntax to reference controllers, use `serviceOrFqcn::method` instead * allowed using public aliases to reference controllers * added session usage reporting when the `_stateless` attribute of the request is set to `true` diff --git a/CacheWarmer/CacheWarmerAggregate.php b/CacheWarmer/CacheWarmerAggregate.php index 1b3d73b7e1..f89b1cd7a0 100644 --- a/CacheWarmer/CacheWarmerAggregate.php +++ b/CacheWarmer/CacheWarmerAggregate.php @@ -45,6 +45,8 @@ public function enableOnlyOptionalWarmers() /** * Warms up the cache. + * + * @return string[] A list of classes or files to preload on PHP 7.4+ */ public function warmUp(string $cacheDir) { @@ -83,6 +85,7 @@ public function warmUp(string $cacheDir) }); } + $preload = []; try { foreach ($this->warmers as $warmer) { if (!$this->optionalsEnabled && $warmer->isOptional()) { @@ -92,7 +95,7 @@ public function warmUp(string $cacheDir) continue; } - $warmer->warmUp($cacheDir); + $preload[] = array_values((array) $warmer->warmUp($cacheDir)); } } finally { if ($collectDeprecations) { @@ -106,6 +109,8 @@ public function warmUp(string $cacheDir) file_put_contents($this->deprecationLogsFilepath, serialize(array_values($collectedLogs))); } } + + return array_values(array_unique(array_merge([], ...$preload))); } /** diff --git a/CacheWarmer/WarmableInterface.php b/CacheWarmer/WarmableInterface.php index e7715a33f6..2f442cb536 100644 --- a/CacheWarmer/WarmableInterface.php +++ b/CacheWarmer/WarmableInterface.php @@ -20,6 +20,8 @@ interface WarmableInterface { /** * Warms up the cache. + * + * @return string[] A list of classes or files to preload on PHP 7.4+ */ public function warmUp(string $cacheDir); } diff --git a/Kernel.php b/Kernel.php index ce3bd62408..ccca20d459 100644 --- a/Kernel.php +++ b/Kernel.php @@ -22,6 +22,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Dumper\PhpDumper; +use Symfony\Component\DependencyInjection\Dumper\Preloader; use Symfony\Component\DependencyInjection\Loader\ClosureLoader; use Symfony\Component\DependencyInjection\Loader\DirectoryLoader; use Symfony\Component\DependencyInjection\Loader\GlobFileLoader; @@ -551,7 +552,11 @@ protected function initializeContainer() } if ($this->container->has('cache_warmer')) { - $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir')); + $preload = (array) $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir')); + + if (method_exists(Preloader::class, 'append') && file_exists($preloadFile = $cacheDir.'/'.$class.'.preload.php')) { + Preloader::append($preloadFile, $preload); + } } } diff --git a/Tests/CacheWarmer/CacheWarmerTest.php b/Tests/CacheWarmer/CacheWarmerTest.php index 9cced03a47..eeb39e4dca 100644 --- a/Tests/CacheWarmer/CacheWarmerTest.php +++ b/Tests/CacheWarmer/CacheWarmerTest.php @@ -54,9 +54,14 @@ public function __construct(string $file) $this->file = $file; } + /** + * @return string[] + */ public function warmUp(string $cacheDir) { $this->writeCacheFile($this->file, 'content'); + + return []; } public function isOptional(): bool From 6cb4a212185e7ed65245fe2b1fd4f52a95d716be Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 4 Apr 2020 13:58:35 +0200 Subject: [PATCH 024/104] [HttpKernel][FrameworkBundle] fix compat with Debug component --- EventListener/DebugHandlersListener.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index dcb54ea891..0e672a299d 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -15,6 +15,7 @@ use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Event\ConsoleEvent; use Symfony\Component\Console\Output\ConsoleOutputInterface; +use Symfony\Component\Debug\ErrorHandler as LegacyErrorHandler; use Symfony\Component\Debug\Exception\FatalThrowableError; use Symfony\Component\ErrorHandler\ErrorHandler; use Symfony\Component\EventDispatcher\Event; @@ -79,7 +80,7 @@ public function configure(Event $event = null) restore_exception_handler(); if ($this->logger || null !== $this->throwAt) { - if ($handler instanceof ErrorHandler) { + if ($handler instanceof ErrorHandler || $handler instanceof LegacyErrorHandler) { if ($this->logger) { $handler->setDefaultLogger($this->logger, $this->levels); if (\is_array($this->levels)) { @@ -138,7 +139,7 @@ public function configure(Event $event = null) } } if ($this->exceptionHandler) { - if ($handler instanceof ErrorHandler) { + if ($handler instanceof ErrorHandler || $handler instanceof LegacyErrorHandler) { $handler->setExceptionHandler($this->exceptionHandler); } $this->exceptionHandler = null; From 76400d5701a1315e46a322eea011e9ec5db04b22 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 5 Apr 2020 23:50:34 +0200 Subject: [PATCH 025/104] [ErrorHandler] Remove trigger_deprecation frame from trace --- Kernel.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Kernel.php b/Kernel.php index ce3bd62408..97e4ec2e22 100644 --- a/Kernel.php +++ b/Kernel.php @@ -490,6 +490,18 @@ protected function initializeContainer() break; } } + for ($i = 0; isset($backtrace[$i]); ++$i) { + if (!isset($backtrace[$i]['file'], $backtrace[$i]['line'], $backtrace[$i]['function'])) { + continue; + } + if (!isset($backtrace[$i]['class']) && 'trigger_deprecation' === $backtrace[$i]['function']) { + $file = $backtrace[$i]['file']; + $line = $backtrace[$i]['line']; + $backtrace = \array_slice($backtrace, 1 + $i); + break; + } + } + // Remove frames added by DebugClassLoader. for ($i = \count($backtrace) - 2; 0 < $i; --$i) { if (\in_array($backtrace[$i]['class'] ?? null, [DebugClassLoader::class, LegacyDebugClassLoader::class], true)) { From c0c5cf69726437a036c005a785558a140d8eb430 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 12 Apr 2020 11:28:02 +0200 Subject: [PATCH 026/104] silence E_NOTICE triggered since PHP 7.4 --- Log/Logger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Log/Logger.php b/Log/Logger.php index f490293a62..e05d8c32ec 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -77,7 +77,7 @@ public function log($level, $message, array $context = []) } $formatter = $this->formatter; - fwrite($this->handle, $formatter($level, $message, $context)); + @fwrite($this->handle, $formatter($level, $message, $context)); } /** From 1b3c8e6cea7d9f48a2ab803b300aa4e2b6a9a5b8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 12 Apr 2020 16:22:30 +0200 Subject: [PATCH 027/104] Tweak the code to avoid fabbot false positives --- Controller/ControllerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 4e11ac640b..6244fdb9e5 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -88,7 +88,7 @@ public function getController(Request $request) try { $callable = $this->createController($controller); } catch (\InvalidArgumentException $e) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $e->getMessage()), 0, $e); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$e->getMessage(), $request->getPathInfo()), 0, $e); } return $callable; From 01579a057c470714f7e9533568328149255d191a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 12 Apr 2020 18:10:21 +0200 Subject: [PATCH 028/104] Tweak the code to avoid fabbot false positives --- Controller/ControllerResolver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 16a4a4a2e4..b3e21e5f26 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -64,7 +64,7 @@ public function getController(Request $request) } if (!\is_callable($controller)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $this->getControllerError($controller))); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$this->getControllerError($controller), $request->getPathInfo())); } return $controller; @@ -72,7 +72,7 @@ public function getController(Request $request) if (\is_object($controller)) { if (!\is_callable($controller)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $this->getControllerError($controller))); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$this->getControllerError($controller), $request->getPathInfo())); } return $controller; @@ -89,7 +89,7 @@ public function getController(Request $request) } if (!\is_callable($callable)) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s.', $request->getPathInfo(), $this->getControllerError($callable))); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$this->getControllerError($callable), $request->getPathInfo())); } return $callable; From 5d4ba814f72b96fcfc3e733234b16d76aca18ca0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 12 Apr 2020 18:39:58 +0200 Subject: [PATCH 029/104] Fix code --- Tests/Controller/ContainerControllerResolverTest.php | 2 +- Tests/Controller/ControllerResolverTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index b03169de93..4c4abf5aa4 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -248,7 +248,7 @@ public function getUndefinedControllers() [ 'Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::bar', \InvalidArgumentException::class, - '/.?[cC]ontroller(.*?) for URI "\/" is not callable\.( Expected method(.*) Available methods)?/', + '/.?[cC]ontroller(.*?) for URI "\/" is not callable:( Expected method(.*) Available methods)?/', ], ]; } diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index e34427a32e..d2684791fe 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -131,10 +131,10 @@ public function getUndefinedControllers() ['foo', 'InvalidArgumentException', 'Unable to find controller "foo".'], ['oof::bar', 'InvalidArgumentException', 'Class "oof" does not exist.'], ['stdClass', 'InvalidArgumentException', 'Unable to find controller "stdClass".'], - ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::staticsAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Expected method "staticsAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest", did you mean "staticAction"?'], - ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::privateAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Method "privateAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'], - ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::protectedAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Method "protectedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'], - ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::undefinedAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Expected method "undefinedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest". Available methods: "publicAction", "staticAction"'], + ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::staticsAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable: Expected method "staticsAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest", did you mean "staticAction"?'], + ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::privateAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable: Method "privateAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'], + ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::protectedAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable: Method "protectedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'], + ['Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::undefinedAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable: Expected method "undefinedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest". Available methods: "publicAction", "staticAction"'], ]; } From ce6bcb410c62a4e4f319ed0b984027e33ca67372 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 16 Apr 2020 18:48:01 +0200 Subject: [PATCH 030/104] Use ExpectDeprecationTrait --- Tests/Controller/ContainerControllerResolverTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index 85dd5fb671..d394c3bce4 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -13,18 +13,22 @@ use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; +use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver; class ContainerControllerResolverTest extends ControllerResolverTest { + use ExpectDeprecationTrait; + /** * @group legacy - * @expectedDeprecation Since symfony/http-kernel 5.1: Referencing controllers with a single colon is deprecated. Use "foo::action" instead. */ public function testGetControllerServiceWithSingleColon() { + $this->expectDeprecation('Since symfony/http-kernel 5.1: Referencing controllers with a single colon is deprecated. Use "foo::action" instead.'); + $service = new ControllerTestService('foo'); $container = $this->createMockContainer(); From d00202a22a0615d709368f4f331dd082c53727be Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 24 Apr 2020 00:29:13 +0200 Subject: [PATCH 031/104] Use is_file() instead of file_exists() where possible --- Kernel.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel.php b/Kernel.php index 4c4e185e71..293601dd5c 100644 --- a/Kernel.php +++ b/Kernel.php @@ -280,12 +280,12 @@ public function getProjectDir() if (null === $this->projectDir) { $r = new \ReflectionObject($this); - if (!file_exists($dir = $r->getFileName())) { + if (!is_file($dir = $r->getFileName())) { throw new \LogicException(sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name)); } $dir = $rootDir = \dirname($dir); - while (!file_exists($dir.'/composer.json')) { + while (!is_file($dir.'/composer.json')) { if ($dir === \dirname($dir)) { return $this->projectDir = $rootDir; } @@ -432,7 +432,7 @@ protected function initializeContainer() $errorLevel = error_reporting(E_ALL ^ E_WARNING); try { - if (file_exists($cachePath) && \is_object($this->container = include $cachePath) + if (is_file($cachePath) && \is_object($this->container = include $cachePath) && (!$this->debug || (self::$freshCache[$cachePath] ?? $cache->isFresh())) ) { self::$freshCache[$cachePath] = true; From 139d477cc926de9ca03c3d59b51ab6e22450c6df Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 Apr 2020 19:41:38 +0200 Subject: [PATCH 032/104] updated VERSION for 3.4.40 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 9422d90e9e..dc9cc048eb 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.40-DEV'; + const VERSION = '3.4.40'; const VERSION_ID = 30440; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 40; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 1799a6c01f0db5851f399151abdb5d6393fec277 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 Apr 2020 20:47:42 +0200 Subject: [PATCH 033/104] updated VERSION for 4.4.8 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index c583aa66d7..9cb3a034d6 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.8-DEV'; + const VERSION = '4.4.8'; const VERSION_ID = 40408; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 8; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 052e039bedd5c1201af0c981f155c1b8fef95a6c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 Apr 2020 20:52:27 +0200 Subject: [PATCH 034/104] bumped Symfony version to 4.4.9 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 9cb3a034d6..8349de676a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.8'; - const VERSION_ID = 40408; + const VERSION = '4.4.9-DEV'; + const VERSION_ID = 40409; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 8; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 9; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 3565e51eecd06106304baba5ccb7ba89db2d7d2b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 Apr 2020 20:53:25 +0200 Subject: [PATCH 035/104] updated VERSION for 5.0.8 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 357209072b..d4a6834b58 100644 --- a/Kernel.php +++ b/Kernel.php @@ -68,12 +68,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.0.8-DEV'; + const VERSION = '5.0.8'; const VERSION_ID = 50008; const MAJOR_VERSION = 5; const MINOR_VERSION = 0; const RELEASE_VERSION = 8; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '07/2020'; const END_OF_LIFE = '07/2020'; From 403d0c2503933ebe6bd2a6311f0e0f75d80fd65f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 Apr 2020 20:57:42 +0200 Subject: [PATCH 036/104] bumped Symfony version to 5.0.9 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index d4a6834b58..1c65649c65 100644 --- a/Kernel.php +++ b/Kernel.php @@ -68,12 +68,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.0.8'; - const VERSION_ID = 50008; + const VERSION = '5.0.9-DEV'; + const VERSION_ID = 50009; const MAJOR_VERSION = 5; const MINOR_VERSION = 0; - const RELEASE_VERSION = 8; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 9; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '07/2020'; const END_OF_LIFE = '07/2020'; From b5c7ec2838db5571358ff0bfedc03a215dc980ec Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 30 Apr 2020 16:23:31 +0200 Subject: [PATCH 037/104] [FrameworkBundle][CacheWarmupCommand] Append files to preload --- Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel.php b/Kernel.php index 293601dd5c..7fe8358a14 100644 --- a/Kernel.php +++ b/Kernel.php @@ -566,7 +566,7 @@ protected function initializeContainer() if ($this->container->has('cache_warmer')) { $preload = (array) $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir')); - if (method_exists(Preloader::class, 'append') && file_exists($preloadFile = $cacheDir.'/'.$class.'.preload.php')) { + if ($preload && method_exists(Preloader::class, 'append') && file_exists($preloadFile = $cacheDir.'/'.$class.'.preload.php')) { Preloader::append($preloadFile, $preload); } } From 85ed61f648e0e74af4cfd2b1e32d3ae248ccf251 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 30 Apr 2020 18:01:38 +0200 Subject: [PATCH 038/104] [HttpFoundation][HttpKernel] Add more preload always-needed symbols --- Kernel.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Kernel.php b/Kernel.php index 293601dd5c..1514696e54 100644 --- a/Kernel.php +++ b/Kernel.php @@ -39,6 +39,9 @@ use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; +// Help opcache.preload discover always-needed symbols +class_exists(ConfigCache::class); + /** * The Kernel is the heart of the Symfony system. * From dfb8372df2ab6237d5faa26a78b11fe947c64f9d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 27 Apr 2020 13:15:27 +0200 Subject: [PATCH 039/104] [HttpKernel] make kernels implementing `WarmableInterface` be part of the cache warmup stage --- CHANGELOG.md | 1 + Kernel.php | 11 +++++++---- Tests/KernelTest.php | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b766484b6..2e12f8d434 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG * made `WarmableInterface::warmUp()` return a list of classes or files to preload on PHP 7.4+; not returning an array is deprecated + * made kernels implementing `WarmableInterface` be part of the cache warmup stage * deprecated support for `service:action` syntax to reference controllers, use `serviceOrFqcn::method` instead * allowed using public aliases to reference controllers * added session usage reporting when the `_stateless` attribute of the request is set to `true` diff --git a/Kernel.php b/Kernel.php index 45e00e4e8e..b66dba0d3b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -35,6 +35,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Bundle\BundleInterface; +use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; use Symfony\Component\HttpKernel\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; @@ -566,12 +567,14 @@ protected function initializeContainer() touch($oldContainerDir.'.legacy'); } + $preload = $this instanceof WarmableInterface ? (array) $this->warmUp($this->container->getParameter('kernel.cache_dir')) : []; + if ($this->container->has('cache_warmer')) { - $preload = (array) $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir')); + $preload = array_merge($preload, (array) $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir'))); + } - if ($preload && method_exists(Preloader::class, 'append') && file_exists($preloadFile = $cacheDir.'/'.$class.'.preload.php')) { - Preloader::append($preloadFile, $preload); - } + if ($preload && method_exists(Preloader::class, 'append') && file_exists($preloadFile = $cacheDir.'/'.$class.'.preload.php')) { + Preloader::append($preloadFile, $preload); } } diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index e9f100a8af..ea6ab60ef5 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -19,6 +19,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Bundle\BundleInterface; +use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass; use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter; use Symfony\Component\HttpKernel\HttpKernelInterface; @@ -480,6 +481,14 @@ public function testKernelPass() $this->assertTrue($kernel->getContainer()->getParameter('test.processed')); } + public function testWarmup() + { + $kernel = new CustomProjectDirKernel(); + $kernel->boot(); + + $this->assertTrue($kernel->warmedUp); + } + public function testServicesResetter() { $httpKernelMock = $this->getMockBuilder(HttpKernelInterface::class) @@ -603,8 +612,9 @@ public function getProjectDir(): string } } -class CustomProjectDirKernel extends Kernel +class CustomProjectDirKernel extends Kernel implements WarmableInterface { + public $warmedUp = false; private $baseDir; private $buildContainer; private $httpKernel; @@ -631,6 +641,13 @@ public function getProjectDir(): string return __DIR__.'/Fixtures'; } + public function warmUp(string $cacheDir): array + { + $this->warmedUp = true; + + return []; + } + protected function build(ContainerBuilder $container) { if ($build = $this->buildContainer) { From 7a6e6ca58dd89cff16488660c2885410a44f1c8e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 4 May 2020 16:41:05 +0200 Subject: [PATCH 040/104] Fix exception messages containing exception messages --- Controller/ControllerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 6244fdb9e5..e3a7211c1b 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -88,7 +88,7 @@ public function getController(Request $request) try { $callable = $this->createController($controller); } catch (\InvalidArgumentException $e) { - throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$e->getMessage(), $request->getPathInfo()), 0, $e); + throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e); } return $callable; From 0e9c24d5c55c8d1baa76495af85389b6d1bee76e Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Wed, 29 Apr 2020 12:17:13 +0200 Subject: [PATCH 041/104] Log deprecations on a dedicated Monolog channel --- CHANGELOG.md | 5 ++ EventListener/DebugHandlersListener.php | 75 +++++++++++----- .../DebugHandlersListenerTest.php | 86 +++++++++++++++++++ 3 files changed, 143 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b766484b6..e48612f5f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.2.0 +----- + + * allowed to use a specific logger channel for deprecations + 5.1.0 ----- diff --git a/EventListener/DebugHandlersListener.php b/EventListener/DebugHandlersListener.php index 9cecf164bc..44b1ddb187 100644 --- a/EventListener/DebugHandlersListener.php +++ b/EventListener/DebugHandlersListener.php @@ -32,6 +32,7 @@ class DebugHandlersListener implements EventSubscriberInterface { private $exceptionHandler; private $logger; + private $deprecationLogger; private $levels; private $throwAt; private $scream; @@ -48,7 +49,7 @@ class DebugHandlersListener implements EventSubscriberInterface * @param string|FileLinkFormatter|null $fileLinkFormat The format for links to source files * @param bool $scope Enables/disables scoping mode */ - public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, ?int $throwAt = E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true) + public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, ?int $throwAt = E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true, LoggerInterface $deprecationLogger = null) { $this->exceptionHandler = $exceptionHandler; $this->logger = $logger; @@ -57,6 +58,7 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $ $this->scream = $scream; $this->fileLinkFormat = $fileLinkFormat; $this->scope = $scope; + $this->deprecationLogger = $deprecationLogger; } /** @@ -76,31 +78,30 @@ public function configure(object $event = null) $handler = \is_array($handler) ? $handler[0] : null; restore_exception_handler(); - if ($this->logger || null !== $this->throwAt) { - if ($handler instanceof ErrorHandler) { - if ($this->logger) { - $handler->setDefaultLogger($this->logger, $this->levels); - if (\is_array($this->levels)) { - $levels = 0; - foreach ($this->levels as $type => $log) { - $levels |= $type; - } - } else { - $levels = $this->levels; - } - if ($this->scream) { - $handler->screamAt($levels); + if ($handler instanceof ErrorHandler) { + if ($this->logger || $this->deprecationLogger) { + $this->setDefaultLoggers($handler); + if (\is_array($this->levels)) { + $levels = 0; + foreach ($this->levels as $type => $log) { + $levels |= $type; } - if ($this->scope) { - $handler->scopeAt($levels & ~E_USER_DEPRECATED & ~E_DEPRECATED); - } else { - $handler->scopeAt(0, true); - } - $this->logger = $this->levels = null; + } else { + $levels = $this->levels; } - if (null !== $this->throwAt) { - $handler->throwAt($this->throwAt, true); + + if ($this->scream) { + $handler->screamAt($levels); } + if ($this->scope) { + $handler->scopeAt($levels & ~E_USER_DEPRECATED & ~E_DEPRECATED); + } else { + $handler->scopeAt(0, true); + } + $this->logger = $this->deprecationLogger = $this->levels = null; + } + if (null !== $this->throwAt) { + $handler->throwAt($this->throwAt, true); } } if (!$this->exceptionHandler) { @@ -135,6 +136,34 @@ public function configure(object $event = null) } } + private function setDefaultLoggers(ErrorHandler $handler): void + { + if (\is_array($this->levels)) { + $levelsDeprecatedOnly = []; + $levelsWithoutDeprecated = []; + foreach ($this->levels as $type => $log) { + if (E_DEPRECATED == $type || E_USER_DEPRECATED == $type) { + $levelsDeprecatedOnly[$type] = $log; + } else { + $levelsWithoutDeprecated[$type] = $log; + } + } + } else { + $levelsDeprecatedOnly = $this->levels & (E_DEPRECATED | E_USER_DEPRECATED); + $levelsWithoutDeprecated = $this->levels & ~E_DEPRECATED & ~E_USER_DEPRECATED; + } + + $defaultLoggerLevels = $this->levels; + if ($this->deprecationLogger && $levelsDeprecatedOnly) { + $handler->setDefaultLogger($this->deprecationLogger, $levelsDeprecatedOnly); + $defaultLoggerLevels = $levelsWithoutDeprecated; + } + + if ($this->logger && $defaultLoggerLevels) { + $handler->setDefaultLogger($this->logger, $defaultLoggerLevels); + } + } + public static function getSubscribedEvents(): array { $events = [KernelEvents::REQUEST => ['configure', 2048]]; diff --git a/Tests/EventListener/DebugHandlersListenerTest.php b/Tests/EventListener/DebugHandlersListenerTest.php index 6f04c0a4c6..abd202f381 100644 --- a/Tests/EventListener/DebugHandlersListenerTest.php +++ b/Tests/EventListener/DebugHandlersListenerTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; @@ -150,4 +151,89 @@ public function testReplaceExistingExceptionHandler() $this->assertSame($userHandler, $eHandler->setExceptionHandler('var_dump')); } + + public function provideLevelsAssignedToLoggers(): array + { + return [ + [false, false, '0', null, null], + [false, false, E_ALL, null, null], + [false, false, [], null, null], + [false, false, [E_WARNING => LogLevel::WARNING, E_USER_DEPRECATED => LogLevel::NOTICE], null, null], + + [true, false, E_ALL, E_ALL, null], + [true, false, E_DEPRECATED, E_DEPRECATED, null], + [true, false, [], null, null], + [true, false, [E_WARNING => LogLevel::WARNING, E_DEPRECATED => LogLevel::NOTICE], [E_WARNING => LogLevel::WARNING, E_DEPRECATED => LogLevel::NOTICE], null], + + [false, true, '0', null, null], + [false, true, E_ALL, null, E_DEPRECATED | E_USER_DEPRECATED], + [false, true, E_ERROR, null, null], + [false, true, [], null, null], + [false, true, [E_ERROR => LogLevel::ERROR, E_DEPRECATED => LogLevel::DEBUG], null, [E_DEPRECATED => LogLevel::DEBUG]], + + [true, true, '0', null, null], + [true, true, E_ALL, E_ALL & ~(E_DEPRECATED | E_USER_DEPRECATED), E_DEPRECATED | E_USER_DEPRECATED], + [true, true, E_ERROR, E_ERROR, null], + [true, true, E_USER_DEPRECATED, null, E_USER_DEPRECATED], + [true, true, [E_ERROR => LogLevel::ERROR, E_DEPRECATED => LogLevel::DEBUG], [E_ERROR => LogLevel::ERROR], [E_DEPRECATED => LogLevel::DEBUG]], + [true, true, [E_ERROR => LogLevel::ALERT], [E_ERROR => LogLevel::ALERT], null], + [true, true, [E_USER_DEPRECATED => LogLevel::NOTICE], null, [E_USER_DEPRECATED => LogLevel::NOTICE]], + ]; + } + + /** + * @dataProvider provideLevelsAssignedToLoggers + * + * @param array|string $levels + * @param array|string|null $expectedLoggerLevels + * @param array|string|null $expectedDeprecationLoggerLevels + */ + public function testLevelsAssignedToLoggers(bool $hasLogger, bool $hasDeprecationLogger, $levels, $expectedLoggerLevels, $expectedDeprecationLoggerLevels) + { + if (!class_exists(ErrorHandler::class)) { + $this->markTestSkipped('ErrorHandler component is required to run this test.'); + } + + $handler = $this->createMock(ErrorHandler::class); + + $expectedCalls = []; + $logger = null; + + $deprecationLogger = null; + if ($hasDeprecationLogger) { + $deprecationLogger = $this->createMock(LoggerInterface::class); + if (null !== $expectedDeprecationLoggerLevels) { + $expectedCalls[] = [$deprecationLogger, $expectedDeprecationLoggerLevels]; + } + } + + if ($hasLogger) { + $logger = $this->createMock(LoggerInterface::class); + if (null !== $expectedLoggerLevels) { + $expectedCalls[] = [$logger, $expectedLoggerLevels]; + } + } + + $handler + ->expects($this->exactly(\count($expectedCalls))) + ->method('setDefaultLogger') + ->withConsecutive(...$expectedCalls); + + $sut = new DebugHandlersListener(null, $logger, $levels, null, true, null, true, $deprecationLogger); + $prevHander = set_exception_handler([$handler, 'handleError']); + + try { + $handler + ->method('handleError') + ->willReturnCallback(function () use ($prevHander) { + $prevHander(...\func_get_args()); + }); + + $sut->configure(); + set_exception_handler($prevHander); + } catch (\Exception $e) { + set_exception_handler($prevHander); + throw $e; + } + } } From 3d3085b9f22bd2174797d3fa256a112dea71483d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 5 May 2020 07:40:09 +0200 Subject: [PATCH 042/104] Fix changelog --- CHANGELOG.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d4f81c4ea..b74c4b8757 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,10 @@ CHANGELOG ========= -5.2.0 ------ - - * allowed to use a specific logger channel for deprecations - 5.1.0 ----- + * allowed to use a specific logger channel for deprecations * made `WarmableInterface::warmUp()` return a list of classes or files to preload on PHP 7.4+; not returning an array is deprecated * made kernels implementing `WarmableInterface` be part of the cache warmup stage From a51d2355d2de8e66ada53f90e89378275cc7c6e7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 5 May 2020 19:05:38 +0200 Subject: [PATCH 043/104] updated VERSION for 5.1.0-BETA1 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index b66dba0d3b..738f913886 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.0-DEV'; + const VERSION = '5.1.0-BETA1'; const VERSION_ID = 50100; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = 'BETA1'; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From ee30c3957acddc275924718dd99cf3d220be9fba Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 5 May 2020 19:11:24 +0200 Subject: [PATCH 044/104] bumped Symfony version to 5.1.0 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 738f913886..b66dba0d3b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.0-BETA1'; + const VERSION = '5.1.0-DEV'; const VERSION_ID = 50100; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'BETA1'; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From b9dcde9571b45ee7eac70faf634ae6c398ff8efe Mon Sep 17 00:00:00 2001 From: Marc Weistroff Date: Tue, 12 May 2020 14:07:21 +0200 Subject: [PATCH 045/104] Change priority of KernelEvents::RESPONSE subscriber --- EventListener/ProfilerListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventListener/ProfilerListener.php b/EventListener/ProfilerListener.php index b8464f1627..fec89c3ed3 100644 --- a/EventListener/ProfilerListener.php +++ b/EventListener/ProfilerListener.php @@ -119,7 +119,7 @@ public function onKernelTerminate(PostResponseEvent $event) public static function getSubscribedEvents() { return [ - KernelEvents::RESPONSE => ['onKernelResponse', -100], + KernelEvents::RESPONSE => ['onKernelResponse', -1012], KernelEvents::EXCEPTION => ['onKernelException', 0], KernelEvents::TERMINATE => ['onKernelTerminate', -1024], ]; From 7441fbe98ea8b412cbc554132412a6eb7ae7ffe6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 16 May 2020 14:31:53 +0200 Subject: [PATCH 046/104] updated VERSION for 5.1.0-RC1 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index b66dba0d3b..163e112077 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.0-DEV'; + const VERSION = '5.1.0-RC1'; const VERSION_ID = 50100; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = 'RC1'; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From b4e4e43f61bf2195dc4b9f23a200b6b223c79b06 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 16 May 2020 14:36:23 +0200 Subject: [PATCH 047/104] bumped Symfony version to 5.1.0 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 163e112077..b66dba0d3b 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.0-RC1'; + const VERSION = '5.1.0-DEV'; const VERSION_ID = 50100; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'RC1'; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From 7d9b08c59456c61cbe0e768bddbefa55841c9812 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 16 May 2020 15:57:47 +0200 Subject: [PATCH 048/104] Revert "Change priority of KernelEvents::RESPONSE subscriber" This reverts commit 6ed624ad16d21a5daf8f0e132cbef53ff1e0de59. --- EventListener/ProfilerListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventListener/ProfilerListener.php b/EventListener/ProfilerListener.php index fec89c3ed3..b8464f1627 100644 --- a/EventListener/ProfilerListener.php +++ b/EventListener/ProfilerListener.php @@ -119,7 +119,7 @@ public function onKernelTerminate(PostResponseEvent $event) public static function getSubscribedEvents() { return [ - KernelEvents::RESPONSE => ['onKernelResponse', -1012], + KernelEvents::RESPONSE => ['onKernelResponse', -100], KernelEvents::EXCEPTION => ['onKernelException', 0], KernelEvents::TERMINATE => ['onKernelTerminate', -1024], ]; From 238f49161af85e68700eb6379826ec2dc03cd9ab Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 18 May 2020 16:22:26 +0200 Subject: [PATCH 049/104] [HttpKernel] Fix error logger when stderr is redirected to /dev/null (FPM) --- Log/Logger.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Log/Logger.php b/Log/Logger.php index e05d8c32ec..bbdd101d7d 100644 --- a/Log/Logger.php +++ b/Log/Logger.php @@ -37,10 +37,10 @@ class Logger extends AbstractLogger private $formatter; private $handle; - public function __construct($minLevel = null, $output = 'php://stderr', callable $formatter = null) + public function __construct($minLevel = null, $output = null, callable $formatter = null) { if (null === $minLevel) { - $minLevel = 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::CRITICAL : LogLevel::WARNING; + $minLevel = null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING; if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) { switch ((int) (isset($_ENV['SHELL_VERBOSITY']) ? $_ENV['SHELL_VERBOSITY'] : $_SERVER['SHELL_VERBOSITY'])) { @@ -58,7 +58,7 @@ public function __construct($minLevel = null, $output = 'php://stderr', callable $this->minLevelIndex = self::$levels[$minLevel]; $this->formatter = $formatter ?: [$this, 'format']; - if (false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) { + if ($output && false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) { throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output)); } } @@ -77,7 +77,11 @@ public function log($level, $message, array $context = []) } $formatter = $this->formatter; - @fwrite($this->handle, $formatter($level, $message, $context)); + if ($this->handle) { + @fwrite($this->handle, $formatter($level, $message, $context)); + } else { + error_log($formatter($level, $message, $context, false)); + } } /** @@ -86,7 +90,7 @@ public function log($level, $message, array $context = []) * * @return string */ - private function format($level, $message, array $context) + private function format($level, $message, array $context, $prefixDate = true) { if (false !== strpos($message, '{')) { $replacements = []; @@ -105,6 +109,11 @@ private function format($level, $message, array $context) $message = strtr($message, $replacements); } - return sprintf('%s [%s] %s', date(\DateTime::RFC3339), $level, $message).PHP_EOL; + $log = sprintf('[%s] %s', $level, $message).PHP_EOL; + if ($prefixDate) { + $log = date(\DateTime::RFC3339).' '.$log; + } + + return $log; } } From 00b5b7c0644d59354ce646179b5c1a45fa7f74db Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Sat, 16 May 2020 11:23:27 +0000 Subject: [PATCH 050/104] [HttpKernel] Fix that the `Store` would not save responses with the X-Content-Digest header present --- HttpCache/Store.php | 29 +++++++++++++++-------------- Tests/HttpCache/StoreTest.php | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/HttpCache/Store.php b/HttpCache/Store.php index c831ba2ac3..fd04a7b23d 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -177,19 +177,15 @@ public function write(Request $request, Response $response) $key = $this->getCacheKey($request); $storedEnv = $this->persistRequest($request); - // write the response body to the entity store if this is the original response - if (!$response->headers->has('X-Content-Digest')) { - $digest = $this->generateContentDigest($response); + $digest = $this->generateContentDigest($response); + $response->headers->set('X-Content-Digest', $digest); - if (!$this->save($digest, $response->getContent())) { - throw new \RuntimeException('Unable to store the entity.'); - } - - $response->headers->set('X-Content-Digest', $digest); + if (!$this->save($digest, $response->getContent(), false)) { + throw new \RuntimeException('Unable to store the entity.'); + } - if (!$response->headers->has('Transfer-Encoding')) { - $response->headers->set('Content-Length', \strlen($response->getContent())); - } + if (!$response->headers->has('Transfer-Encoding')) { + $response->headers->set('Content-Length', \strlen($response->getContent())); } // read existing cache entries, remove non-varying, and add this one to the list @@ -362,15 +358,20 @@ private function load($key) /** * Save data for the given key. * - * @param string $key The store key - * @param string $data The data to store + * @param string $key The store key + * @param string $data The data to store + * @param bool $overwrite Whether existing data should be overwritten * * @return bool */ - private function save($key, $data) + private function save($key, $data, $overwrite = true) { $path = $this->getPath($key); + if (!$overwrite && file_exists($path)) { + return true; + } + if (isset($this->locks[$key])) { $fp = $this->locks[$key]; @ftruncate($fp, 0); diff --git a/Tests/HttpCache/StoreTest.php b/Tests/HttpCache/StoreTest.php index 77cb34cfa5..07c4154269 100644 --- a/Tests/HttpCache/StoreTest.php +++ b/Tests/HttpCache/StoreTest.php @@ -97,6 +97,27 @@ public function testSetsTheXContentDigestResponseHeaderBeforeStoring() $this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]); } + public function testDoesNotTrustXContentDigestFromUpstream() + { + $response = new Response('test', 200, ['X-Content-Digest' => 'untrusted-from-elsewhere']); + + $cacheKey = $this->store->write($this->request, $response); + $entries = $this->getStoreMetadata($cacheKey); + list(, $res) = $entries[0]; + + $this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]); + $this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $response->headers->get('X-Content-Digest')); + } + + public function testWritesResponseEvenIfXContentDigestIsPresent() + { + // Prime the store + $this->store->write($this->request, new Response('test', 200, ['X-Content-Digest' => 'untrusted-from-elsewhere'])); + + $response = $this->store->lookup($this->request); + $this->assertNotNull($response); + } + public function testFindsAStoredEntryWithLookup() { $this->storeSimpleEntry(); From 2b5cb0043c3250e078fcd23679c6fca0e6aca11e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 20 May 2020 10:37:50 +0200 Subject: [PATCH 051/104] Use ">=" for the "php" requirement --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 14e1c64cc0..eca3b54b36 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": ">=7.1.3", "symfony/error-handler": "^4.4", "symfony/event-dispatcher": "^4.4", "symfony/http-foundation": "^4.4|^5.0", From 34db0698fe3fbcf53ebe1df127e820a028268c5c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Thu, 21 May 2020 13:30:55 +0200 Subject: [PATCH 052/104] Address deprecation of ReflectionType::getClass(). --- Controller/ControllerResolver.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index e3a7211c1b..688d574ceb 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -136,7 +136,7 @@ protected function doGetArguments(Request $request, $controller, array $paramete } else { $arguments[] = $attributes[$param->name]; } - } elseif ($param->getClass() && $param->getClass()->isInstance($request)) { + } elseif ($this->typeMatchesRequestClass($param, $request)) { $arguments[] = $request; } elseif ($param->isDefaultValueAvailable()) { $arguments[] = $param->getDefaultValue(); @@ -260,4 +260,22 @@ private function getControllerError($callable) return $message; } + + /** + * @return bool + */ + private function typeMatchesRequestClass(\ReflectionParameter $param, Request $request) + { + if (!method_exists($param, 'getType')) { + return $param->getClass() && $param->getClass()->isInstance($request); + } + + if (!($type = $param->getType()) || $type->isBuiltin()) { + return false; + } + + $class = new \ReflectionClass(method_exists($type, 'getName') ? $type->getName() : (string) $type); + + return $class && $class->isInstance($request); + } } From 5b389af7f40a3ce704145b7c719d66bc3a401d48 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 May 2020 15:23:31 +0200 Subject: [PATCH 053/104] [HttpKernel] Prevent calling method_exists() with non-string values. --- Controller/ControllerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index e3a7211c1b..e01c725454 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -77,7 +77,7 @@ public function getController(Request $request) throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', \get_class($controller), $request->getPathInfo())); } - if (false === strpos($controller, ':')) { + if (\is_string($controller) && false === strpos($controller, ':')) { if (method_exists($controller, '__invoke')) { return $this->instantiateController($controller); } elseif (\function_exists($controller)) { From 62e2503b8815a3d5d1e40c0e4a514a6ddddb6869 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 23 May 2020 18:55:06 +0200 Subject: [PATCH 054/104] Make PHP 8 green on Travis --- Tests/Controller/ArgumentResolverTest.php | 8 ++++---- Tests/Controller/ControllerResolverTest.php | 8 +++++--- .../ArgumentMetadataFactoryTest.php | 6 +++--- .../Controller/LegacyNullableController.php | 19 +++++++++++++++++++ .../Controller/NullableController.php | 2 +- 5 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 Tests/Fixtures/Controller/LegacyNullableController.php diff --git a/Tests/Controller/ArgumentResolverTest.php b/Tests/Controller/ArgumentResolverTest.php index a964aaeb58..bf94728a43 100644 --- a/Tests/Controller/ArgumentResolverTest.php +++ b/Tests/Controller/ArgumentResolverTest.php @@ -216,10 +216,10 @@ public function testGetNullableArguments() $request = Request::create('/'); $request->attributes->set('foo', 'foo'); $request->attributes->set('bar', new \stdClass()); - $request->attributes->set('mandatory', 'mandatory'); + $request->attributes->set('last', 'last'); $controller = [new NullableController(), 'action']; - $this->assertEquals(['foo', new \stdClass(), 'value', 'mandatory'], self::$resolver->getArguments($request, $controller)); + $this->assertEquals(['foo', new \stdClass(), 'value', 'last'], self::$resolver->getArguments($request, $controller)); } /** @@ -228,10 +228,10 @@ public function testGetNullableArguments() public function testGetNullableArgumentsWithDefaults() { $request = Request::create('/'); - $request->attributes->set('mandatory', 'mandatory'); + $request->attributes->set('last', 'last'); $controller = [new NullableController(), 'action']; - $this->assertEquals([null, null, 'value', 'mandatory'], self::$resolver->getArguments($request, $controller)); + $this->assertEquals([null, null, 'value', 'last'], self::$resolver->getArguments($request, $controller)); } public function testGetSessionArguments() diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index d2684791fe..b0a6b20058 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -15,7 +15,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ControllerResolver; -use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController; +use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\LegacyNullableController; use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController; class ControllerResolverTest extends TestCase @@ -243,6 +243,7 @@ public function testIfExceptionIsThrownWhenMissingAnArgument() /** * @requires PHP 7.1 + * @requires PHP < 8 * @group legacy */ public function testGetNullableArguments() @@ -253,12 +254,13 @@ public function testGetNullableArguments() $request->attributes->set('foo', 'foo'); $request->attributes->set('bar', new \stdClass()); $request->attributes->set('mandatory', 'mandatory'); - $controller = [new NullableController(), 'action']; + $controller = [new LegacyNullableController(), 'action']; $this->assertEquals(['foo', new \stdClass(), 'value', 'mandatory'], $resolver->getArguments($request, $controller)); } /** * @requires PHP 7.1 + * @requires PHP < 8 * @group legacy */ public function testGetNullableArgumentsWithDefaults() @@ -267,7 +269,7 @@ public function testGetNullableArgumentsWithDefaults() $request = Request::create('/'); $request->attributes->set('mandatory', 'mandatory'); - $controller = [new NullableController(), 'action']; + $controller = [new LegacyNullableController(), 'action']; $this->assertEquals([null, null, 'value', 'mandatory'], $resolver->getArguments($request, $controller)); } diff --git a/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php b/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php index e5c62a87ca..00715462a2 100644 --- a/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php +++ b/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php @@ -80,7 +80,7 @@ public function testSignature5() $this->assertEquals([ new ArgumentMetadata('foo', 'array', false, true, null, true), - new ArgumentMetadata('bar', null, false, false, null), + new ArgumentMetadata('bar', null, false, true, null, true), ], $arguments); } @@ -122,7 +122,7 @@ public function testNullableTypesSignature() new ArgumentMetadata('foo', 'string', false, false, null, true), new ArgumentMetadata('bar', \stdClass::class, false, false, null, true), new ArgumentMetadata('baz', 'string', false, true, 'value', true), - new ArgumentMetadata('mandatory', null, false, false, null, true), + new ArgumentMetadata('last', 'string', false, true, '', false), ], $arguments); } @@ -142,7 +142,7 @@ private function signature4($foo = 'default', $bar = 500, $baz = []) { } - private function signature5(array $foo = null, $bar) + private function signature5(array $foo = null, $bar = null) { } } diff --git a/Tests/Fixtures/Controller/LegacyNullableController.php b/Tests/Fixtures/Controller/LegacyNullableController.php new file mode 100644 index 0000000000..23dde69d48 --- /dev/null +++ b/Tests/Fixtures/Controller/LegacyNullableController.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller; + +class LegacyNullableController +{ + public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', $mandatory) + { + } +} diff --git a/Tests/Fixtures/Controller/NullableController.php b/Tests/Fixtures/Controller/NullableController.php index 9db4df7b4c..aacae0e3e3 100644 --- a/Tests/Fixtures/Controller/NullableController.php +++ b/Tests/Fixtures/Controller/NullableController.php @@ -13,7 +13,7 @@ class NullableController { - public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', $mandatory) + public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', string $last = '') { } } From 3361e8316006460cc3124dc5574994ac3c598cc7 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 23 May 2020 19:37:50 +0200 Subject: [PATCH 055/104] [HttpKernel] fix test --- Tests/Controller/ControllerResolverTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Tests/Controller/ControllerResolverTest.php b/Tests/Controller/ControllerResolverTest.php index b0a6b20058..d249468e88 100644 --- a/Tests/Controller/ControllerResolverTest.php +++ b/Tests/Controller/ControllerResolverTest.php @@ -243,11 +243,14 @@ public function testIfExceptionIsThrownWhenMissingAnArgument() /** * @requires PHP 7.1 - * @requires PHP < 8 * @group legacy */ public function testGetNullableArguments() { + if (\PHP_VERSION_ID >= 80000) { + $this->markTestSkipped('PHP < 8 required.'); + } + $resolver = new ControllerResolver(); $request = Request::create('/'); @@ -260,11 +263,14 @@ public function testGetNullableArguments() /** * @requires PHP 7.1 - * @requires PHP < 8 * @group legacy */ public function testGetNullableArgumentsWithDefaults() { + if (\PHP_VERSION_ID >= 80000) { + $this->markTestSkipped('PHP < 8 required.'); + } + $resolver = new ControllerResolver(); $request = Request::create('/'); From 195731b7fa6f7226f7af3964e17eb5c85377e020 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 23 May 2020 00:49:08 +0200 Subject: [PATCH 056/104] Parse and render anonymous classes correctly on php 8 --- Kernel.php | 7 ++----- Tests/KernelTest.php | 21 +++++++++++++++++++++ composer.json | 1 + 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Kernel.php b/Kernel.php index 8349de676a..438ef37f34 100644 --- a/Kernel.php +++ b/Kernel.php @@ -228,10 +228,7 @@ public function getBundles() public function getBundle($name) { if (!isset($this->bundles[$name])) { - $class = static::class; - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class; - - throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, $class)); + throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, get_debug_type($this))); } return $this->bundles[$name]; @@ -474,7 +471,7 @@ protected function build(ContainerBuilder $container) protected function getContainerClass() { $class = static::class; - $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; + $class = false !== strpos($class, "@anonymous\0") ? get_parent_class($class).str_replace('.', '_', ContainerBuilder::hash($class)) : $class; $class = $this->name.str_replace('\\', '_', $class).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $class)) { diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index deac82b72d..36f8ea6e66 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -640,6 +640,27 @@ public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel() $this->assertGreaterThan($preReBoot, $kernel->getStartTime()); } + public function testAnonymousKernelGeneratesValidContainerClass(): void + { + $kernel = new class('test', true) extends Kernel { + public function registerBundles(): iterable + { + return []; + } + + public function registerContainerConfiguration(LoaderInterface $loader): void + { + } + + public function getContainerClass(): string + { + return parent::getContainerClass(); + } + }; + + $this->assertRegExp('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*TestDebugContainer$/', $kernel->getContainerClass()); + } + /** * Returns a mock for the BundleInterface. */ diff --git a/composer.json b/composer.json index eca3b54b36..2ae07df884 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "symfony/http-foundation": "^4.4|^5.0", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-php73": "^1.9", + "symfony/polyfill-php80": "^1.15", "psr/log": "~1.0" }, "require-dev": { From c1594299cd48a7e55171f6b10ce402ae98cd2001 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 26 May 2020 09:22:08 +0200 Subject: [PATCH 057/104] updated VERSION for 5.1.0-RC2 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index c5313ee24f..b06cb82389 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.0-DEV'; + const VERSION = '5.1.0-RC2'; const VERSION_ID = 50100; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = 'RC2'; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From 182793edf7c4e3e580854334fdb7664ef0f751df Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 26 May 2020 09:39:17 +0200 Subject: [PATCH 058/104] bumped Symfony version to 5.1.0 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index b06cb82389..c5313ee24f 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.0-RC2'; + const VERSION = '5.1.0-DEV'; const VERSION_ID = 50100; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'RC2'; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From e4e4ed6c008c983645b4eee6b67d8f258cde54df Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 May 2020 07:14:17 +0200 Subject: [PATCH 059/104] updated VERSION for 3.4.41 --- Kernel.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel.php b/Kernel.php index dc9cc048eb..00382a95c1 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,11 +67,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.40'; - const VERSION_ID = 30440; + const VERSION = '3.4.41'; + const VERSION_ID = 30441; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 40; + const RELEASE_VERSION = 41; const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; From 05ff4a5cc1f1d3e24c93e2a19d55288eb306dbcb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 May 2020 07:24:17 +0200 Subject: [PATCH 060/104] bumped Symfony version to 3.4.42 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 00382a95c1..a0eb026f60 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.41'; - const VERSION_ID = 30441; + const VERSION = '3.4.42-DEV'; + const VERSION_ID = 30442; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 41; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 42; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 54526b598d7fc86a67850488b194a88a79ab8467 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 May 2020 07:25:51 +0200 Subject: [PATCH 061/104] updated VERSION for 4.4.9 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 438ef37f34..49c7ab594a 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.9-DEV'; + const VERSION = '4.4.9'; const VERSION_ID = 40409; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 9; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 9b5f471bbbaf8645a863e79b1ae50752ee5340c6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 May 2020 07:29:28 +0200 Subject: [PATCH 062/104] bumped Symfony version to 4.4.10 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 49c7ab594a..f0a2ee8d29 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.9'; - const VERSION_ID = 40409; + const VERSION = '4.4.10-DEV'; + const VERSION_ID = 40410; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 9; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 10; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 1d303b84848d155143c4e87e17675e42cc23ee88 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 May 2020 07:30:12 +0200 Subject: [PATCH 063/104] updated VERSION for 5.0.9 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index d90cb2b6c8..25111f3bc4 100644 --- a/Kernel.php +++ b/Kernel.php @@ -68,12 +68,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.0.9-DEV'; + const VERSION = '5.0.9'; const VERSION_ID = 50009; const MAJOR_VERSION = 5; const MINOR_VERSION = 0; const RELEASE_VERSION = 9; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '07/2020'; const END_OF_LIFE = '07/2020'; From 265ded949f51fc573376d47265e0003af765053b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 May 2020 08:13:19 +0200 Subject: [PATCH 064/104] bumped Symfony version to 5.0.10 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 25111f3bc4..7ed8adc6b6 100644 --- a/Kernel.php +++ b/Kernel.php @@ -68,12 +68,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.0.9'; - const VERSION_ID = 50009; + const VERSION = '5.0.10-DEV'; + const VERSION_ID = 50010; const MAJOR_VERSION = 5; const MINOR_VERSION = 0; - const RELEASE_VERSION = 9; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 10; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '07/2020'; const END_OF_LIFE = '07/2020'; From 75ff5327a7d6ede3ccc2fac3ebca9ed776b3e85c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 May 2020 08:14:18 +0200 Subject: [PATCH 065/104] updated VERSION for 5.1.0 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index c5313ee24f..0df231dca9 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.0-DEV'; + const VERSION = '5.1.0'; const VERSION_ID = 50100; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From ac72040cbf667c3b14c806461d7cac28c6ae9b62 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 May 2020 08:17:42 +0200 Subject: [PATCH 066/104] bumped Symfony version to 5.1.1 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 0df231dca9..6ec1c85f7e 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.0'; - const VERSION_ID = 50100; + const VERSION = '5.1.1-DEV'; + const VERSION_ID = 50101; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; - const RELEASE_VERSION = 0; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 1; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From f972768badff84285bbf15ec5a92fbeff4e813d4 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Sun, 7 Jun 2020 21:29:41 +0200 Subject: [PATCH 067/104] Update welcome.html.php --- Resources/welcome.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/welcome.html.php b/Resources/welcome.html.php index e1c0ff1192..b8337dc737 100644 --- a/Resources/welcome.html.php +++ b/Resources/welcome.html.php @@ -65,7 +65,7 @@
- You're seeing this page because you haven't configured any homepage URL. + You're seeing this page because you haven't configured any homepage URL and debug mode is enabled.
From 746fd7ae6330c57da3dd454b979bc9f9fd3410e1 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 10 Jun 2020 08:28:31 +0000 Subject: [PATCH 068/104] [HttpKernel] Fix regression where Store does not return response body correctly --- HttpCache/Store.php | 41 +++++++++++++++++++++++------------ Tests/HttpCache/StoreTest.php | 33 ++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/HttpCache/Store.php b/HttpCache/Store.php index fd04a7b23d..72793f582d 100644 --- a/HttpCache/Store.php +++ b/HttpCache/Store.php @@ -152,8 +152,8 @@ public function lookup(Request $request) } $headers = $match[1]; - if (file_exists($body = $this->getPath($headers['x-content-digest'][0]))) { - return $this->restoreResponse($headers, $body); + if (file_exists($path = $this->getPath($headers['x-content-digest'][0]))) { + return $this->restoreResponse($headers, $path); } // TODO the metaStore referenced an entity that doesn't exist in @@ -177,15 +177,28 @@ public function write(Request $request, Response $response) $key = $this->getCacheKey($request); $storedEnv = $this->persistRequest($request); - $digest = $this->generateContentDigest($response); - $response->headers->set('X-Content-Digest', $digest); + if ($response->headers->has('X-Body-File')) { + // Assume the response came from disk, but at least perform some safeguard checks + if (!$response->headers->has('X-Content-Digest')) { + throw new \RuntimeException('A restored response must have the X-Content-Digest header.'); + } - if (!$this->save($digest, $response->getContent(), false)) { - throw new \RuntimeException('Unable to store the entity.'); - } + $digest = $response->headers->get('X-Content-Digest'); + if ($this->getPath($digest) !== $response->headers->get('X-Body-File')) { + throw new \RuntimeException('X-Body-File and X-Content-Digest do not match.'); + } + // Everything seems ok, omit writing content to disk + } else { + $digest = $this->generateContentDigest($response); + $response->headers->set('X-Content-Digest', $digest); - if (!$response->headers->has('Transfer-Encoding')) { - $response->headers->set('Content-Length', \strlen($response->getContent())); + if (!$this->save($digest, $response->getContent(), false)) { + throw new \RuntimeException('Unable to store the entity.'); + } + + if (!$response->headers->has('Transfer-Encoding')) { + $response->headers->set('Content-Length', \strlen($response->getContent())); + } } // read existing cache entries, remove non-varying, and add this one to the list @@ -477,19 +490,19 @@ private function persistResponse(Response $response) * Restores a Response from the HTTP headers and body. * * @param array $headers An array of HTTP headers for the Response - * @param string $body The Response body + * @param string $path Path to the Response body * * @return Response */ - private function restoreResponse($headers, $body = null) + private function restoreResponse($headers, $path = null) { $status = $headers['X-Status'][0]; unset($headers['X-Status']); - if (null !== $body) { - $headers['X-Body-File'] = [$body]; + if (null !== $path) { + $headers['X-Body-File'] = [$path]; } - return new Response($body, $status, $headers); + return new Response($path, $status, $headers); } } diff --git a/Tests/HttpCache/StoreTest.php b/Tests/HttpCache/StoreTest.php index 07c4154269..6754be45a1 100644 --- a/Tests/HttpCache/StoreTest.php +++ b/Tests/HttpCache/StoreTest.php @@ -118,6 +118,39 @@ public function testWritesResponseEvenIfXContentDigestIsPresent() $this->assertNotNull($response); } + public function testWritingARestoredResponseDoesNotCorruptCache() + { + /* + * This covers the regression reported in https://github.com/symfony/symfony/issues/37174. + * + * A restored response does *not* load the body, but only keep the file path in a special X-Body-File + * header. For reasons (?), the file path was also used as the restored response body. + * It would be up to others (HttpCache...?) to hohor this header and actually load the response content + * from there. + * + * When a restored response was stored again, the Store itself would ignore the header. In the first + * step, this would compute a new Content Digest based on the file path in the restored response body; + * this is covered by "Checkpoint 1" below. But, since the X-Body-File header was left untouched (Checkpoint 2), downstream + * code (HttpCache...) would not immediately notice. + * + * Only upon performing the lookup for a second time, we'd get a Response where the (wrong) Content Digest + * is also reflected in the X-Body-File header, this time also producing wrong content when the downstream + * evaluates it. + */ + $this->store->write($this->request, $this->response); + $digest = $this->response->headers->get('X-Content-Digest'); + $path = $this->getStorePath($digest); + + $response = $this->store->lookup($this->request); + $this->store->write($this->request, $response); + $this->assertEquals($digest, $response->headers->get('X-Content-Digest')); // Checkpoint 1 + $this->assertEquals($path, $response->headers->get('X-Body-File')); // Checkpoint 2 + + $response = $this->store->lookup($this->request); + $this->assertEquals($digest, $response->headers->get('X-Content-Digest')); + $this->assertEquals($path, $response->headers->get('X-Body-File')); + } + public function testFindsAStoredEntryWithLookup() { $this->storeSimpleEntry(); From 350cc5379a80cce3ac6ebf987b354361a12f80be Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 11 Jun 2020 15:00:25 +0200 Subject: [PATCH 069/104] Fix typo --- Tests/HttpCache/StoreTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/HttpCache/StoreTest.php b/Tests/HttpCache/StoreTest.php index 6754be45a1..eee8970b96 100644 --- a/Tests/HttpCache/StoreTest.php +++ b/Tests/HttpCache/StoreTest.php @@ -125,7 +125,7 @@ public function testWritingARestoredResponseDoesNotCorruptCache() * * A restored response does *not* load the body, but only keep the file path in a special X-Body-File * header. For reasons (?), the file path was also used as the restored response body. - * It would be up to others (HttpCache...?) to hohor this header and actually load the response content + * It would be up to others (HttpCache...?) to honor this header and actually load the response content * from there. * * When a restored response was stored again, the Store itself would ignore the header. In the first From 6464a0475496040fe1f48428488d53e485be77a0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Jun 2020 12:57:07 +0200 Subject: [PATCH 070/104] updated VERSION for 3.4.42 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index a0eb026f60..1f0e29b97c 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.42-DEV'; + const VERSION = '3.4.42'; const VERSION_ID = 30442; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 42; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 7cc7538970bc7cb71aab6af6e57d5bafcd32eaa5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Jun 2020 13:14:22 +0200 Subject: [PATCH 071/104] bumped Symfony version to 3.4.43 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1f0e29b97c..7fad1ee281 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.42'; - const VERSION_ID = 30442; + const VERSION = '3.4.43-DEV'; + const VERSION_ID = 30443; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 42; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 43; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 81d42148474e1852a333ed7a732f2a014af75430 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Jun 2020 13:15:37 +0200 Subject: [PATCH 072/104] updated VERSION for 4.4.10 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index f0a2ee8d29..25e8202cdb 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.10-DEV'; + const VERSION = '4.4.10'; const VERSION_ID = 40410; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 10; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 1400e5b5792c6f47da5c1f7c01f5edbc00c04835 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Jun 2020 13:19:16 +0200 Subject: [PATCH 073/104] bumped Symfony version to 4.4.11 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 25e8202cdb..6b08101e21 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.10'; - const VERSION_ID = 40410; + const VERSION = '4.4.11-DEV'; + const VERSION_ID = 40411; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 10; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 11; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 03b0be19b9b9df26e72713c3b8ce9e6ba8a259ff Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Jun 2020 13:20:19 +0200 Subject: [PATCH 074/104] updated VERSION for 5.0.10 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7ed8adc6b6..a43aa286e5 100644 --- a/Kernel.php +++ b/Kernel.php @@ -68,12 +68,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.0.10-DEV'; + const VERSION = '5.0.10'; const VERSION_ID = 50010; const MAJOR_VERSION = 5; const MINOR_VERSION = 0; const RELEASE_VERSION = 10; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '07/2020'; const END_OF_LIFE = '07/2020'; From 8756c3f8604ed4960cf3383d9bdb606b80645050 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Jun 2020 13:25:22 +0200 Subject: [PATCH 075/104] bumped Symfony version to 5.0.11 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index a43aa286e5..8cc002b513 100644 --- a/Kernel.php +++ b/Kernel.php @@ -68,12 +68,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.0.10'; - const VERSION_ID = 50010; + const VERSION = '5.0.11-DEV'; + const VERSION_ID = 50011; const MAJOR_VERSION = 5; const MINOR_VERSION = 0; - const RELEASE_VERSION = 10; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 11; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '07/2020'; const END_OF_LIFE = '07/2020'; From 1151e5d51a680b22e758d05c6647dd9857503ec8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Jun 2020 13:25:56 +0200 Subject: [PATCH 076/104] updated VERSION for 5.1.1 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 6ec1c85f7e..ceb069ee2c 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.1-DEV'; + const VERSION = '5.1.1'; const VERSION_ID = 50101; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; const RELEASE_VERSION = 1; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From 3f622b02c8deac9965e070772214b8c5a5822853 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 12 Jun 2020 14:20:44 +0200 Subject: [PATCH 077/104] bumped Symfony version to 5.1.2 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index ceb069ee2c..8190103082 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.1'; - const VERSION_ID = 50101; + const VERSION = '5.1.2-DEV'; + const VERSION_ID = 50102; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; - const RELEASE_VERSION = 1; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 2; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From a18c27ace1ef344ffcb129a5b089bad7643b387a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 15 Jun 2020 15:51:38 +0200 Subject: [PATCH 078/104] updated VERSION for 5.1.2 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 8190103082..178585762d 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.2-DEV'; + const VERSION = '5.1.2'; const VERSION_ID = 50102; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; const RELEASE_VERSION = 2; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From e737872c9812959f34933f7db911dc5b5024944f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 15 Jun 2020 16:01:03 +0200 Subject: [PATCH 079/104] bumped Symfony version to 5.1.3 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 178585762d..4f7e6e0408 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.2'; - const VERSION_ID = 50102; + const VERSION = '5.1.3-DEV'; + const VERSION_ID = 50103; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; - const RELEASE_VERSION = 2; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 3; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From 8ebcd836e0affce675fb397d18c340cefb196ad4 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 13 Jun 2020 10:25:25 +0200 Subject: [PATCH 080/104] [3.4] Small update in our internal terminology --- DependencyInjection/AddAnnotatedClassesToCachePass.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/AddAnnotatedClassesToCachePass.php b/DependencyInjection/AddAnnotatedClassesToCachePass.php index 8bb03bd0c7..b59949379d 100644 --- a/DependencyInjection/AddAnnotatedClassesToCachePass.php +++ b/DependencyInjection/AddAnnotatedClassesToCachePass.php @@ -136,10 +136,10 @@ private function patternsToRegexps($patterns) private function matchAnyRegexps($class, $regexps) { - $blacklisted = false !== strpos($class, 'Test'); + $isTest = false !== strpos($class, 'Test'); foreach ($regexps as $regex) { - if ($blacklisted && false === strpos($regex, 'Test')) { + if ($isTest && false === strpos($regex, 'Test')) { continue; } From e8c115612b24e4bdf1c493512fe36ac5e34106a3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 15 Jun 2020 16:43:28 +0200 Subject: [PATCH 081/104] Fix support for PHP8 union types --- ControllerMetadata/ArgumentMetadataFactory.php | 2 +- EventListener/ErrorListener.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ControllerMetadata/ArgumentMetadataFactory.php b/ControllerMetadata/ArgumentMetadataFactory.php index 9370174c25..6c192a6f5f 100644 --- a/ControllerMetadata/ArgumentMetadataFactory.php +++ b/ControllerMetadata/ArgumentMetadataFactory.php @@ -45,7 +45,7 @@ public function createArgumentMetadata($controller): array */ private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function): ?string { - if (!$type = $parameter->getType()) { + if (!($type = $parameter->getType()) instanceof \ReflectionNamedType) { return null; } $name = $type->getName(); diff --git a/EventListener/ErrorListener.php b/EventListener/ErrorListener.php index 26c361f754..1ca6c9b458 100644 --- a/EventListener/ErrorListener.php +++ b/EventListener/ErrorListener.php @@ -99,7 +99,7 @@ public function onControllerArguments(ControllerArgumentsEvent $event) $r = new \ReflectionFunction(\Closure::fromCallable($event->getController())); $r = $r->getParameters()[$k] ?? null; - if ($r && (!$r->hasType() || \in_array($r->getType()->getName(), [FlattenException::class, LegacyFlattenException::class], true))) { + if ($r && (!($r = $r->getType()) instanceof \ReflectionNamedType || \in_array($r->getName(), [FlattenException::class, LegacyFlattenException::class], true))) { $arguments = $event->getArguments(); $arguments[$k] = FlattenException::createFromThrowable($e); $event->setArguments($arguments); From 66a6ceafd959d93bf9bc84886f17e5a1be801837 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 18 Jun 2020 21:30:53 +0200 Subject: [PATCH 082/104] Fix --- ControllerMetadata/ArgumentMetadataFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ControllerMetadata/ArgumentMetadataFactory.php b/ControllerMetadata/ArgumentMetadataFactory.php index 2548a2a083..14e7ca3d11 100644 --- a/ControllerMetadata/ArgumentMetadataFactory.php +++ b/ControllerMetadata/ArgumentMetadataFactory.php @@ -105,7 +105,7 @@ private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbs if (!$type = $parameter->getType()) { return null; } - $name = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString(); + $name = $type instanceof \ReflectionNamedType ? $type->getName() : (string) $type; if ('array' === $name && !$type->isBuiltin()) { // Special case for HHVM with variadics return null; From 1e96d6dea796cd71615658d9e5d57d2effbc8f5f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 8 Jul 2020 19:07:26 +0200 Subject: [PATCH 083/104] Fix PHP 8 deprecations --- Controller/ControllerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 015448b510..8ed79ff7b2 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -274,7 +274,7 @@ private function typeMatchesRequestClass(\ReflectionParameter $param, Request $r return false; } - $class = new \ReflectionClass(method_exists($type, 'getName') ? $type->getName() : (string) $type); + $class = new \ReflectionClass($type instanceof \ReflectionNamedType ? $type->getName() : (string) $type); return $class && $class->isInstance($request); } From 41e230aad04a49be1c241dab5eb6711f7bcab162 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 16 Jul 2020 11:17:05 +0200 Subject: [PATCH 084/104] [SCA] Minor fixes on tests --- Tests/Event/FilterControllerArgumentsEventTest.php | 2 +- Tests/Profiler/FileProfilerStorageTest.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/Event/FilterControllerArgumentsEventTest.php b/Tests/Event/FilterControllerArgumentsEventTest.php index abc51ac51e..53962347d0 100644 --- a/Tests/Event/FilterControllerArgumentsEventTest.php +++ b/Tests/Event/FilterControllerArgumentsEventTest.php @@ -12,6 +12,6 @@ class FilterControllerArgumentsEventTest extends TestCase public function testFilterControllerArgumentsEvent() { $filterController = new FilterControllerArgumentsEvent(new TestHttpKernel(), function () {}, ['test'], new Request(), 1); - $this->assertEquals($filterController->getArguments(), ['test']); + $this->assertEquals(['test'], $filterController->getArguments()); } } diff --git a/Tests/Profiler/FileProfilerStorageTest.php b/Tests/Profiler/FileProfilerStorageTest.php index 1cc05e41ec..7100659c4d 100644 --- a/Tests/Profiler/FileProfilerStorageTest.php +++ b/Tests/Profiler/FileProfilerStorageTest.php @@ -205,9 +205,9 @@ public function testStoreTime() $records = $this->storage->find('', '', 3, 'GET', $start, time() + 3 * 60); $this->assertCount(3, $records, '->find() returns all previously added records'); - $this->assertEquals($records[0]['token'], 'time_2', '->find() returns records ordered by time in descendant order'); - $this->assertEquals($records[1]['token'], 'time_1', '->find() returns records ordered by time in descendant order'); - $this->assertEquals($records[2]['token'], 'time_0', '->find() returns records ordered by time in descendant order'); + $this->assertEquals('time_2', $records[0]['token'], '->find() returns records ordered by time in descendant order'); + $this->assertEquals('time_1', $records[1]['token'], '->find() returns records ordered by time in descendant order'); + $this->assertEquals('time_0', $records[2]['token'], '->find() returns records ordered by time in descendant order'); $records = $this->storage->find('', '', 3, 'GET', $start, time() + 2 * 60); $this->assertCount(2, $records, '->find() should return only first two of the previously added records'); From 05200f57a89ad1df2f0c2f33fd1596289e4822b2 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 13 Jul 2020 00:27:19 +0200 Subject: [PATCH 085/104] Fix PHPUnit 8.5 deprecations. --- Tests/Controller/ContainerControllerResolverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index 4c4abf5aa4..ef1c82638b 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -232,7 +232,7 @@ public function testGetControllerOnNonUndefinedFunction($controller, $exceptionN // All this logic needs to be duplicated, since calling parent::testGetControllerOnNonUndefinedFunction will override the expected exception and not use the regex $resolver = $this->createControllerResolver(); $this->expectException($exceptionName); - $this->expectExceptionMessageRegExp($exceptionMessage); + $this->expectExceptionMessageMatches($exceptionMessage); $request = Request::create('/'); $request->attributes->set('_controller', $controller); From 4a1c6b310806adce0f299411951d06747edf9e28 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Jul 2020 05:48:59 +0200 Subject: [PATCH 086/104] updated VERSION for 3.4.43 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7fad1ee281..e824fdcf72 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.43-DEV'; + const VERSION = '3.4.43'; const VERSION_ID = 30443; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 43; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From a50959872fb69315ab98907f97ffcf65d1e86480 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Jul 2020 06:07:51 +0200 Subject: [PATCH 087/104] Bump Symfony version to 3.4.44 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index e824fdcf72..1b270bfdec 100644 --- a/Kernel.php +++ b/Kernel.php @@ -67,12 +67,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '3.4.43'; - const VERSION_ID = 30443; + const VERSION = '3.4.44-DEV'; + const VERSION_ID = 30444; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 43; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 44; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From a675d2bf04a9328f164910cae6e3918b295151f3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Jul 2020 06:10:09 +0200 Subject: [PATCH 088/104] Update VERSION for 4.4.11 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 6b08101e21..2efa73a375 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.11-DEV'; + const VERSION = '4.4.11'; const VERSION_ID = 40411; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 11; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From d42f9bee7d7975b0ce62413c241f714c083db84b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Jul 2020 06:14:13 +0200 Subject: [PATCH 089/104] Bump Symfony version to 4.4.12 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 2efa73a375..7c89e610fa 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.11'; - const VERSION_ID = 40411; + const VERSION = '4.4.12-DEV'; + const VERSION_ID = 40412; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 11; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 12; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From d6dd8f6420e377970ddad0d6317d4ce4186fc6b3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Jul 2020 06:22:56 +0200 Subject: [PATCH 090/104] Update VERSION for 5.1.3 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 4f7e6e0408..a906fdb82e 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.3-DEV'; + const VERSION = '5.1.3'; const VERSION_ID = 50103; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; const RELEASE_VERSION = 3; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From 5e55bf35c42afc2075880e88143a0974e3aa211e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Jul 2020 06:28:10 +0200 Subject: [PATCH 091/104] Bump Symfony version to 5.1.4 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index a906fdb82e..22732d9a80 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.3'; - const VERSION_ID = 50103; + const VERSION = '5.1.4-DEV'; + const VERSION_ID = 50104; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; - const RELEASE_VERSION = 3; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 4; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From 6451928305b13d5f126bf3ea48aa41c76cd3ce74 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 8 Aug 2020 16:41:28 +0200 Subject: [PATCH 092/104] Modernized deprecated PHPUnit assertion calls --- .../DataCollector/ConfigDataCollectorTest.php | 4 ++-- Tests/HttpCache/HttpCacheTest.php | 20 +++++++++---------- Tests/HttpCache/HttpCacheTestCase.php | 4 ++-- Tests/KernelTest.php | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index a858eabe15..f2cc4fa0dd 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -31,8 +31,8 @@ public function testCollect() $this->assertTrue($c->isDebug()); $this->assertSame('config', $c->getName()); $this->assertSame('testkernel', $c->getAppName()); - $this->assertRegExp('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION); - $this->assertRegExp('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION); + $this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION); + $this->assertMatchesRegularExpression('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION); $this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture()); $this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale()); $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone()); diff --git a/Tests/HttpCache/HttpCacheTest.php b/Tests/HttpCache/HttpCacheTest.php index cac06a80e5..444db71a3e 100644 --- a/Tests/HttpCache/HttpCacheTest.php +++ b/Tests/HttpCache/HttpCacheTest.php @@ -654,7 +654,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformation() $this->assertTraceContains('miss'); $this->assertTraceContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=10/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=10/', $this->response->headers->get('Cache-Control')); $this->cacheConfig['default_ttl'] = 10; $this->request('GET', '/'); @@ -663,7 +663,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformation() $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=10/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=10/', $this->response->headers->get('Cache-Control')); } public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpired() @@ -676,7 +676,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('miss'); $this->assertTraceContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); $this->request('GET', '/'); $this->assertHttpKernelIsNotCalled(); @@ -684,7 +684,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); // expires the cache $values = $this->getMetaStorageValues(); @@ -704,7 +704,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('invalid'); $this->assertTraceContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); $this->setNextResponse(); @@ -714,7 +714,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); } public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpiredWithStatus304() @@ -727,7 +727,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('miss'); $this->assertTraceContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); $this->request('GET', '/'); $this->assertHttpKernelIsNotCalled(); @@ -755,7 +755,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('store'); $this->assertTraceNotContains('miss'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); $this->request('GET', '/'); $this->assertHttpKernelIsNotCalled(); @@ -763,7 +763,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); + $this->assertMatchesRegularExpression('/s-maxage=(2|3)/', $this->response->headers->get('Cache-Control')); } public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirective() @@ -776,7 +776,7 @@ public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirectiv $this->assertEquals(200, $this->response->getStatusCode()); $this->assertTraceContains('miss'); $this->assertTraceNotContains('store'); - $this->assertNotRegExp('/s-maxage/', $this->response->headers->get('Cache-Control')); + $this->assertDoesNotMatchRegularExpression('/s-maxage/', $this->response->headers->get('Cache-Control')); $this->assertEquals('Hello World', $this->response->getContent()); } diff --git a/Tests/HttpCache/HttpCacheTestCase.php b/Tests/HttpCache/HttpCacheTestCase.php index 1eb4617447..3cbea5e4ee 100644 --- a/Tests/HttpCache/HttpCacheTestCase.php +++ b/Tests/HttpCache/HttpCacheTestCase.php @@ -91,7 +91,7 @@ public function assertTraceContains($trace) $traces = $this->cache->getTraces(); $traces = current($traces); - $this->assertRegExp('/'.$trace.'/', implode(', ', $traces)); + $this->assertMatchesRegularExpression('/'.$trace.'/', implode(', ', $traces)); } public function assertTraceNotContains($trace) @@ -99,7 +99,7 @@ public function assertTraceNotContains($trace) $traces = $this->cache->getTraces(); $traces = current($traces); - $this->assertNotRegExp('/'.$trace.'/', implode(', ', $traces)); + $this->assertDoesNotMatchRegularExpression('/'.$trace.'/', implode(', ', $traces)); } public function assertExceptionsAreCaught() diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index e4e2e0727b..6cbf59b9b2 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -78,7 +78,7 @@ public function testInitializeContainerClearsOldContainers() $containerDir = __DIR__.'/Fixtures/cache/custom/'.substr(\get_class($kernel->getContainer()), 0, 16); $this->assertTrue(unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta')); $this->assertFileExists($containerDir); - $this->assertFileNotExists($containerDir.'.legacy'); + $this->assertFileDoesNotExist($containerDir.'.legacy'); $kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); }); $kernel->boot(); @@ -86,8 +86,8 @@ public function testInitializeContainerClearsOldContainers() $this->assertFileExists($containerDir); $this->assertFileExists($containerDir.'.legacy'); - $this->assertFileNotExists($legacyContainerDir); - $this->assertFileNotExists($legacyContainerDir.'.legacy'); + $this->assertFileDoesNotExist($legacyContainerDir); + $this->assertFileDoesNotExist($legacyContainerDir.'.legacy'); } public function testBootInitializesBundlesAndContainer() From 8ee84f9e0e1cd3ab7d0b4d4e870ef3500ed96858 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 9 Aug 2020 14:16:18 +0200 Subject: [PATCH 093/104] PHPUnit's assertContains() performs strict comparisons now. --- Tests/DataCollector/RequestDataCollectorTest.php | 2 +- Tests/Profiler/FileProfilerStorageTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/DataCollector/RequestDataCollectorTest.php b/Tests/DataCollector/RequestDataCollectorTest.php index 38979bba72..9bf5bf968d 100644 --- a/Tests/DataCollector/RequestDataCollectorTest.php +++ b/Tests/DataCollector/RequestDataCollectorTest.php @@ -51,7 +51,7 @@ public function testCollect() $this->assertEquals(['name' => 'foo'], $c->getRouteParams()); $this->assertSame([], $c->getSessionAttributes()); $this->assertSame('en', $c->getLocale()); - $this->assertContains(__FILE__, $attributes->get('resource')); + $this->assertContainsEquals(__FILE__, $attributes->get('resource')); $this->assertSame('stdClass', $attributes->get('object')->getType()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getResponseHeaders()); diff --git a/Tests/Profiler/FileProfilerStorageTest.php b/Tests/Profiler/FileProfilerStorageTest.php index 7100659c4d..4e23f13b02 100644 --- a/Tests/Profiler/FileProfilerStorageTest.php +++ b/Tests/Profiler/FileProfilerStorageTest.php @@ -293,8 +293,8 @@ public function testStatusCode() $tokens = $this->storage->find('', '', 10, ''); $this->assertCount(2, $tokens); - $this->assertContains($tokens[0]['status_code'], [200, 404]); - $this->assertContains($tokens[1]['status_code'], [200, 404]); + $this->assertContains((int) $tokens[0]['status_code'], [200, 404]); + $this->assertContains((int) $tokens[1]['status_code'], [200, 404]); } public function testMultiRowIndexFile() From a031f696fc43db5f1ba97f33c1e0066a75196472 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 11 Aug 2020 09:56:31 +0200 Subject: [PATCH 094/104] stop using the deprecated at() PHPUnit matcher --- .../ContainerControllerResolverTest.php | 25 ++++------------- .../EventListener/TranslatorListenerTest.php | 28 +++++++++++-------- Tests/HttpKernelTest.php | 4 +-- Tests/KernelTest.php | 8 ++++-- 4 files changed, 30 insertions(+), 35 deletions(-) diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index ef1c82638b..8275154657 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -15,6 +15,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver; @@ -117,16 +118,10 @@ public function testNonConstructController() $this->expectException('LogicException'); $this->expectExceptionMessage('Controller "Symfony\Component\HttpKernel\Tests\Controller\ImpossibleConstructController" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?'); $container = $this->getMockBuilder(Container::class)->getMock(); - $container->expects($this->at(0)) + $container->expects($this->exactly(2)) ->method('has') ->with(ImpossibleConstructController::class) - ->willReturn(true) - ; - - $container->expects($this->at(1)) - ->method('has') - ->with(ImpossibleConstructController::class) - ->willReturn(false) + ->willReturnOnConsecutiveCalls(true, false) ; $container->expects($this->atLeastOnce()) @@ -181,18 +176,10 @@ public function testExceptionWhenUsingRemovedControllerService() { $this->expectException('LogicException'); $this->expectExceptionMessage('Controller "app.my_controller" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"?'); - $container = $this->getMockBuilder(Container::class)->getMock(); - $container->expects($this->at(0)) - ->method('has') - ->with('app.my_controller') - ->willReturn(false) - ; - $container->expects($this->atLeastOnce()) - ->method('getRemovedIds') - ->with() - ->willReturn(['app.my_controller' => true]) - ; + $container = new ContainerBuilder(); + $container->register('app.my_controller'); + $container->removeDefinition('app.my_controller'); $resolver = $this->createControllerResolver(null, $container); diff --git a/Tests/EventListener/TranslatorListenerTest.php b/Tests/EventListener/TranslatorListenerTest.php index 77c2c1c694..79e0d6f1ac 100644 --- a/Tests/EventListener/TranslatorListenerTest.php +++ b/Tests/EventListener/TranslatorListenerTest.php @@ -45,13 +45,15 @@ public function testLocaleIsSetInOnKernelRequest() public function testDefaultLocaleIsUsedOnExceptionsInOnKernelRequest() { $this->translator - ->expects($this->at(0)) + ->expects($this->exactly(2)) ->method('setLocale') - ->willThrowException(new \InvalidArgumentException()); - $this->translator - ->expects($this->at(1)) - ->method('setLocale') - ->with($this->equalTo('en')); + ->withConsecutive( + ['fr'], + ['en'] + ) + ->willReturnOnConsecutiveCalls( + $this->throwException(new \InvalidArgumentException()) + ); $event = new GetResponseEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); @@ -82,13 +84,15 @@ public function testLocaleIsNotSetInOnKernelFinishRequestWhenParentRequestDoesNo public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() { $this->translator - ->expects($this->at(0)) - ->method('setLocale') - ->willThrowException(new \InvalidArgumentException()); - $this->translator - ->expects($this->at(1)) + ->expects($this->exactly(2)) ->method('setLocale') - ->with($this->equalTo('en')); + ->withConsecutive( + ['fr'], + ['en'] + ) + ->willReturnOnConsecutiveCalls( + $this->throwException(new \InvalidArgumentException()) + ); $this->setMasterRequest($this->createRequest('fr')); $event = new FinishRequestEvent($this->createHttpKernel(), $this->createRequest('de'), HttpKernelInterface::SUB_REQUEST); diff --git a/Tests/HttpKernelTest.php b/Tests/HttpKernelTest.php index af81f021ed..97c58305db 100644 --- a/Tests/HttpKernelTest.php +++ b/Tests/HttpKernelTest.php @@ -314,8 +314,8 @@ public function testVerifyRequestStackPushPopDuringHandle() $request = new Request(); $stack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->setMethods(['push', 'pop'])->getMock(); - $stack->expects($this->at(0))->method('push')->with($this->equalTo($request)); - $stack->expects($this->at(1))->method('pop'); + $stack->expects($this->once())->method('push')->with($this->equalTo($request)); + $stack->expects($this->once())->method('pop'); $dispatcher = new EventDispatcher(); $kernel = $this->getHttpKernel($dispatcher, null, $stack); diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 6cbf59b9b2..fd840bbb7b 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -15,6 +15,7 @@ use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -219,9 +220,12 @@ public function testShutdownCallsShutdownOnAllBundles() public function testShutdownGivesNullContainerToAllBundles() { $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock(); - $bundle->expects($this->at(3)) + $bundle->expects($this->exactly(2)) ->method('setContainer') - ->with(null); + ->withConsecutive( + [$this->isInstanceOf(ContainerInterface::class)], + [null] + ); $kernel = $this->getKernel(['getBundles']); $kernel->expects($this->any()) From a3d083f0152a8e30d37e01c71ee775e0c789d3a0 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Fri, 14 Aug 2020 16:49:01 +0200 Subject: [PATCH 095/104] [VarDumper] Backport handler lock when using VAR_DUMPER_FORMAT --- DataCollector/DumpDataCollector.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index d9f381b3d6..4e430f8f37 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -235,13 +235,7 @@ public function __destruct() --$i; } - if (isset($_SERVER['VAR_DUMPER_FORMAT'])) { - $html = 'html' === $_SERVER['VAR_DUMPER_FORMAT']; - } else { - $html = !\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && stripos($h[$i], 'html'); - } - - if ($html) { + if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && stripos($h[$i], 'html')) { $dumper = new HtmlDumper('php://output', $this->charset); $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { From 3ab83d293cb851b243ada91325c69ac5d4c0ded3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 17 Aug 2020 09:16:16 +0200 Subject: [PATCH 096/104] Fix CS --- DataCollector/ConfigDataCollector.php | 2 +- Tests/DataCollector/ConfigDataCollectorTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DataCollector/ConfigDataCollector.php b/DataCollector/ConfigDataCollector.php index 673bf5c5fd..5895ef37d7 100644 --- a/DataCollector/ConfigDataCollector.php +++ b/DataCollector/ConfigDataCollector.php @@ -64,7 +64,7 @@ public function collect(Request $request, Response $response, \Exception $except 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 'php_version' => PHP_VERSION, - 'php_architecture' => PHP_INT_SIZE * 8, + 'php_architecture' => \PHP_INT_SIZE * 8, 'php_intl_locale' => class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => \extension_loaded('xdebug'), diff --git a/Tests/DataCollector/ConfigDataCollectorTest.php b/Tests/DataCollector/ConfigDataCollectorTest.php index f2cc4fa0dd..dc455915fa 100644 --- a/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/Tests/DataCollector/ConfigDataCollectorTest.php @@ -33,7 +33,7 @@ public function testCollect() $this->assertSame('testkernel', $c->getAppName()); $this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION); $this->assertMatchesRegularExpression('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION); - $this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture()); + $this->assertSame(\PHP_INT_SIZE * 8, $c->getPhpArchitecture()); $this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale()); $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone()); $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion()); From ce729cd7e8eb1099d3e2e5370b079b84897f7611 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 17 Aug 2020 09:39:58 +0200 Subject: [PATCH 097/104] Fix CS --- Tests/Controller/ContainerControllerResolverTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Tests/Controller/ContainerControllerResolverTest.php b/Tests/Controller/ContainerControllerResolverTest.php index c029c0b5f8..c39dac3ca5 100644 --- a/Tests/Controller/ContainerControllerResolverTest.php +++ b/Tests/Controller/ContainerControllerResolverTest.php @@ -14,7 +14,6 @@ use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver; From 4b232e313f2f6e538c17c196db156c183601779a Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 13 Aug 2020 19:28:52 +0200 Subject: [PATCH 098/104] stop using deprecated PHPUnit APIs --- .../EventListener/LocaleAwareListenerTest.php | 28 +++++++++++-------- Tests/KernelTest.php | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Tests/EventListener/LocaleAwareListenerTest.php b/Tests/EventListener/LocaleAwareListenerTest.php index ef3b7d1b42..0064429048 100644 --- a/Tests/EventListener/LocaleAwareListenerTest.php +++ b/Tests/EventListener/LocaleAwareListenerTest.php @@ -47,13 +47,15 @@ public function testLocaleIsSetInOnKernelRequest() public function testDefaultLocaleIsUsedOnExceptionsInOnKernelRequest() { $this->localeAwareService - ->expects($this->at(0)) + ->expects($this->exactly(2)) ->method('setLocale') - ->will($this->throwException(new \InvalidArgumentException())); - $this->localeAwareService - ->expects($this->at(1)) - ->method('setLocale') - ->with($this->equalTo('en')); + ->withConsecutive( + [$this->anything()], + ['en'] + ) + ->willReturnOnConsecutiveCalls( + $this->throwException(new \InvalidArgumentException()) + ); $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST); $this->listener->onKernelRequest($event); @@ -89,13 +91,15 @@ public function testLocaleIsSetToDefaultOnKernelFinishRequestWhenParentRequestDo public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest() { $this->localeAwareService - ->expects($this->at(0)) + ->expects($this->exactly(2)) ->method('setLocale') - ->will($this->throwException(new \InvalidArgumentException())); - $this->localeAwareService - ->expects($this->at(1)) - ->method('setLocale') - ->with($this->equalTo('en')); + ->withConsecutive( + [$this->anything()], + ['en'] + ) + ->willReturnOnConsecutiveCalls( + $this->throwException(new \InvalidArgumentException()) + ); $this->requestStack->push($this->createRequest('fr')); $this->requestStack->push($subRequest = $this->createRequest('de')); diff --git a/Tests/KernelTest.php b/Tests/KernelTest.php index 4d40a1b34f..b4075c98ba 100644 --- a/Tests/KernelTest.php +++ b/Tests/KernelTest.php @@ -662,7 +662,7 @@ public function getContainerClass(): string } }; - $this->assertRegExp('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*TestDebugContainer$/', $kernel->getContainerClass()); + $this->assertMatchesRegularExpression('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*TestDebugContainer$/', $kernel->getContainerClass()); } /** From f93f6b3e52a590749994cc23d8fb879472ceb76c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 31 Aug 2020 08:09:42 +0200 Subject: [PATCH 099/104] Update VERSION for 4.4.12 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 7c89e610fa..77806d80ca 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.12-DEV'; + const VERSION = '4.4.12'; const VERSION_ID = 40412; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 12; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From a5ed890bd448a456a592e14b46996140eeface4b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 31 Aug 2020 08:14:12 +0200 Subject: [PATCH 100/104] Bump Symfony version to 4.4.13 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 77806d80ca..e7c70c8fd4 100644 --- a/Kernel.php +++ b/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '4.4.12'; - const VERSION_ID = 40412; + const VERSION = '4.4.13-DEV'; + const VERSION_ID = 40413; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 12; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 13; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From f829c240113986b60fda425c2533142e88efd7c4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 31 Aug 2020 08:18:12 +0200 Subject: [PATCH 101/104] Update VERSION for 5.1.4 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 22732d9a80..421b68d895 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.4-DEV'; + const VERSION = '5.1.4'; const VERSION_ID = 50104; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; const RELEASE_VERSION = 4; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From 05293dddb5d44bbadfa95aec4c5755a0d8eac7cd Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 31 Aug 2020 08:22:19 +0200 Subject: [PATCH 102/104] Bump Symfony version to 5.1.5 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 421b68d895..b6788a4046 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.4'; - const VERSION_ID = 50104; + const VERSION = '5.1.5-DEV'; + const VERSION_ID = 50105; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; - const RELEASE_VERSION = 4; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 5; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021'; From 8e8d0edc74a13fe592ca5b1c392b41c63f519ecc Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Mon, 15 Jun 2020 07:28:47 +0000 Subject: [PATCH 103/104] Remove headers with internal meaning from HttpClient responses --- HttpClientKernel.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HttpClientKernel.php b/HttpClientKernel.php index 912ce313f8..2056a673a6 100644 --- a/HttpClientKernel.php +++ b/HttpClientKernel.php @@ -58,6 +58,10 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ $response = new Response($response->getContent(!$catch), $response->getStatusCode(), $response->getHeaders(!$catch)); + $response->headers->remove('X-Body-File'); + $response->headers->remove('X-Body-Eval'); + $response->headers->remove('X-Content-Digest'); + $response->headers = new class($response->headers->all()) extends ResponseHeaderBag { protected function computeCacheControlValue(): string { From 3e32676e6cb5d2081c91a56783471ff8a7f7110b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 2 Sep 2020 10:15:18 +0200 Subject: [PATCH 104/104] Update VERSION for 5.1.5 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index b6788a4046..c90c77ae77 100644 --- a/Kernel.php +++ b/Kernel.php @@ -73,12 +73,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - const VERSION = '5.1.5-DEV'; + const VERSION = '5.1.5'; const VERSION_ID = 50105; const MAJOR_VERSION = 5; const MINOR_VERSION = 1; const RELEASE_VERSION = 5; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2021'; const END_OF_LIFE = '01/2021';