From 449c3f7a9b8c47d178f80610afa6e2873ac0a3c0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 29 Feb 2020 11:16:41 +0100 Subject: [PATCH 01/11] updated VERSION for 3.4.38 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 82930d8c27..1c85a2b08f 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.38-DEV'; + const VERSION = '3.4.38'; const VERSION_ID = 30438; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; const RELEASE_VERSION = 38; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From ec8ae13f7fc4b7bccb5dc9788888c9df5c8987ac Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 29 Feb 2020 11:30:13 +0100 Subject: [PATCH 02/11] bumped Symfony version to 3.4.39 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 1c85a2b08f..4ef763e486 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.38'; - const VERSION_ID = 30438; + const VERSION = '3.4.39-DEV'; + const VERSION_ID = 30439; const MAJOR_VERSION = 3; const MINOR_VERSION = 4; - const RELEASE_VERSION = 38; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 39; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2020'; const END_OF_LIFE = '11/2021'; From 43fbae22dbc48de3354ae3014465bbc8d6cb3b10 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 29 Feb 2020 11:35:30 +0100 Subject: [PATCH 03/11] bumped Symfony version to 4.4.6 --- Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel.php b/Kernel.php index 0b21ee8996..281c161b38 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.5'; - const VERSION_ID = 40405; + const VERSION = '4.4.6-DEV'; + const VERSION_ID = 40406; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; - const RELEASE_VERSION = 5; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 6; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023'; From 2f04b78a562590794d6081104218ff7b468e5d7a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 15 Mar 2020 10:01:00 +0100 Subject: [PATCH 04/11] Add missing dots at the end of exception messages --- Controller/ControllerResolver.php | 2 +- DataCollector/DumpDataCollector.php | 2 +- Fragment/HIncludeFragmentRenderer.php | 2 +- Kernel.php | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 619628b5c7..4e11ac640b 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. %s.', $request->getPathInfo(), $e->getMessage()), 0, $e); } return $callable; diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 4266b22fec..7c32ec1001 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -217,7 +217,7 @@ public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1) $dumper = new HtmlDumper($data, $this->charset); $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { - throw new \InvalidArgumentException(sprintf('Invalid dump format: %s', $format)); + throw new \InvalidArgumentException(sprintf('Invalid dump format: %s.', $format)); } $dumps = []; diff --git a/Fragment/HIncludeFragmentRenderer.php b/Fragment/HIncludeFragmentRenderer.php index f94a5c0760..4850e589da 100644 --- a/Fragment/HIncludeFragmentRenderer.php +++ b/Fragment/HIncludeFragmentRenderer.php @@ -57,7 +57,7 @@ public function __construct($templating = null, UriSigner $signer = null, $globa public function setTemplating($templating) { if (null !== $templating && !$templating instanceof EngineInterface && !$templating instanceof Environment) { - throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of Twig\Environment or Symfony\Component\Templating\EngineInterface'); + throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of Twig\Environment or Symfony\Component\Templating\EngineInterface.'); } $this->templating = $templating; diff --git a/Kernel.php b/Kernel.php index 4ef763e486..a73788e1ec 100644 --- a/Kernel.php +++ b/Kernel.php @@ -493,7 +493,7 @@ protected function initializeBundles() foreach ($this->registerBundles() as $bundle) { $name = $bundle->getName(); if (isset($this->bundles[$name])) { - throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s"', $name)); + throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s".', $name)); } $this->bundles[$name] = $bundle; @@ -762,10 +762,10 @@ protected function buildContainer() foreach (['cache' => $this->warmupDir ?: $this->getCacheDir(), 'logs' => $this->getLogDir()] as $name => $dir) { if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, $dir)); + throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n.", $name, $dir)); } } elseif (!is_writable($dir)) { - throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir)); + throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n.", $name, $dir)); } } From 8e6b70bec54216981afb3354990be8a37d0a0ba2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 15 Mar 2020 11:08:38 +0100 Subject: [PATCH 05/11] Add missing dots at the end of exception messages --- Controller/ContainerControllerResolver.php | 2 +- Controller/ControllerResolver.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Controller/ContainerControllerResolver.php b/Controller/ContainerControllerResolver.php index 015eea91fa..7eb028de1f 100644 --- a/Controller/ContainerControllerResolver.php +++ b/Controller/ContainerControllerResolver.php @@ -64,7 +64,7 @@ protected function instantiateController($class) throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?', $class), 0, $e); } - throw new \InvalidArgumentException(sprintf('Controller "%s" does neither exist as service nor as class', $class), 0, $e); + throw new \InvalidArgumentException(sprintf('Controller "%s" does neither exist as service nor as class.', $class), 0, $e); } private function throwExceptionIfControllerWasRemoved(string $controller, \Throwable $previous) diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index fd9a0accaf..feb69e54ac 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. %s.', $request->getPathInfo(), $this->getControllerError($controller))); } 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. %s.', $request->getPathInfo(), $this->getControllerError($controller))); } 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. %s.', $request->getPathInfo(), $this->getControllerError($callable))); } return $callable; From d5b3a4b1d9a522dcd6ccca778dfe2cbf832e7de7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Mar 2020 08:32:23 +0100 Subject: [PATCH 06/11] Fix quotes in exception messages --- Bundle/Bundle.php | 2 +- CacheClearer/Psr6CacheClearer.php | 2 +- ControllerMetadata/ArgumentMetadata.php | 2 +- DataCollector/DumpDataCollector.php | 2 +- DependencyInjection/ResettableServicePass.php | 2 +- Fragment/FragmentHandler.php | 2 +- HttpCache/AbstractSurrogate.php | 2 +- Kernel.php | 6 +++--- Tests/CacheClearer/Psr6CacheClearerTest.php | 2 +- Tests/DependencyInjection/ResettableServicePassTest.php | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Bundle/Bundle.php b/Bundle/Bundle.php index 5bbed6bef1..530a2749d1 100644 --- a/Bundle/Bundle.php +++ b/Bundle/Bundle.php @@ -70,7 +70,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_class($extension))); } // check naming convention diff --git a/CacheClearer/Psr6CacheClearer.php b/CacheClearer/Psr6CacheClearer.php index 42add5a686..4b4aafa163 100644 --- a/CacheClearer/Psr6CacheClearer.php +++ b/CacheClearer/Psr6CacheClearer.php @@ -40,7 +40,7 @@ public function hasPool($name) public function clearPool($name) { if (!isset($this->pools[$name])) { - throw new \InvalidArgumentException(sprintf('Cache pool not found: %s.', $name)); + throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name)); } return $this->pools[$name]->clear(); diff --git a/ControllerMetadata/ArgumentMetadata.php b/ControllerMetadata/ArgumentMetadata.php index 520e83b5fe..6df388d83a 100644 --- a/ControllerMetadata/ArgumentMetadata.php +++ b/ControllerMetadata/ArgumentMetadata.php @@ -107,7 +107,7 @@ public function isNullable() public function getDefaultValue() { if (!$this->hasDefaultValue) { - throw new \LogicException(sprintf('Argument $%s does not have a default value. Use %s::hasDefaultValue() to avoid this exception.', $this->name, __CLASS__)); + throw new \LogicException(sprintf('Argument $%s does not have a default value. Use "%s::hasDefaultValue()" to avoid this exception.', $this->name, __CLASS__)); } return $this->defaultValue; diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index 7c32ec1001..280e1ddd08 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -217,7 +217,7 @@ public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1) $dumper = new HtmlDumper($data, $this->charset); $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { - throw new \InvalidArgumentException(sprintf('Invalid dump format: %s.', $format)); + throw new \InvalidArgumentException(sprintf('Invalid dump format: "%s".', $format)); } $dumps = []; diff --git a/DependencyInjection/ResettableServicePass.php b/DependencyInjection/ResettableServicePass.php index 28136be625..51a518dc28 100644 --- a/DependencyInjection/ResettableServicePass.php +++ b/DependencyInjection/ResettableServicePass.php @@ -46,7 +46,7 @@ public function process(ContainerBuilder $container) $attributes = $tags[0]; if (!isset($attributes['method'])) { - throw new RuntimeException(sprintf('Tag %s requires the "method" attribute to be set.', $this->tagName)); + throw new RuntimeException(sprintf('Tag "%s" requires the "method" attribute to be set.', $this->tagName)); } $methods[$id] = $attributes['method']; diff --git a/Fragment/FragmentHandler.php b/Fragment/FragmentHandler.php index 9629cf7066..b98b1779ad 100644 --- a/Fragment/FragmentHandler.php +++ b/Fragment/FragmentHandler.php @@ -100,7 +100,7 @@ public function render($uri, $renderer = 'inline', array $options = []) protected function deliver(Response $response) { if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->requestStack->getCurrentRequest()->getUri(), $response->getStatusCode())); + throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $this->requestStack->getCurrentRequest()->getUri(), $response->getStatusCode())); } if (!$response instanceof StreamedResponse) { diff --git a/HttpCache/AbstractSurrogate.php b/HttpCache/AbstractSurrogate.php index 9b4541793f..472d87e483 100644 --- a/HttpCache/AbstractSurrogate.php +++ b/HttpCache/AbstractSurrogate.php @@ -96,7 +96,7 @@ public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors) $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true); if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $subRequest->getUri(), $response->getStatusCode())); + throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $subRequest->getUri(), $response->getStatusCode())); } return $response->getContent(); diff --git a/Kernel.php b/Kernel.php index a73788e1ec..9d1d42eb19 100644 --- a/Kernel.php +++ b/Kernel.php @@ -236,7 +236,7 @@ public function getBundle($name, $first = true/*, $noDeprecation = false */) } if (!isset($this->bundleMap[$name])) { - 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, static::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, static::class)); } if (true === $first) { @@ -762,10 +762,10 @@ protected function buildContainer() foreach (['cache' => $this->warmupDir ?: $this->getCacheDir(), 'logs' => $this->getLogDir()] as $name => $dir) { if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n.", $name, $dir)); + throw new \RuntimeException(sprintf('Unable to create the "%s" directory (%s).', $name, $dir)); } } elseif (!is_writable($dir)) { - throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n.", $name, $dir)); + throw new \RuntimeException(sprintf('Unable to write in the "%s" directory (%s).', $name, $dir)); } } diff --git a/Tests/CacheClearer/Psr6CacheClearerTest.php b/Tests/CacheClearer/Psr6CacheClearerTest.php index 2fbce41d1c..4d46c91762 100644 --- a/Tests/CacheClearer/Psr6CacheClearerTest.php +++ b/Tests/CacheClearer/Psr6CacheClearerTest.php @@ -40,7 +40,7 @@ public function testClearPool() public function testClearPoolThrowsExceptionOnUnreferencedPool() { $this->expectException('InvalidArgumentException'); - $this->expectExceptionMessage('Cache pool not found: unknown'); + $this->expectExceptionMessage('Cache pool not found: "unknown"'); (new Psr6CacheClearer())->clearPool('unknown'); } diff --git a/Tests/DependencyInjection/ResettableServicePassTest.php b/Tests/DependencyInjection/ResettableServicePassTest.php index d3c6869320..7ebe5dfb91 100644 --- a/Tests/DependencyInjection/ResettableServicePassTest.php +++ b/Tests/DependencyInjection/ResettableServicePassTest.php @@ -51,7 +51,7 @@ public function testCompilerPass() public function testMissingMethod() { $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); - $this->expectExceptionMessage('Tag kernel.reset requires the "method" attribute to be set.'); + $this->expectExceptionMessage('Tag "kernel.reset" requires the "method" attribute to be set.'); $container = new ContainerBuilder(); $container->register(ResettableService::class) ->addTag('kernel.reset'); From eb80a94ddeb61d3409e29010910348c038d2da63 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Mar 2020 11:25:47 +0100 Subject: [PATCH 07/11] Fix quotes in exception messages --- CacheClearer/Psr6CacheClearer.php | 2 +- EventListener/TranslatorListener.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CacheClearer/Psr6CacheClearer.php b/CacheClearer/Psr6CacheClearer.php index f69740440e..f5670f1b97 100644 --- a/CacheClearer/Psr6CacheClearer.php +++ b/CacheClearer/Psr6CacheClearer.php @@ -31,7 +31,7 @@ public function hasPool($name) public function getPool($name) { if (!$this->hasPool($name)) { - throw new \InvalidArgumentException(sprintf('Cache pool not found: %s.', $name)); + throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name)); } return $this->pools[$name]; diff --git a/EventListener/TranslatorListener.php b/EventListener/TranslatorListener.php index d28eee2b1a..e276b3bd71 100644 --- a/EventListener/TranslatorListener.php +++ b/EventListener/TranslatorListener.php @@ -40,7 +40,7 @@ class TranslatorListener implements EventSubscriberInterface public function __construct($translator, RequestStack $requestStack) { if (!$translator instanceof TranslatorInterface && !$translator instanceof LocaleAwareInterface) { - throw new \TypeError(sprintf('Argument 1 passed to %s() must be an instance of %s, %s given.', __METHOD__, LocaleAwareInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be an instance of "%s", "%s" given.', __METHOD__, LocaleAwareInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator))); } $this->translator = $translator; $this->requestStack = $requestStack; From 855cb1e24b77fd91dce760e3c981a6881c170f7d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Mar 2020 16:39:23 +0100 Subject: [PATCH 08/11] Fix more quotes in exception messages --- Controller/ArgumentResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/ArgumentResolver.php b/Controller/ArgumentResolver.php index fc6f969a9e..9d5f96ed2c 100644 --- a/Controller/ArgumentResolver.php +++ b/Controller/ArgumentResolver.php @@ -56,7 +56,7 @@ public function getArguments(Request $request, $controller) $resolved = $resolver->resolve($request, $metadata); if (!$resolved instanceof \Generator) { - 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_class($resolver))); } foreach ($resolved as $append) { From b3524e3e91d84dbcd011686386ffe4ba76461472 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 24 Sep 2019 13:01:54 +0200 Subject: [PATCH 09/11] [DI] fix preloading script generation --- HttpClientKernel.php | 3 +++ HttpKernel.php | 12 ++++++++++++ Kernel.php | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/HttpClientKernel.php b/HttpClientKernel.php index c8421a4b10..912ce313f8 100644 --- a/HttpClientKernel.php +++ b/HttpClientKernel.php @@ -21,6 +21,9 @@ use Symfony\Component\Mime\Part\TextPart; use Symfony\Contracts\HttpClient\HttpClientInterface; +// Help opcache.preload discover always-needed symbols +class_exists(ResponseHeaderBag::class); + /** * An implementation of a Symfony HTTP kernel using a "real" HTTP client. * diff --git a/HttpKernel.php b/HttpKernel.php index f1b601361e..681e96321d 100644 --- a/HttpKernel.php +++ b/HttpKernel.php @@ -33,6 +33,18 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +// Help opcache.preload discover always-needed symbols +class_exists(LegacyEventDispatcherProxy::class); +class_exists(ControllerArgumentsEvent::class); +class_exists(ControllerEvent::class); +class_exists(ExceptionEvent::class); +class_exists(FinishRequestEvent::class); +class_exists(RequestEvent::class); +class_exists(ResponseEvent::class); +class_exists(TerminateEvent::class); +class_exists(ViewEvent::class); +class_exists(KernelEvents::class); + /** * HttpKernel notifies events to convert a Request object to a Response one. * diff --git a/Kernel.php b/Kernel.php index 6c8f019c6e..d6f5a462d6 100644 --- a/Kernel.php +++ b/Kernel.php @@ -38,6 +38,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. * @@ -805,6 +808,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container 'as_files' => true, 'debug' => $this->debug, 'build_time' => $container->hasParameter('kernel.container_build_time') ? $container->getParameter('kernel.container_build_time') : time(), + 'preload_classes' => array_map('get_class', $this->bundles), ]); $rootCode = array_pop($content); From 36c121cd45c1de6c3479ecb80e0534f366e1fe54 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 22 Mar 2020 21:08:25 +0100 Subject: [PATCH 10/11] [HttpKernel] fix locking for PHP 7.4+ --- Kernel.php | 56 ++++++++++++++---------------------------------------- 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/Kernel.php b/Kernel.php index d6f5a462d6..958e049bf0 100644 --- a/Kernel.php +++ b/Kernel.php @@ -38,9 +38,6 @@ 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. * @@ -533,47 +530,20 @@ protected function initializeContainer() try { is_dir($cacheDir) ?: mkdir($cacheDir, 0777, true); - if ($lock = fopen($cachePath, 'w')) { - chmod($cachePath, 0666 & ~umask()); + if ($lock = fopen($cachePath.'.lock', 'w')) { flock($lock, LOCK_EX | LOCK_NB, $wouldBlock); if (!flock($lock, $wouldBlock ? LOCK_SH : LOCK_EX)) { fclose($lock); - } else { - $cache = new class($cachePath, $this->debug) extends ConfigCache { - public $lock; - - public function write($content, array $metadata = null) - { - rewind($this->lock); - ftruncate($this->lock, 0); - fwrite($this->lock, $content); - - if (null !== $metadata) { - file_put_contents($this->getPath().'.meta', serialize($metadata)); - @chmod($this->getPath().'.meta', 0666 & ~umask()); - } - - if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) { - @opcache_invalidate($this->getPath(), true); - } - } - - public function release() - { - flock($this->lock, LOCK_UN); - fclose($this->lock); - } - }; - $cache->lock = $lock; - - if (!\is_object($this->container = include $cachePath)) { - $this->container = null; - } elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) { - $this->container->set('kernel', $this); - - return; - } + $lock = null; + } elseif (!\is_object($this->container = include $cachePath)) { + $this->container = null; + } elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) { + flock($lock, LOCK_UN); + fclose($lock); + $this->container->set('kernel', $this); + + return; } } } catch (\Throwable $e) { @@ -637,8 +607,10 @@ public function release() } $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass()); - if (method_exists($cache, 'release')) { - $cache->release(); + + if ($lock) { + flock($lock, LOCK_UN); + fclose($lock); } $this->container = require $cachePath; From 02ee1d0d616b031fb48a1c9c3e5dc092dd7e448d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 27 Mar 2020 09:32:28 +0100 Subject: [PATCH 11/11] Update VERSION for 4.4.6 --- Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel.php b/Kernel.php index 958e049bf0..a559f07288 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.6-DEV'; + const VERSION = '4.4.6'; const VERSION_ID = 40406; const MAJOR_VERSION = 4; const MINOR_VERSION = 4; const RELEASE_VERSION = 6; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '11/2022'; const END_OF_LIFE = '11/2023';