diff --git a/src/Symfony/Component/Cache/LockRegistry.php b/src/Symfony/Component/Cache/LockRegistry.php index 3fa8bb8512..81f7db459f 100644 --- a/src/Symfony/Component/Cache/LockRegistry.php +++ b/src/Symfony/Component/Cache/LockRegistry.php @@ -23,7 +23,7 @@ use Symfony\Contracts\Cache\ItemInterface; * * @author Nicolas Grekas
*/
-class LockRegistry
+final class LockRegistry
{
private static $openedFiles = [];
private static $lockedFiles = [];
@@ -75,7 +75,7 @@ class LockRegistry
return $previousFiles;
}
- public static function compute(callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool)
+ public static function compute(callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool, \Closure $setMetadata = null)
{
$key = self::$files ? crc32($item->getKey()) % \count(self::$files) : -1;
@@ -89,7 +89,18 @@ class LockRegistry
if (flock($lock, LOCK_EX | LOCK_NB)) {
self::$lockedFiles[$key] = true;
- return $callback($item, $save);
+ $value = $callback($item, $save);
+
+ if ($save) {
+ if ($setMetadata) {
+ $setMetadata($item);
+ }
+
+ $pool->save($item->set($value));
+ $save = false;
+ }
+
+ return $value;
}
// if we failed the race, retry locking in blocking mode to wait for the winner
flock($lock, LOCK_SH);
@@ -126,6 +137,6 @@ class LockRegistry
restore_error_handler();
}
- self::$openedFiles[$key] = $h ?: @fopen(self::$files[$key], 'r');
+ return self::$openedFiles[$key] = $h ?: @fopen(self::$files[$key], 'r');
}
}
diff --git a/src/Symfony/Component/Cache/Traits/ContractsTrait.php b/src/Symfony/Component/Cache/Traits/ContractsTrait.php
index 8b1eb5a244..bd7be08dd5 100644
--- a/src/Symfony/Component/Cache/Traits/ContractsTrait.php
+++ b/src/Symfony/Component/Cache/Traits/ContractsTrait.php
@@ -40,7 +40,7 @@ trait ContractsTrait
public function setCallbackWrapper(?callable $callbackWrapper): callable
{
$previousWrapper = $this->callbackWrapper;
- $this->callbackWrapper = $callbackWrapper ?? function (callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool) {
+ $this->callbackWrapper = $callbackWrapper ?? function (callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool, \Closure $setMetadata) {
return $callback($item, $save);
};
@@ -56,17 +56,19 @@ trait ContractsTrait
static $setMetadata;
$setMetadata = $setMetadata ?? \Closure::bind(
- function (AdapterInterface $pool, ItemInterface $item, float $startTime) {
+ function (CacheItem $item, float $startTime, ?array &$metadata) {
if ($item->expiry > $endTime = microtime(true)) {
- $item->newMetadata[ItemInterface::METADATA_EXPIRY] = $item->expiry;
- $item->newMetadata[ItemInterface::METADATA_CTIME] = 1000 * (int) ($endTime - $startTime);
+ $item->newMetadata[CacheItem::METADATA_EXPIRY] = $metadata[CacheItem::METADATA_EXPIRY] = $item->expiry;
+ $item->newMetadata[CacheItem::METADATA_CTIME] = $metadata[CacheItem::METADATA_CTIME] = 1000 * (int) ($endTime - $startTime);
+ } else {
+ unset($metadata[CacheItem::METADATA_EXPIRY], $metadata[CacheItem::METADATA_CTIME]);
}
},
null,
CacheItem::class
);
- return $this->contractsGet($pool, $key, function (CacheItem $item, bool &$save) use ($pool, $callback, $setMetadata) {
+ return $this->contractsGet($pool, $key, function (CacheItem $item, bool &$save) use ($pool, $callback, $setMetadata, &$metadata) {
// don't wrap nor save recursive calls
if (null === $callbackWrapper = $this->callbackWrapper) {
$value = $callback($item, $save);
@@ -78,8 +80,10 @@ trait ContractsTrait
$startTime = microtime(true);
try {
- $value = $callbackWrapper($callback, $item, $save, $pool);
- $setMetadata($pool, $item, $startTime);
+ $value = $callbackWrapper($callback, $item, $save, $pool, function (CacheItem $item) use ($setMetadata, $startTime, &$metadata) {
+ $setMetadata($item, $startTime, $metadata);
+ });
+ $setMetadata($item, $startTime, $metadata);
return $value;
} finally {
diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php
index 7f44aab1d5..7cf2120a51 100644
--- a/src/Symfony/Component/HttpFoundation/Request.php
+++ b/src/Symfony/Component/HttpFoundation/Request.php
@@ -1330,7 +1330,7 @@ class Request
*
* @param string|null $default The default format
*
- * @return string The request format
+ * @return string|null The request format
*/
public function getRequestFormat($default = 'html')
{
diff --git a/src/Symfony/Component/Security/Core/Resources/translations/security.ua.xlf b/src/Symfony/Component/Security/Core/Resources/translations/security.uk.xlf
similarity index 100%
rename from src/Symfony/Component/Security/Core/Resources/translations/security.ua.xlf
rename to src/Symfony/Component/Security/Core/Resources/translations/security.uk.xlf
diff --git a/src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php b/src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php
index c0266e65a5..7d1cdd8003 100644
--- a/src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php
+++ b/src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php
@@ -66,6 +66,11 @@ class Psr6Cache implements CacheInterface
*/
private function escapeClassName(string $class): string
{
+ if (false !== strpos($class, '@')) {
+ // anonymous class: replace all PSR6-reserved characters
+ return str_replace(["\0", '\\', '/', '@', ':', '{', '}', '(', ')'], '.', $class);
+ }
+
return str_replace('\\', '.', $class);
}
}
diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf
index bd09da5d0e..1db88086cf 100644
--- a/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf
+++ b/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf
@@ -36,23 +36,23 @@