Skip to content

Commit c9a91e8

Browse files
Merge branch '4.4' into 5.0
* 4.4: [Http Foundation] Fix clear cookie samesite [Security] Check if firewall is stateless before checking for session/previous session [Form] Support customized intl php.ini settings [Security] Remember me: allow to set the samesite cookie flag [Debug] fix for PHP 7.3.16+/7.4.4+ [Validator] Backport translations [Mailer] Use %d instead of %s for error code in error messages [HttpKernel] fix locking for PHP 7.4+ [Security] Fixed hardcoded value of SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE Prevent warning in proc_open() [FrameworkBundle] Fix Router Cache Fix deprecation messages
2 parents ea9d281 + 36c121c commit c9a91e8

File tree

1 file changed

+14
-42
lines changed

1 file changed

+14
-42
lines changed

Kernel.php

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass;
3939
use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
4040

41-
// Help opcache.preload discover always-needed symbols
42-
class_exists(ConfigCache::class);
43-
4441
/**
4542
* The Kernel is the heart of the Symfony system.
4643
*
@@ -452,47 +449,20 @@ protected function initializeContainer()
452449
try {
453450
is_dir($cacheDir) ?: mkdir($cacheDir, 0777, true);
454451

455-
if ($lock = fopen($cachePath, 'w')) {
456-
chmod($cachePath, 0666 & ~umask());
452+
if ($lock = fopen($cachePath.'.lock', 'w')) {
457453
flock($lock, LOCK_EX | LOCK_NB, $wouldBlock);
458454

459455
if (!flock($lock, $wouldBlock ? LOCK_SH : LOCK_EX)) {
460456
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;
496466
}
497467
}
498468
} catch (\Throwable $e) {
@@ -556,8 +526,10 @@ public function release()
556526
}
557527

558528
$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);
561533
}
562534

563535
$this->container = require $cachePath;

0 commit comments

Comments
 (0)