From 7f2e7e2e9aec039fdd2396e5a3f1ce8dc5c37bf3 Mon Sep 17 00:00:00 2001 From: Pierre du Plessis Date: Wed, 24 Jul 2019 15:26:40 +0200 Subject: [PATCH 01/13] Recompile container when translations directory changes --- .../DependencyInjection/FrameworkExtension.php | 10 +++++----- .../DependencyInjection/FrameworkExtensionTest.php | 13 ------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index e63d5b1aff..9caea53511 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1128,12 +1128,12 @@ class FrameworkExtension extends Extension $defaultDir = $container->getParameterBag()->resolveValue($config['default_path']); $rootDir = $container->getParameter('kernel.root_dir'); foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { - if (is_dir($dir = $bundle['path'].'/Resources/translations')) { + if ($container->fileExists($dir = $bundle['path'].'/Resources/translations')) { $dirs[] = $dir; } else { $nonExistingDirs[] = $dir; } - if (is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) { + if ($container->fileExists($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) { @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED); $dirs[] = $dir; } else { @@ -1142,7 +1142,7 @@ class FrameworkExtension extends Extension } foreach ($config['paths'] as $dir) { - if (is_dir($dir)) { + if ($container->fileExists($dir)) { $dirs[] = $transPaths[] = $dir; } else { throw new \UnexpectedValueException(sprintf('%s defined in translator.paths does not exist or is not a directory', $dir)); @@ -1157,13 +1157,13 @@ class FrameworkExtension extends Extension $container->getDefinition('console.command.translation_update')->replaceArgument(6, $transPaths); } - if (is_dir($defaultDir)) { + if ($container->fileExists($defaultDir)) { $dirs[] = $defaultDir; } else { $nonExistingDirs[] = $defaultDir; } - if (is_dir($dir = $rootDir.'/Resources/translations')) { + if ($container->fileExists($dir = $rootDir.'/Resources/translations')) { if ($dir !== $defaultDir) { @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 251e2eb624..3b12c97dc3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -24,8 +24,6 @@ use Symfony\Component\Cache\Adapter\DoctrineAdapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\ProxyAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; -use Symfony\Component\Config\Resource\DirectoryResource; -use Symfony\Component\Config\Resource\FileExistenceResource; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\ResolveInstanceofConditionalsPass; @@ -840,17 +838,6 @@ abstract class FrameworkExtensionTest extends TestCase ); $this->assertNotEmpty($nonExistingDirectories, 'FrameworkBundle should pass non existing directories to Translator'); - - $resources = $container->getResources(); - foreach ($resources as $resource) { - if ($resource instanceof DirectoryResource) { - $this->assertNotContains('translations', $resource->getResource()); - } - - if ($resource instanceof FileExistenceResource) { - $this->assertNotContains('translations', $resource->getResource()); - } - } } /** From bf4c713ad71ac8bf09c9d8ee6fef823433df20b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20de=20Guillebon?= Date: Wed, 24 Jul 2019 17:35:10 +0200 Subject: [PATCH 02/13] Fix bindings and tagged_locator --- .../Component/DependencyInjection/Compiler/PassConfig.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php index e39cd4981a..6df0929fd8 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php @@ -51,15 +51,15 @@ class PassConfig $this->optimizationPasses = [[ new ValidateEnvPlaceholdersPass(), new ResolveChildDefinitionsPass(), - new ServiceLocatorTagPass(), new RegisterServiceSubscribersPass(), new DecoratorServicePass(), new ResolveParameterPlaceHoldersPass(false), new ResolveFactoryClassPass(), - new CheckDefinitionValidityPass(), new ResolveNamedArgumentsPass(), new AutowireRequiredMethodsPass(), new ResolveBindingsPass(), + new ServiceLocatorTagPass(), + new CheckDefinitionValidityPass(), new AutowirePass(false), new ResolveTaggedIteratorArgumentPass(), new ResolveServiceSubscribersPass(), From 7b2c3267193382cc45f8d0fd7ca4127e19da7985 Mon Sep 17 00:00:00 2001 From: Arman Hosseini <44655055+Arman-Hosseini@users.noreply.github.com> Date: Wed, 24 Jul 2019 16:11:31 +0430 Subject: [PATCH 03/13] Ensure $request->hasSession() is always checked before calling getSession() --- src/Symfony/Bridge/Twig/AppVariable.php | 8 +++----- src/Symfony/Bridge/Twig/Tests/AppVariableTest.php | 2 ++ .../FrameworkBundle/Templating/GlobalVariables.php | 6 +++--- .../Controller/ProfilerController.php | 2 +- .../EventListener/WebDebugToolbarListener.php | 3 +-- .../EventListener/AbstractTestSessionListener.php | 3 +-- .../HttpKernel/EventListener/SaveSessionListener.php | 4 ++-- .../Http/Authentication/AuthenticationUtils.php | 7 ++----- .../Security/Http/Firewall/ContextListener.php | 12 ++++++------ 9 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index 21020270a0..a874e37c9b 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -112,10 +112,9 @@ class AppVariable if (null === $this->requestStack) { throw new \RuntimeException('The "app.session" variable is not available.'); } + $request = $this->getRequest(); - if ($request = $this->getRequest()) { - return $request->getSession(); - } + return $request && $request->hasSession() ? $request->getSession() : null; } /** @@ -157,8 +156,7 @@ class AppVariable public function getFlashes($types = null) { try { - $session = $this->getSession(); - if (null === $session) { + if (null === $session = $this->getSession()) { return []; } } catch (\RuntimeException $e) { diff --git a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php index 53b84b2d1b..b6699e5cdc 100644 --- a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php +++ b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php @@ -51,6 +51,7 @@ class AppVariableTest extends TestCase public function testGetSession() { $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request->method('hasSession')->willReturn(true); $request->method('getSession')->willReturn($session = new Session()); $this->setRequestStack($request); @@ -267,6 +268,7 @@ class AppVariableTest extends TestCase $session->method('getFlashBag')->willReturn($flashBag); $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request->method('hasSession')->willReturn(true); $request->method('getSession')->willReturn($session); $this->setRequestStack($request); diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php b/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php index 2981eb6642..5f30595635 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php @@ -75,9 +75,9 @@ class GlobalVariables */ public function getSession() { - if ($request = $this->getRequest()) { - return $request->getSession(); - } + $request = $this->getRequest(); + + return $request && $request->hasSession() ? $request->getSession() : null; } /** diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index c8a560295d..707f8040c3 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -123,7 +123,7 @@ class ProfilerController throw new NotFoundHttpException('The profiler must be enabled.'); } - if ($request->hasSession() && ($session = $request->getSession()) && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { + if ($request->hasSession() && ($session = $request->getSession())->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { // keep current flashes for one more request if using AutoExpireFlashBag $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); } diff --git a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php index 1541c7113b..fbcdb67826 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php +++ b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php @@ -88,8 +88,7 @@ class WebDebugToolbarListener implements EventSubscriberInterface } if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects && 'html' === $request->getRequestFormat()) { - $session = $request->getSession(); - if (null !== $session && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { + if ($request->hasSession() && ($session = $request->getSession())->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { // keep current flashes for one more request if using AutoExpireFlashBag $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); } diff --git a/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php index 054695e6f2..86f179add7 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/AbstractTestSessionListener.php @@ -46,8 +46,7 @@ abstract class AbstractTestSessionListener implements EventSubscriberInterface } // bootstrap the session - $session = $this->getSession(); - if (!$session) { + if (!$session = $this->getSession()) { return; } diff --git a/src/Symfony/Component/HttpKernel/EventListener/SaveSessionListener.php b/src/Symfony/Component/HttpKernel/EventListener/SaveSessionListener.php index b14153ad3c..3b105ced34 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/SaveSessionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/SaveSessionListener.php @@ -30,8 +30,8 @@ class SaveSessionListener implements EventSubscriberInterface return; } - $session = $event->getRequest()->getSession(); - if ($session && $session->isStarted()) { + $request = $event->getRequest(); + if ($request->hasSession() && ($session = $request->getSession())->isStarted()) { $session->save(); } } diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php index fbdc0bc5eb..af7e4919c3 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php @@ -38,12 +38,11 @@ class AuthenticationUtils public function getLastAuthenticationError($clearSession = true) { $request = $this->getRequest(); - $session = $request->getSession(); $authenticationException = null; if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) { $authenticationException = $request->attributes->get(Security::AUTHENTICATION_ERROR); - } elseif (null !== $session && $session->has(Security::AUTHENTICATION_ERROR)) { + } elseif ($request->hasSession() && ($session = $request->getSession())->has(Security::AUTHENTICATION_ERROR)) { $authenticationException = $session->get(Security::AUTHENTICATION_ERROR); if ($clearSession) { @@ -65,9 +64,7 @@ class AuthenticationUtils return $request->attributes->get(Security::LAST_USERNAME, ''); } - $session = $request->getSession(); - - return null === $session ? '' : $session->get(Security::LAST_USERNAME, ''); + return $request->hasSession() ? $request->getSession()->get(Security::LAST_USERNAME, '') : ''; } /** diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 16cdc8f9e2..e58b2e3f7d 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -90,7 +90,7 @@ class ContextListener implements ListenerInterface } $request = $event->getRequest(); - $session = $request->hasPreviousSession() ? $request->getSession() : null; + $session = $request->hasPreviousSession() && $request->hasSession() ? $request->getSession() : null; if (null === $session || null === $token = $session->get($this->sessionKey)) { $this->tokenStorage->setToken(null); @@ -137,14 +137,14 @@ class ContextListener implements ListenerInterface $this->dispatcher->removeListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']); $this->registered = false; - $session = $request->getSession(); + $token = $this->tokenStorage->getToken(); - if ((null === $token = $this->tokenStorage->getToken()) || $this->trustResolver->isAnonymous($token)) { - if ($request->hasPreviousSession()) { - $session->remove($this->sessionKey); + if (null === $token || $this->trustResolver->isAnonymous($token)) { + if ($request->hasPreviousSession() && $request->hasSession()) { + $request->getSession()->remove($this->sessionKey); } } else { - $session->set($this->sessionKey, serialize($token)); + $request->getSession()->set($this->sessionKey, serialize($token)); if (null !== $this->logger) { $this->logger->debug('Stored the security token in the session.', ['key' => $this->sessionKey]); From b80e9b8474ba8bef762aa5ff6a3b1a45fddff36a Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Mon, 29 Jul 2019 20:53:34 +0200 Subject: [PATCH 04/13] Make sure trace_level is always defined --- src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 051285aeba..b182dad212 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -98,8 +98,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface 'trace_header' => 'X-Symfony-Cache', ], $options); - if (!isset($options['trace_level']) && $this->options['debug']) { - $this->options['trace_level'] = 'full'; + if (!isset($options['trace_level'])) { + $this->options['trace_level'] = $this->options['debug'] ? 'full' : 'none'; } } From dd945e375c5c1e95e1dcbc8d423568ca595e019b Mon Sep 17 00:00:00 2001 From: Soufian EZ ZANTAR Date: Sat, 27 Jul 2019 00:20:27 +0200 Subject: [PATCH 05/13] fix(yml): fix comment in milti line value --- src/Symfony/Component/Yaml/Parser.php | 3 +++ src/Symfony/Component/Yaml/Tests/ParserTest.php | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index cc094085c6..4f5c30e168 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -436,6 +436,9 @@ class Parser $value = ''; foreach ($this->lines as $line) { + if ('' !== ltrim($line) && '#' === ltrim($line)[0]) { + continue; + } // If the indentation is not consistent at offset 0, it is to be considered as a ParseError if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) { throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 0f25732ab4..4b5073fb4e 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -2292,6 +2292,18 @@ YAML; return $tests; } + + public function testMultiLineComment() + { + $yaml = <<assertSame(['parameters' => 'abc'], $this->parser->parse($yaml)); + } } class B From a80e56c460aa70706ed8773c0422497c4f80edf7 Mon Sep 17 00:00:00 2001 From: Arjen van der Meijden Date: Tue, 30 Jul 2019 11:09:02 +0200 Subject: [PATCH 06/13] Don't add value of (default/static) objects to the signature --- .../Config/Resource/ReflectionClassResource.php | 2 +- .../Tests/Resource/ReflectionClassResourceTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php index f05042f8d3..d5e6b829cf 100644 --- a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php +++ b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php @@ -140,7 +140,7 @@ class ReflectionClassResource implements SelfCheckingResourceInterface, \Seriali foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) { yield $p->getDocComment().$p; - yield print_r(isset($defaults[$p->name]) ? $defaults[$p->name] : null, true); + yield print_r(isset($defaults[$p->name]) && !\is_object($defaults[$p->name]) ? $defaults[$p->name] : null, true); } } diff --git a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php index 1f0bcb17b4..76cad1433b 100644 --- a/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php @@ -170,6 +170,15 @@ EOPHP; $res = new ReflectionClassResource(new \ReflectionClass(TestServiceSubscriber::class)); $this->assertTrue($res->isFresh(0)); } + + public function testIgnoresObjectsInSignature() + { + $res = new ReflectionClassResource(new \ReflectionClass(TestServiceWithStaticProperty::class)); + $this->assertTrue($res->isFresh(0)); + + TestServiceWithStaticProperty::$initializedObject = new TestServiceWithStaticProperty(); + $this->assertTrue($res->isFresh(0)); + } } interface DummyInterface @@ -195,3 +204,8 @@ class TestServiceSubscriber implements ServiceSubscriberInterface return self::$subscribedServices; } } + +class TestServiceWithStaticProperty +{ + public static $initializedObject; +} From eaad40e5007bb440d9f2206b482c4d8bac41b25f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 29 Jul 2019 21:21:39 +0200 Subject: [PATCH 07/13] let BlockingStoreInterface extend PersistingStoreInterface --- src/Symfony/Component/Lock/BlockingStoreInterface.php | 2 +- src/Symfony/Component/Lock/Store/RetryTillSaveStore.php | 2 +- src/Symfony/Component/Lock/Tests/LockTest.php | 6 +++--- .../Component/Lock/Tests/Store/CombinedStoreTest.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Lock/BlockingStoreInterface.php b/src/Symfony/Component/Lock/BlockingStoreInterface.php index 162c9b3d41..15efaa2bdf 100644 --- a/src/Symfony/Component/Lock/BlockingStoreInterface.php +++ b/src/Symfony/Component/Lock/BlockingStoreInterface.php @@ -16,7 +16,7 @@ use Symfony\Component\Lock\Exception\LockConflictedException; /** * @author Hamza Amrouche */ -interface BlockingStoreInterface +interface BlockingStoreInterface extends PersistingStoreInterface { /** * Waits until a key becomes free, then stores the resource. diff --git a/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php b/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php index 81185f59eb..9a412810c2 100644 --- a/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php +++ b/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php @@ -26,7 +26,7 @@ use Symfony\Component\Lock\StoreInterface; * * @author Jérémy Derussé */ -class RetryTillSaveStore implements PersistingStoreInterface, BlockingStoreInterface, StoreInterface, LoggerAwareInterface +class RetryTillSaveStore implements BlockingStoreInterface, StoreInterface, LoggerAwareInterface { use LoggerAwareTrait; diff --git a/src/Symfony/Component/Lock/Tests/LockTest.php b/src/Symfony/Component/Lock/Tests/LockTest.php index 87331a64cf..1239ddba0f 100644 --- a/src/Symfony/Component/Lock/Tests/LockTest.php +++ b/src/Symfony/Component/Lock/Tests/LockTest.php @@ -97,7 +97,7 @@ class LockTest extends TestCase public function testAcquireBlocking() { $key = new Key(uniqid(__METHOD__, true)); - $store = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock(); + $store = $this->createMock(BlockingStoreInterface::class); $lock = new Lock($key, $store); $store @@ -213,7 +213,7 @@ class LockTest extends TestCase public function testReleaseOnDestruction() { $key = new Key(uniqid(__METHOD__, true)); - $store = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock(); + $store = $this->createMock(BlockingStoreInterface::class); $lock = new Lock($key, $store, 10); $store @@ -232,7 +232,7 @@ class LockTest extends TestCase public function testNoAutoReleaseWhenNotConfigured() { $key = new Key(uniqid(__METHOD__, true)); - $store = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock(); + $store = $this->createMock(BlockingStoreInterface::class); $lock = new Lock($key, $store, 10, false); $store diff --git a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php index 0f77d103d5..15ceb42bb5 100644 --- a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php @@ -62,8 +62,8 @@ class CombinedStoreTest extends AbstractStoreTest protected function setUp() { $this->strategy = $this->getMockBuilder(StrategyInterface::class)->getMock(); - $this->store1 = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock(); - $this->store2 = $this->getMockBuilder([PersistingStoreInterface::class, BlockingStoreInterface::class])->getMock(); + $this->store1 = $this->createMock(BlockingStoreInterface::class); + $this->store2 = $this->createMock(BlockingStoreInterface::class); $this->store = new CombinedStore([$this->store1, $this->store2], $this->strategy); } From 5f451e6f7074976aae60a65ba144fff684b7b48c Mon Sep 17 00:00:00 2001 From: Babichev Maxim Date: Tue, 30 Jul 2019 10:49:10 +0300 Subject: [PATCH 08/13] [Console] fix warning on PHP 7.4 --- src/Symfony/Component/Console/Input/ArrayInput.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Input/ArrayInput.php b/src/Symfony/Component/Console/Input/ArrayInput.php index 44c2f0d5c6..9f8f93a65e 100644 --- a/src/Symfony/Component/Console/Input/ArrayInput.php +++ b/src/Symfony/Component/Console/Input/ArrayInput.php @@ -132,7 +132,7 @@ class ArrayInput extends Input } if (0 === strpos($key, '--')) { $this->addLongOption(substr($key, 2), $value); - } elseif ('-' === $key[0]) { + } elseif (0 === strpos($key, '-')) { $this->addShortOption(substr($key, 1), $value); } else { $this->addArgument($key, $value); From 3324505b51ff85210a131fa7ec0d506e0489f6b9 Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Mon, 29 Jul 2019 13:33:17 +0200 Subject: [PATCH 09/13] [Cache] fix warning on PHP 7.4 --- src/Symfony/Component/Cache/Adapter/AbstractAdapter.php | 4 ++-- src/Symfony/Component/Cache/Adapter/ArrayAdapter.php | 2 +- src/Symfony/Component/Cache/Adapter/ChainAdapter.php | 2 +- src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php | 2 +- src/Symfony/Component/Cache/Adapter/ProxyAdapter.php | 2 +- src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php | 8 ++++---- src/Symfony/Component/Cache/Simple/Psr6Cache.php | 2 +- .../ExpressionLanguage/ParserCache/ParserCacheAdapter.php | 2 +- src/Symfony/Component/Routing/Loader/PhpFileLoader.php | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 0868c16d47..b543371159 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -49,7 +49,7 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, \strlen($namespace), $namespace)); } $this->createCacheItem = \Closure::bind( - function ($key, $value, $isHit) use ($defaultLifetime) { + static function ($key, $value, $isHit) use ($defaultLifetime) { $item = new CacheItem(); $item->key = $key; $item->value = $value; @@ -63,7 +63,7 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface ); $getId = function ($key) { return $this->getId((string) $key); }; $this->mergeByLifetime = \Closure::bind( - function ($deferred, $namespace, &$expiredIds) use ($getId) { + static function ($deferred, $namespace, &$expiredIds) use ($getId) { $byLifetime = []; $now = time(); $expiredIds = []; diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index 858a47e9ab..4c6695e267 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -34,7 +34,7 @@ class ArrayAdapter implements AdapterInterface, LoggerAwareInterface, Resettable { $this->storeSerialized = $storeSerialized; $this->createCacheItem = \Closure::bind( - function ($key, $value, $isHit) use ($defaultLifetime) { + static function ($key, $value, $isHit) use ($defaultLifetime) { $item = new CacheItem(); $item->key = $key; $item->value = $value; diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index 1f4d319e4f..0080db711b 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -56,7 +56,7 @@ class ChainAdapter implements AdapterInterface, PruneableInterface, ResettableIn $this->adapterCount = \count($this->adapters); $this->syncItem = \Closure::bind( - function ($sourceItem, $item) use ($defaultLifetime) { + static function ($sourceItem, $item) use ($defaultLifetime) { $item->value = $sourceItem->value; $item->expiry = $sourceItem->expiry; $item->isHit = $sourceItem->isHit; diff --git a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php index 42a4142099..59994ea4b6 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php @@ -42,7 +42,7 @@ class PhpArrayAdapter implements AdapterInterface, PruneableInterface, Resettabl $this->pool = $fallbackPool; $this->zendDetectUnicode = filter_var(ini_get('zend.detect_unicode'), FILTER_VALIDATE_BOOLEAN); $this->createCacheItem = \Closure::bind( - function ($key, $value, $isHit) { + static function ($key, $value, $isHit) { $item = new CacheItem(); $item->key = $key; $item->value = $value; diff --git a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php index 0b7918287e..009e92fb88 100644 --- a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php @@ -42,7 +42,7 @@ class ProxyAdapter implements AdapterInterface, PruneableInterface, ResettableIn $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace); $this->namespaceLen = \strlen($namespace); $this->createCacheItem = \Closure::bind( - function ($key, $innerItem) use ($defaultLifetime, $poolHash) { + static function ($key, $innerItem) use ($defaultLifetime, $poolHash) { $item = new CacheItem(); $item->key = $key; $item->defaultLifetime = $defaultLifetime; diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 362aceed0e..433d4eb132 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -42,7 +42,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R $this->tags = $tagsPool ?: $itemsPool; $this->knownTagVersionsTtl = $knownTagVersionsTtl; $this->createCacheItem = \Closure::bind( - function ($key, $value, CacheItem $protoItem) { + static function ($key, $value, CacheItem $protoItem) { $item = new CacheItem(); $item->key = $key; $item->value = $value; @@ -56,7 +56,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R CacheItem::class ); $this->setCacheItemTags = \Closure::bind( - function (CacheItem $item, $key, array &$itemTags) { + static function (CacheItem $item, $key, array &$itemTags) { if (!$item->isHit) { return $item; } @@ -76,7 +76,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R CacheItem::class ); $this->getTagsByKey = \Closure::bind( - function ($deferred) { + static function ($deferred) { $tagsByKey = []; foreach ($deferred as $key => $item) { $tagsByKey[$key] = $item->tags; @@ -88,7 +88,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, PruneableInterface, R CacheItem::class ); $this->invalidateTags = \Closure::bind( - function (AdapterInterface $tagsAdapter, array $tags) { + static function (AdapterInterface $tagsAdapter, array $tags) { foreach ($tags as $v) { $v->defaultLifetime = 0; $v->expiry = null; diff --git a/src/Symfony/Component/Cache/Simple/Psr6Cache.php b/src/Symfony/Component/Cache/Simple/Psr6Cache.php index 85d75becbe..aab41f722d 100644 --- a/src/Symfony/Component/Cache/Simple/Psr6Cache.php +++ b/src/Symfony/Component/Cache/Simple/Psr6Cache.php @@ -41,7 +41,7 @@ class Psr6Cache implements CacheInterface, PruneableInterface, ResettableInterfa } $cacheItemPrototype = &$this->cacheItemPrototype; $createCacheItem = \Closure::bind( - function ($key, $value, $allowInt = false) use (&$cacheItemPrototype) { + static function ($key, $value, $allowInt = false) use (&$cacheItemPrototype) { $item = clone $cacheItemPrototype; $item->key = $allowInt && \is_int($key) ? (string) $key : CacheItem::validateKey($key); $item->value = $value; diff --git a/src/Symfony/Component/ExpressionLanguage/ParserCache/ParserCacheAdapter.php b/src/Symfony/Component/ExpressionLanguage/ParserCache/ParserCacheAdapter.php index 30d9f8425b..38ce6590b9 100644 --- a/src/Symfony/Component/ExpressionLanguage/ParserCache/ParserCacheAdapter.php +++ b/src/Symfony/Component/ExpressionLanguage/ParserCache/ParserCacheAdapter.php @@ -30,7 +30,7 @@ class ParserCacheAdapter implements CacheItemPoolInterface $this->pool = $pool; $this->createCacheItem = \Closure::bind( - function ($key, $value, $isHit) { + static function ($key, $value, $isHit) { $item = new CacheItem(); $item->key = $key; $item->value = $value; diff --git a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php index d81e7e82e7..d9ba59d51e 100644 --- a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php @@ -40,7 +40,7 @@ class PhpFileLoader extends FileLoader // the closure forbids access to the private scope in the included file $loader = $this; - $load = \Closure::bind(function ($file) use ($loader) { + $load = \Closure::bind(static function ($file) use ($loader) { return include $file; }, null, ProtectedPhpFileLoader::class); From 54107bac33afe156424c2280187fdd663a1b8b70 Mon Sep 17 00:00:00 2001 From: Benny Born Date: Sun, 28 Jul 2019 12:33:26 +0200 Subject: [PATCH 10/13] [HttpFoundation] Fix `getMaxFilesize` --- .../HttpFoundation/File/UploadedFile.php | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index a44c664b4c..093aaf8326 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -214,13 +214,26 @@ class UploadedFile extends File */ public static function getMaxFilesize() { - $iniMax = strtolower(ini_get('upload_max_filesize')); + $sizePostMax = self::parseFilesize(ini_get('post_max_size')); + $sizeUploadMax = self::parseFilesize(ini_get('upload_max_filesize')); - if ('' === $iniMax) { - return PHP_INT_MAX; + return min([$sizePostMax, $sizeUploadMax]); + } + + /** + * Returns the given size from an ini value in bytes. + * + * @return int The given size in bytes + */ + private static function parseFilesize($size) + { + if ('' === $size) { + return 0; } - $max = ltrim($iniMax, '+'); + $size = strtolower($size); + + $max = ltrim($size, '+'); if (0 === strpos($max, '0x')) { $max = \intval($max, 16); } elseif (0 === strpos($max, '0')) { @@ -229,7 +242,7 @@ class UploadedFile extends File $max = (int) $max; } - switch (substr($iniMax, -1)) { + switch (substr($size, -1)) { case 't': $max *= 1024; // no break case 'g': $max *= 1024; From 8b2d67bb3dd16586e8f75a3cba800f379cbe2e00 Mon Sep 17 00:00:00 2001 From: Tobias Weichart Date: Wed, 31 Jul 2019 08:13:25 +0100 Subject: [PATCH 11/13] minor fix for wrong case --- src/Symfony/Component/Debug/Exception/SilencedErrorContext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Debug/Exception/SilencedErrorContext.php b/src/Symfony/Component/Debug/Exception/SilencedErrorContext.php index f862b74f45..2bacfd5c9b 100644 --- a/src/Symfony/Component/Debug/Exception/SilencedErrorContext.php +++ b/src/Symfony/Component/Debug/Exception/SilencedErrorContext.php @@ -54,7 +54,7 @@ class SilencedErrorContext implements \JsonSerializable return $this->trace; } - public function JsonSerialize() + public function jsonSerialize() { return [ 'severity' => $this->severity, From 05cfc2b6ba8c2c29fe2ad13c6f007b30b9c55f25 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 31 Jul 2019 14:25:32 +0200 Subject: [PATCH 12/13] [Contracts] Fix branch alias --- src/Symfony/Contracts/Cache/composer.json | 2 +- src/Symfony/Contracts/EventDispatcher/composer.json | 2 +- src/Symfony/Contracts/HttpClient/composer.json | 2 +- src/Symfony/Contracts/Service/composer.json | 2 +- src/Symfony/Contracts/Translation/composer.json | 2 +- src/Symfony/Contracts/composer.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Contracts/Cache/composer.json b/src/Symfony/Contracts/Cache/composer.json index e30b0bca8f..4e0bd1a422 100644 --- a/src/Symfony/Contracts/Cache/composer.json +++ b/src/Symfony/Contracts/Cache/composer.json @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.1-dev" } } } diff --git a/src/Symfony/Contracts/EventDispatcher/composer.json b/src/Symfony/Contracts/EventDispatcher/composer.json index 8251d90a0c..55802a491d 100644 --- a/src/Symfony/Contracts/EventDispatcher/composer.json +++ b/src/Symfony/Contracts/EventDispatcher/composer.json @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.1-dev" } } } diff --git a/src/Symfony/Contracts/HttpClient/composer.json b/src/Symfony/Contracts/HttpClient/composer.json index 718852d5c0..4dc9b2d38c 100644 --- a/src/Symfony/Contracts/HttpClient/composer.json +++ b/src/Symfony/Contracts/HttpClient/composer.json @@ -27,7 +27,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.1-dev" } } } diff --git a/src/Symfony/Contracts/Service/composer.json b/src/Symfony/Contracts/Service/composer.json index d8738fa213..f4209cc41c 100644 --- a/src/Symfony/Contracts/Service/composer.json +++ b/src/Symfony/Contracts/Service/composer.json @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.1-dev" } } } diff --git a/src/Symfony/Contracts/Translation/composer.json b/src/Symfony/Contracts/Translation/composer.json index 22ef38363e..09749d35f5 100644 --- a/src/Symfony/Contracts/Translation/composer.json +++ b/src/Symfony/Contracts/Translation/composer.json @@ -27,7 +27,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.1-dev" } } } diff --git a/src/Symfony/Contracts/composer.json b/src/Symfony/Contracts/composer.json index a3fa4afd98..b9277e1dd1 100644 --- a/src/Symfony/Contracts/composer.json +++ b/src/Symfony/Contracts/composer.json @@ -47,7 +47,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.1-dev" } } } From dfce45bf2e347bca3a8066fa034855314a81f31e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 31 Jul 2019 14:40:56 +0200 Subject: [PATCH 13/13] Fix travis script --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 12d031f64b..26f2ef810d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -199,7 +199,7 @@ install: export SYMFONY_DEPRECATIONS_HELPER=weak && cp composer.json composer.json.orig && echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json && - php .github/build-packages.php HEAD^ $COMPONENTS && + php .github/build-packages.php HEAD^ $(find src/Symfony -mindepth 3 -type f -name composer.json -printf '%h\n') && mv composer.json composer.json.phpunit && mv composer.json.orig composer.json fi