diff --git a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php index af4a1d156c..0ebce3696f 100644 --- a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php @@ -74,7 +74,11 @@ class DoctrineTokenProvider implements TokenProviderInterface $sql = 'DELETE FROM rememberme_token WHERE series=:series'; $paramValues = ['series' => $series]; $paramTypes = ['series' => \PDO::PARAM_STR]; - $this->conn->executeUpdate($sql, $paramValues, $paramTypes); + if (method_exists($this->conn, 'executeStatement')) { + $this->conn->executeStatement($sql, $paramValues, $paramTypes); + } else { + $this->conn->executeUpdate($sql, $paramValues, $paramTypes); + } } /** @@ -94,7 +98,11 @@ class DoctrineTokenProvider implements TokenProviderInterface 'lastUsed' => Types::DATETIME_MUTABLE, 'series' => \PDO::PARAM_STR, ]; - $updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes); + if (method_exists($this->conn, 'executeStatement')) { + $updated = $this->conn->executeStatement($sql, $paramValues, $paramTypes); + } else { + $updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes); + } if ($updated < 1) { throw new TokenNotFoundException('No token found.'); } @@ -122,6 +130,10 @@ class DoctrineTokenProvider implements TokenProviderInterface 'value' => \PDO::PARAM_STR, 'lastUsed' => Types::DATETIME_MUTABLE, ]; - $this->conn->executeUpdate($sql, $paramValues, $paramTypes); + if (method_exists($this->conn, 'executeStatement')) { + $this->conn->executeStatement($sql, $paramValues, $paramTypes); + } else { + $this->conn->executeUpdate($sql, $paramValues, $paramTypes); + } } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php index df696ff7ff..75faf9012a 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/RememberMe/DoctrineTokenProviderTest.php @@ -72,7 +72,7 @@ class DoctrineTokenProviderTest extends TestCase 'driver' => 'pdo_sqlite', 'url' => 'sqlite:///:memory:', ]); - $connection->executeUpdate(<<< 'SQL' + $connection->{method_exists($connection, 'executeStatement') ? 'executeStatement' : 'executeUpdate'}(<<< 'SQL' CREATE TABLE rememberme_token ( series char(88) UNIQUE PRIMARY KEY NOT NULL, value char(88) NOT NULL, diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 3cb6f17131..2b276f60b6 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -43,12 +43,11 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s").', $this->maxIdLength - 24, \strlen($namespace), $namespace)); } $this->createCacheItem = \Closure::bind( - static function ($key, $value, $isHit) use ($defaultLifetime) { + static function ($key, $value, $isHit) { $item = new CacheItem(); $item->key = $key; $item->value = $v = $value; $item->isHit = $isHit; - $item->defaultLifetime = $defaultLifetime; // Detect wrapped values that encode for their expiry and creation duration // For compactness, these values are packed in the key of an array using // magic numbers in the form 9D-..-..-..-..-00-..-..-..-5F @@ -66,7 +65,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg ); $getId = \Closure::fromCallable([$this, 'getId']); $this->mergeByLifetime = \Closure::bind( - static function ($deferred, $namespace, &$expiredIds) use ($getId) { + static function ($deferred, $namespace, &$expiredIds) use ($getId, $defaultLifetime) { $byLifetime = []; $now = microtime(true); $expiredIds = []; @@ -74,7 +73,9 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg foreach ($deferred as $key => $item) { $key = (string) $key; if (null === $item->expiry) { - $ttl = 0 < $item->defaultLifetime ? $item->defaultLifetime : 0; + $ttl = 0 < $defaultLifetime ? $defaultLifetime : 0; + } elseif (0 === $item->expiry) { + $ttl = 0; } elseif (0 >= $ttl = (int) (0.1 + $item->expiry - $now)) { $expiredIds[] = $getId($key); continue; diff --git a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php index 86a69f26e7..ae3116ed8d 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php @@ -44,10 +44,9 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s").', $this->maxIdLength - 24, \strlen($namespace), $namespace)); } $this->createCacheItem = \Closure::bind( - static function ($key, $value, $isHit) use ($defaultLifetime) { + static function ($key, $value, $isHit) { $item = new CacheItem(); $item->key = $key; - $item->defaultLifetime = $defaultLifetime; $item->isTaggable = true; // If structure does not match what we expect return item as is (no value and not a hit) if (!\is_array($value) || !\array_key_exists('value', $value)) { @@ -72,7 +71,7 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA $getId = \Closure::fromCallable([$this, 'getId']); $tagPrefix = self::TAGS_PREFIX; $this->mergeByLifetime = \Closure::bind( - static function ($deferred, &$expiredIds) use ($getId, $tagPrefix) { + static function ($deferred, &$expiredIds) use ($getId, $tagPrefix, $defaultLifetime) { $byLifetime = []; $now = microtime(true); $expiredIds = []; @@ -80,7 +79,9 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA foreach ($deferred as $key => $item) { $key = (string) $key; if (null === $item->expiry) { - $ttl = 0 < $item->defaultLifetime ? $item->defaultLifetime : 0; + $ttl = 0 < $defaultLifetime ? $defaultLifetime : 0; + } elseif (0 === $item->expiry) { + $ttl = 0; } elseif (0 >= $ttl = (int) (0.1 + $item->expiry - $now)) { $expiredIds[] = $getId($key); continue; diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index 71d3e765be..701f9190e5 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -34,6 +34,7 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter private $values = []; private $expiries = []; private $createCacheItem; + private $defaultLifetime; private $maxLifetime; private $maxItems; @@ -50,16 +51,16 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter throw new InvalidArgumentException(sprintf('Argument $maxItems must be a positive integer, %d passed.', $maxItems)); } + $this->defaultLifetime = $defaultLifetime; $this->storeSerialized = $storeSerialized; $this->maxLifetime = $maxLifetime; $this->maxItems = $maxItems; $this->createCacheItem = \Closure::bind( - static function ($key, $value, $isHit) use ($defaultLifetime) { + static function ($key, $value, $isHit) { $item = new CacheItem(); $item->key = $key; $item->value = $value; $item->isHit = $isHit; - $item->defaultLifetime = $defaultLifetime; return $item; }, @@ -203,8 +204,8 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter if ($this->storeSerialized && null === $value = $this->freeze($value, $key)) { return false; } - if (null === $expiry && 0 < $item["\0*\0defaultLifetime"]) { - $expiry = $item["\0*\0defaultLifetime"]; + if (null === $expiry && 0 < $this->defaultLifetime) { + $expiry = microtime(true) + $this->defaultLifetime; $expiry = $now + ($expiry > ($this->maxLifetime ?: $expiry) ? $this->maxLifetime : $expiry); } elseif ($this->maxLifetime && (null === $expiry || $expiry > $now + $this->maxLifetime)) { $expiry = $now + $this->maxLifetime; diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index 5432ce92fb..d2ff15eb9d 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -70,15 +70,11 @@ class ChainAdapter implements AdapterInterface, CacheInterface, PruneableInterfa unset($sourceMetadata[CacheItem::METADATA_TAGS]); $item->value = $sourceItem->value; - $item->expiry = $sourceMetadata[CacheItem::METADATA_EXPIRY] ?? $sourceItem->expiry; $item->isHit = $sourceItem->isHit; $item->metadata = $item->newMetadata = $sourceItem->metadata = $sourceMetadata; - if (0 < $sourceItem->defaultLifetime && $sourceItem->defaultLifetime < $defaultLifetime) { - $defaultLifetime = $sourceItem->defaultLifetime; - } - if (0 < $defaultLifetime && ($item->defaultLifetime <= 0 || $defaultLifetime < $item->defaultLifetime)) { - $item->defaultLifetime = $defaultLifetime; + if (0 < $defaultLifetime) { + $item->expiresAfter($defaultLifetime); } return $item; diff --git a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php index 00e2f835fd..d80cd89d62 100644 --- a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php @@ -121,7 +121,11 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface $this->addTableToSchema($schema); foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) { - $conn->exec($sql); + if (method_exists($conn, 'executeStatement')) { + $conn->executeStatement($sql); + } else { + $conn->exec($sql); + } } return; @@ -152,7 +156,11 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver)); } - $conn->exec($sql); + if (method_exists($conn, 'executeStatement')) { + $conn->executeStatement($sql); + } else { + $conn->exec($sql); + } } /** @@ -281,7 +289,11 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface } try { - $conn->exec($sql); + if (method_exists($conn, 'executeStatement')) { + $conn->executeStatement($sql); + } else { + $conn->exec($sql); + } } catch (TableNotFoundException $e) { } catch (\PDOException $e) { } diff --git a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php index bd96fa87b9..82a2deaf08 100644 --- a/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ProxyAdapter.php @@ -33,6 +33,7 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa private $createCacheItem; private $setInnerItem; private $poolHash; + private $defaultLifetime; public function __construct(CacheItemPoolInterface $pool, string $namespace = '', int $defaultLifetime = 0) { @@ -40,8 +41,9 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa $this->poolHash = $poolHash = spl_object_hash($pool); $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace); $this->namespaceLen = \strlen($namespace); + $this->defaultLifetime = $defaultLifetime; $this->createCacheItem = \Closure::bind( - static function ($key, $innerItem) use ($defaultLifetime, $poolHash) { + static function ($key, $innerItem) use ($poolHash) { $item = new CacheItem(); $item->key = $key; @@ -52,7 +54,6 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa $item->value = $v = $innerItem->get(); $item->isHit = $innerItem->isHit(); $item->innerItem = $innerItem; - $item->defaultLifetime = $defaultLifetime; $item->poolHash = $poolHash; // Detect wrapped values that encode for their expiry and creation duration @@ -223,8 +224,8 @@ class ProxyAdapter implements AdapterInterface, CacheInterface, PruneableInterfa return false; } $item = (array) $item; - if (null === $item["\0*\0expiry"] && 0 < $item["\0*\0defaultLifetime"]) { - $item["\0*\0expiry"] = microtime(true) + $item["\0*\0defaultLifetime"]; + if (null === $item["\0*\0expiry"] && 0 < $this->defaultLifetime) { + $item["\0*\0expiry"] = microtime(true) + $this->defaultLifetime; } if ($item["\0*\0poolHash"] === $this->poolHash && $item["\0*\0innerItem"]) { diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 793df433f9..10375f7c07 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -49,7 +49,6 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac $item = new CacheItem(); $item->key = $key; $item->value = $value; - $item->defaultLifetime = $protoItem->defaultLifetime; $item->expiry = $protoItem->expiry; $item->poolHash = $protoItem->poolHash; @@ -94,8 +93,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac $this->invalidateTags = \Closure::bind( static function (AdapterInterface $tagsAdapter, array $tags) { foreach ($tags as $v) { - $v->defaultLifetime = 0; - $v->expiry = null; + $v->expiry = 0; $tagsAdapter->saveDeferred($v); } diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index fac5f9004e..295b0c1366 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -27,7 +27,6 @@ final class CacheItem implements ItemInterface protected $value; protected $isHit = false; protected $expiry; - protected $defaultLifetime; protected $metadata = []; protected $newMetadata = []; protected $innerItem; @@ -78,7 +77,7 @@ final class CacheItem implements ItemInterface public function expiresAt($expiration): self { if (null === $expiration) { - $this->expiry = $this->defaultLifetime > 0 ? microtime(true) + $this->defaultLifetime : null; + $this->expiry = null; } elseif ($expiration instanceof \DateTimeInterface) { $this->expiry = (float) $expiration->format('U.u'); } else { @@ -96,7 +95,7 @@ final class CacheItem implements ItemInterface public function expiresAfter($time): self { if (null === $time) { - $this->expiry = $this->defaultLifetime > 0 ? microtime(true) + $this->defaultLifetime : null; + $this->expiry = null; } elseif ($time instanceof \DateInterval) { $this->expiry = microtime(true) + \DateTime::createFromFormat('U', 0)->add($time)->format('U.u'); } elseif (\is_int($time)) { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php index 99b38834f8..3e723f1b6a 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php @@ -31,7 +31,7 @@ class ChainAdapterTest extends AdapterTestCase return new ChainAdapter([new FilesystemAdapter('a', $defaultLifetime), new FilesystemAdapter('b', $defaultLifetime)], $defaultLifetime); } - return new ChainAdapter([new ArrayAdapter($defaultLifetime), new ExternalAdapter(), new FilesystemAdapter('', $defaultLifetime)], $defaultLifetime); + return new ChainAdapter([new ArrayAdapter($defaultLifetime), new ExternalAdapter($defaultLifetime), new FilesystemAdapter('', $defaultLifetime)], $defaultLifetime); } public function testEmptyAdaptersException() @@ -69,6 +69,124 @@ class ChainAdapterTest extends AdapterTestCase $this->assertFalse($cache->prune()); } + public function testMultipleCachesExpirationWhenCommonTtlIsNotSet() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $adapter1 = new ArrayAdapter(4); + $adapter2 = new ArrayAdapter(2); + + $cache = new ChainAdapter([$adapter1, $adapter2]); + + $cache->save($cache->getItem('key')->set('value')); + + $item = $adapter1->getItem('key'); + $this->assertTrue($item->isHit()); + $this->assertEquals('value', $item->get()); + + $item = $adapter2->getItem('key'); + $this->assertTrue($item->isHit()); + $this->assertEquals('value', $item->get()); + + sleep(2); + + $item = $adapter1->getItem('key'); + $this->assertTrue($item->isHit()); + $this->assertEquals('value', $item->get()); + + $item = $adapter2->getItem('key'); + $this->assertFalse($item->isHit()); + + sleep(2); + + $item = $adapter1->getItem('key'); + $this->assertFalse($item->isHit()); + + $adapter2->save($adapter2->getItem('key1')->set('value1')); + + $item = $cache->getItem('key1'); + $this->assertTrue($item->isHit()); + $this->assertEquals('value1', $item->get()); + + sleep(2); + + $item = $adapter1->getItem('key1'); + $this->assertTrue($item->isHit()); + $this->assertEquals('value1', $item->get()); + + $item = $adapter2->getItem('key1'); + $this->assertFalse($item->isHit()); + + sleep(2); + + $item = $adapter1->getItem('key1'); + $this->assertFalse($item->isHit()); + } + + public function testMultipleCachesExpirationWhenCommonTtlIsSet() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $adapter1 = new ArrayAdapter(4); + $adapter2 = new ArrayAdapter(2); + + $cache = new ChainAdapter([$adapter1, $adapter2], 6); + + $cache->save($cache->getItem('key')->set('value')); + + $item = $adapter1->getItem('key'); + $this->assertTrue($item->isHit()); + $this->assertEquals('value', $item->get()); + + $item = $adapter2->getItem('key'); + $this->assertTrue($item->isHit()); + $this->assertEquals('value', $item->get()); + + sleep(2); + + $item = $adapter1->getItem('key'); + $this->assertTrue($item->isHit()); + $this->assertEquals('value', $item->get()); + + $item = $adapter2->getItem('key'); + $this->assertFalse($item->isHit()); + + sleep(2); + + $item = $adapter1->getItem('key'); + $this->assertFalse($item->isHit()); + + $adapter2->save($adapter2->getItem('key1')->set('value1')); + + $item = $cache->getItem('key1'); + $this->assertTrue($item->isHit()); + $this->assertEquals('value1', $item->get()); + + sleep(2); + + $item = $adapter1->getItem('key1'); + $this->assertTrue($item->isHit()); + $this->assertEquals('value1', $item->get()); + + $item = $adapter2->getItem('key1'); + $this->assertFalse($item->isHit()); + + sleep(2); + + $item = $adapter1->getItem('key1'); + $this->assertTrue($item->isHit()); + $this->assertEquals('value1', $item->get()); + + sleep(2); + + $item = $adapter1->getItem('key1'); + $this->assertFalse($item->isHit()); + } + private function getPruneableMock(): AdapterInterface { $pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]); diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index b25f34fc18..dbdc8744da 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -395,7 +395,7 @@ class ChoiceType extends AbstractType 'value' => $choiceView->value, 'label' => $choiceView->label, 'attr' => $choiceView->attr, - 'translation_domain' => $options['translation_domain'], + 'translation_domain' => $options['choice_translation_domain'], 'block_name' => 'entry', ]; diff --git a/src/Symfony/Component/Form/Resources/translations/validators.tl.xlf b/src/Symfony/Component/Form/Resources/translations/validators.tl.xlf index 02def0bf31..950c4110d8 100644 --- a/src/Symfony/Component/Form/Resources/translations/validators.tl.xlf +++ b/src/Symfony/Component/Form/Resources/translations/validators.tl.xlf @@ -14,6 +14,106 @@ The CSRF token is invalid. Please try to resubmit the form. Hindi balido ang CSRF token. Maagpasa muli ng isang pang porma. + + This value is not a valid HTML5 color. + Ang halagang ito ay hindi wastong HTML5 color. + + + Please enter a valid birthdate. + Pakilagay ang tamang petsa ng kapanganakan. + + + The selected choice is invalid. + Ang pinagpiliang sagot ay hindi tama. + + + The collection is invalid. + Hindi balido ang koleksyon. + + + Please select a valid color. + Pakipiliin ang nararapat na kulay. + + + Please select a valid country. + Pakipiliin ang nararapat na bansa. + + + Please select a valid currency. + Pakipiliin ang tamang pananalapi. + + + Please choose a valid date interval. + Piliin ang wastong agwat ng petsa. + + + Please enter a valid date and time. + Piliin ang wastong petsa at oras. + + + Please enter a valid date. + Ilagay ang wastong petsa. + + + Please select a valid file. + Piliin ang balidong file. + + + The hidden field is invalid. + Hindi balido ang field na nakatago. + + + Please enter an integer. + Pakilagay ang integer. + + + Please select a valid language. + Piliin ang nararapat na lengguwahe. + + + Please select a valid locale. + Pakipili ang nararapat na locale. + + + Please enter a valid money amount. + Pakilagay ang tamang halaga ng pera. + + + Please enter a number. + Ilagay ang numero. + + + The password is invalid. + Hindi balido ang password. + + + Please enter a percentage value. + Pakilagay ang tamang porsyento ng halaga. + + + The values do not match. + Hindi tugma ang mga halaga. + + + Please enter a valid time. + Pakilagay ang tamang oras. + + + Please select a valid timezone. + Pakilagay ang tamang sona ng oras. + + + Please enter a valid URL. + Pakilagay ang balidong URL. + + + Please enter a valid search term. + Pakilagay ang balidong katagang sinasaliksik. + + + Please provide a valid phone number. + Pakilagay ang balidong numero ng telepono. + diff --git a/src/Symfony/Component/Form/Resources/translations/validators.vi.xlf b/src/Symfony/Component/Form/Resources/translations/validators.vi.xlf index b5b2f83a9a..4d060fbe0d 100644 --- a/src/Symfony/Component/Form/Resources/translations/validators.vi.xlf +++ b/src/Symfony/Component/Form/Resources/translations/validators.vi.xlf @@ -4,7 +4,7 @@ This form should not contain extra fields. - Mẫu này không nên chứa trường mở rộng + Mẫu này không nên chứa trường mở rộng. The uploaded file was too large. Please try to upload a smaller file. @@ -14,6 +14,106 @@ The CSRF token is invalid. Please try to resubmit the form. CSRF token không hợp lệ. Vui lòng thử lại. + + This value is not a valid HTML5 color. + Giá trị này không phải là màu HTML5 hợp lệ. + + + Please enter a valid birthdate. + Vui lòng nhập ngày sinh hợp lệ. + + + The selected choice is invalid. + Lựa chọn không hợp lệ. + + + The collection is invalid. + Danh sách không hợp lệ. + + + Please select a valid color. + Vui lòng chọn một màu hợp lệ. + + + Please select a valid country. + Vui lòng chọn đất nước hợp lệ. + + + Please select a valid currency. + Vui lòng chọn tiền tệ hợp lệ. + + + Please choose a valid date interval. + Vui lòng chọn một khoảng thời gian hợp lệ. + + + Please enter a valid date and time. + Vui lòng nhập ngày và thời gian hợp lệ. + + + Please enter a valid date. + Vui lòng nhập ngày hợp lệ. + + + Please select a valid file. + Vui lòng chọn tệp hợp lệ. + + + The hidden field is invalid. + Phạm vi ẩn không hợp lệ. + + + Please enter an integer. + Vui lòng nhập một số nguyên. + + + Please select a valid language. + Vui lòng chọn ngôn ngữ hợp lệ. + + + Please select a valid locale. + Vui lòng chọn miền hợp lệ. + + + Please enter a valid money amount. + Vui lòng nhập một khoảng tiền hợp lệ. + + + Please enter a number. + Vui lòng nhập một con số. + + + The password is invalid. + Mật khẩu không hợp lệ. + + + Please enter a percentage value. + Vui lòng nhập một giá trị phần trăm. + + + The values do not match. + Các giá trị không phù hợp. + + + Please enter a valid time. + Vui lòng nhập thời gian hợp lệ. + + + Please select a valid timezone. + Vui lòng chọn múi giờ hợp lệ. + + + Please enter a valid URL. + Vui lòng nhập một URL hợp lệ. + + + Please enter a valid search term. + Vui lòng nhập chuỗi tìm kiếm hợp lệ. + + + Please provide a valid phone number. + Vui lòng cung cấp số điện thoại hợp lệ. + diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index 7bbaf4efb6..16ede19493 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -2003,6 +2003,24 @@ class ChoiceTypeTest extends BaseTypeTest $this->assertEquals('_09name', $view->vars['full_name']); } + public function testSubFormTranslationDomain() + { + $form = $this->factory->create(static::TESTED_TYPE, null, [ + 'label' => 'label', + 'translation_domain' => 'label_translation_domain', + 'choices' => [ + 'choice1' => true, + 'choice2' => false, + ], + 'choice_translation_domain' => 'choice_translation_domain', + 'expanded' => true, + ])->createView(); + + $this->assertCount(2, $form->children); + $this->assertSame('choice_translation_domain', $form->children[0]->vars['translation_domain']); + $this->assertSame('choice_translation_domain', $form->children[1]->vars['translation_domain']); + } + /** * @dataProvider provideTrimCases */ diff --git a/src/Symfony/Component/Lock/Store/PdoStore.php b/src/Symfony/Component/Lock/Store/PdoStore.php index 160bec0e1d..e72d80da66 100644 --- a/src/Symfony/Component/Lock/Store/PdoStore.php +++ b/src/Symfony/Component/Lock/Store/PdoStore.php @@ -253,7 +253,11 @@ class PdoStore implements PersistingStoreInterface $this->addTableToSchema($schema); foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) { - $conn->exec($sql); + if (method_exists($conn, 'executeStatement')) { + $conn->executeStatement($sql); + } else { + $conn->exec($sql); + } } return; @@ -279,7 +283,11 @@ class PdoStore implements PersistingStoreInterface throw new \DomainException(sprintf('Creating the lock table is currently not implemented for PDO driver "%s".', $driver)); } - $conn->exec($sql); + if (method_exists($conn, 'executeStatement')) { + $conn->executeStatement($sql); + } else { + $conn->exec($sql); + } } /** @@ -305,7 +313,12 @@ class PdoStore implements PersistingStoreInterface { $sql = "DELETE FROM $this->table WHERE $this->expirationCol <= {$this->getCurrentTimestampStatement()}"; - $this->getConnection()->exec($sql); + $conn = $this->getConnection(); + if (method_exists($conn, 'executeStatement')) { + $conn->executeStatement($sql); + } else { + $conn->exec($sql); + } } private function getDriver(): string diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php index 3712b0dd94..a08178235c 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php @@ -130,7 +130,7 @@ class Connection implements ResetInterface 'available_at' => '?', ]); - $this->executeUpdate($queryBuilder->getSQL(), [ + $this->executeStatement($queryBuilder->getSQL(), [ $body, json_encode($headers), $this->configuration['queue_name'], @@ -181,7 +181,7 @@ class Connection implements ResetInterface ->set('delivered_at', '?') ->where('id = ?'); $now = new \DateTime(); - $this->executeUpdate($queryBuilder->getSQL(), [ + $this->executeStatement($queryBuilder->getSQL(), [ $now, $doctrineEnvelope['id'], ], [ @@ -338,10 +338,14 @@ class Connection implements ResetInterface return $stmt; } - private function executeUpdate(string $sql, array $parameters = [], array $types = []) + private function executeStatement(string $sql, array $parameters = [], array $types = []) { try { - $stmt = $this->driverConnection->executeUpdate($sql, $parameters, $types); + if (method_exists($this->driverConnection, 'executeStatement')) { + $stmt = $this->driverConnection->executeStatement($sql, $parameters, $types); + } else { + $stmt = $this->driverConnection->executeUpdate($sql, $parameters, $types); + } } catch (TableNotFoundException $e) { if ($this->driverConnection->isTransactionActive()) { throw $e; @@ -351,7 +355,11 @@ class Connection implements ResetInterface if ($this->autoSetup) { $this->setup(); } - $stmt = $this->driverConnection->executeUpdate($sql, $parameters, $types); + if (method_exists($this->driverConnection, 'executeStatement')) { + $stmt = $this->driverConnection->executeStatement($sql, $parameters, $types); + } else { + $stmt = $this->driverConnection->executeUpdate($sql, $parameters, $types); + } } return $stmt; diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index aa9bf7dd28..a7883d2f4e 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -556,6 +556,7 @@ class OptionsResolver implements Options } if ($forcePrepend) { + $this->normalizers[$option] = $this->normalizers[$option] ?? []; array_unshift($this->normalizers[$option], $normalizer); } else { $this->normalizers[$option][] = $normalizer; diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php index 9831146185..4083e5ee6a 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php @@ -1512,6 +1512,17 @@ class OptionsResolverTest extends TestCase $this->assertEquals(['foo' => '2nd-normalized-1st-normalized-bar'], $this->resolver->resolve()); } + public function testForcePrependNormalizerForResolverWithoutPreviousNormalizers() + { + // defined by superclass + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->addNormalizer('foo', function (Options $options, $value) { + return '1st-normalized-'.$value; + }, true); + + $this->assertEquals(['foo' => '1st-normalized-bar'], $this->resolver->resolve()); + } + public function testAddNormalizerFailsIfUnknownOption() { $this->expectException('Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException');