|
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 | *
|
@@ -452,47 +449,20 @@ protected function initializeContainer()
|
452 | 449 | try {
|
453 | 450 | is_dir($cacheDir) ?: mkdir($cacheDir, 0777, true);
|
454 | 451 |
|
455 |
| - if ($lock = fopen($cachePath, 'w')) { |
456 |
| - chmod($cachePath, 0666 & ~umask()); |
| 452 | + if ($lock = fopen($cachePath.'.lock', 'w')) { |
457 | 453 | flock($lock, LOCK_EX | LOCK_NB, $wouldBlock);
|
458 | 454 |
|
459 | 455 | if (!flock($lock, $wouldBlock ? LOCK_SH : LOCK_EX)) {
|
460 | 456 | fclose($lock);
|
461 |
| - } else { |
462 |
| - $cache = new class($cachePath, $this->debug) extends ConfigCache { |
463 |
| - public $lock; |
464 |
| - |
465 |
| - public function write(string $content, array $metadata = null) |
466 |
| - { |
467 |
| - rewind($this->lock); |
468 |
| - ftruncate($this->lock, 0); |
469 |
| - fwrite($this->lock, $content); |
470 |
| - |
471 |
| - if (null !== $metadata) { |
472 |
| - file_put_contents($this->getPath().'.meta', serialize($metadata)); |
473 |
| - @chmod($this->getPath().'.meta', 0666 & ~umask()); |
474 |
| - } |
475 |
| - |
476 |
| - if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) { |
477 |
| - @opcache_invalidate($this->getPath(), true); |
478 |
| - } |
479 |
| - } |
480 |
| - |
481 |
| - public function release() |
482 |
| - { |
483 |
| - flock($this->lock, LOCK_UN); |
484 |
| - fclose($this->lock); |
485 |
| - } |
486 |
| - }; |
487 |
| - $cache->lock = $lock; |
488 |
| - |
489 |
| - if (!\is_object($this->container = include $cachePath)) { |
490 |
| - $this->container = null; |
491 |
| - } elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) { |
492 |
| - $this->container->set('kernel', $this); |
493 |
| - |
494 |
| - return; |
495 |
| - } |
| 457 | + $lock = null; |
| 458 | + } elseif (!\is_object($this->container = include $cachePath)) { |
| 459 | + $this->container = null; |
| 460 | + } elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) { |
| 461 | + flock($lock, LOCK_UN); |
| 462 | + fclose($lock); |
| 463 | + $this->container->set('kernel', $this); |
| 464 | + |
| 465 | + return; |
496 | 466 | }
|
497 | 467 | }
|
498 | 468 | } catch (\Throwable $e) {
|
@@ -556,8 +526,10 @@ public function release()
|
556 | 526 | }
|
557 | 527 |
|
558 | 528 | $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
|
559 |
| - if (method_exists($cache, 'release')) { |
560 |
| - $cache->release(); |
| 529 | + |
| 530 | + if ($lock) { |
| 531 | + flock($lock, LOCK_UN); |
| 532 | + fclose($lock); |
561 | 533 | }
|
562 | 534 |
|
563 | 535 | $this->container = require $cachePath;
|
|
0 commit comments