|
38 | 38 | use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass;
|
39 | 39 | use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
|
40 | 40 |
|
41 |
| -// Help opcache.preload discover always-needed symbols |
42 |
| -class_exists(ConfigCache::class); |
43 |
| - |
44 | 41 | /**
|
45 | 42 | * The Kernel is the heart of the Symfony system.
|
46 | 43 | *
|
@@ -533,47 +530,20 @@ protected function initializeContainer()
|
533 | 530 | try {
|
534 | 531 | is_dir($cacheDir) ?: mkdir($cacheDir, 0777, true);
|
535 | 532 |
|
536 |
| - if ($lock = fopen($cachePath, 'w')) { |
537 |
| - chmod($cachePath, 0666 & ~umask()); |
| 533 | + if ($lock = fopen($cachePath.'.lock', 'w')) { |
538 | 534 | flock($lock, LOCK_EX | LOCK_NB, $wouldBlock);
|
539 | 535 |
|
540 | 536 | if (!flock($lock, $wouldBlock ? LOCK_SH : LOCK_EX)) {
|
541 | 537 | fclose($lock);
|
542 |
| - } else { |
543 |
| - $cache = new class($cachePath, $this->debug) extends ConfigCache { |
544 |
| - public $lock; |
545 |
| - |
546 |
| - public function write($content, array $metadata = null) |
547 |
| - { |
548 |
| - rewind($this->lock); |
549 |
| - ftruncate($this->lock, 0); |
550 |
| - fwrite($this->lock, $content); |
551 |
| - |
552 |
| - if (null !== $metadata) { |
553 |
| - file_put_contents($this->getPath().'.meta', serialize($metadata)); |
554 |
| - @chmod($this->getPath().'.meta', 0666 & ~umask()); |
555 |
| - } |
556 |
| - |
557 |
| - if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) { |
558 |
| - @opcache_invalidate($this->getPath(), true); |
559 |
| - } |
560 |
| - } |
561 |
| - |
562 |
| - public function release() |
563 |
| - { |
564 |
| - flock($this->lock, LOCK_UN); |
565 |
| - fclose($this->lock); |
566 |
| - } |
567 |
| - }; |
568 |
| - $cache->lock = $lock; |
569 |
| - |
570 |
| - if (!\is_object($this->container = include $cachePath)) { |
571 |
| - $this->container = null; |
572 |
| - } elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) { |
573 |
| - $this->container->set('kernel', $this); |
574 |
| - |
575 |
| - return; |
576 |
| - } |
| 538 | + $lock = null; |
| 539 | + } elseif (!\is_object($this->container = include $cachePath)) { |
| 540 | + $this->container = null; |
| 541 | + } elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) { |
| 542 | + flock($lock, LOCK_UN); |
| 543 | + fclose($lock); |
| 544 | + $this->container->set('kernel', $this); |
| 545 | + |
| 546 | + return; |
577 | 547 | }
|
578 | 548 | }
|
579 | 549 | } catch (\Throwable $e) {
|
@@ -637,8 +607,10 @@ public function release()
|
637 | 607 | }
|
638 | 608 |
|
639 | 609 | $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
|
640 |
| - if (method_exists($cache, 'release')) { |
641 |
| - $cache->release(); |
| 610 | + |
| 611 | + if ($lock) { |
| 612 | + flock($lock, LOCK_UN); |
| 613 | + fclose($lock); |
642 | 614 | }
|
643 | 615 |
|
644 | 616 | $this->container = require $cachePath;
|
|
0 commit comments