Merge branch '4.4' into 5.0

* 4.4:
  [Cache] Use the default expiry when saving (not when creating) items
  Fix typo
  Fix DBAL deprecation
  [Form] Fix ChoiceType translation domain
  Add Tagalog translations for new form messages
  [Form] Add missing vietnamese translations
  sync translations from master
  [OptionsResolver] Fix force prepend normalizer
  add vietnamese translation for html5 color validation
This commit is contained in:
Nicolas Grekas 2020-07-12 14:51:51 +02:00
commit afd9760357
20 changed files with 532 additions and 46 deletions

View File

@ -81,7 +81,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);
}
}
/**
@ -101,7 +105,11 @@ class DoctrineTokenProvider implements TokenProviderInterface
'lastUsed' => self::$useDeprecatedConstants ? Type::DATETIME : 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.');
}
@ -129,6 +137,10 @@ class DoctrineTokenProvider implements TokenProviderInterface
'value' => \PDO::PARAM_STR,
'lastUsed' => self::$useDeprecatedConstants ? Type::DATETIME : 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);
}
}
}

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -29,20 +29,21 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
private $values = [];
private $expiries = [];
private $createCacheItem;
private $defaultLifetime;
/**
* @param bool $storeSerialized Disabling serialization can lead to cache corruptions when storing mutable values but increases performance otherwise
*/
public function __construct(int $defaultLifetime = 0, bool $storeSerialized = true)
{
$this->defaultLifetime = $defaultLifetime;
$this->storeSerialized = $storeSerialized;
$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;
},
@ -172,8 +173,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 = microtime(true) + $item["\0*\0defaultLifetime"];
if (null === $expiry && 0 < $this->defaultLifetime) {
$expiry = microtime(true) + $this->defaultLifetime;
}
$this->values[$key] = $value;

View File

@ -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;

View File

@ -137,7 +137,11 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
$table->setPrimaryKey([$this->idCol]);
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
$conn->exec($sql);
if (method_exists($conn, 'executeStatement')) {
$conn->executeStatement($sql);
} else {
$conn->exec($sql);
}
}
return;
@ -168,7 +172,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);
}
}
/**
@ -280,7 +288,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) {
}

View File

@ -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"]) {

View File

@ -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);
}

View File

@ -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)) {

View File

@ -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]);

View File

@ -368,7 +368,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',
];

View File

@ -18,6 +18,102 @@
<source>This value is not a valid HTML5 color.</source>
<target>This value is not a valid HTML5 color.</target>
</trans-unit>
<trans-unit id="100">
<source>Please enter a valid birthdate.</source>
<target>Please enter a valid birthdate.</target>
</trans-unit>
<trans-unit id="101">
<source>The selected choice is invalid.</source>
<target>The selected choice is invalid.</target>
</trans-unit>
<trans-unit id="102">
<source>The collection is invalid.</source>
<target>The collection is invalid.</target>
</trans-unit>
<trans-unit id="103">
<source>Please select a valid color.</source>
<target>Please select a valid color.</target>
</trans-unit>
<trans-unit id="104">
<source>Please select a valid country.</source>
<target>Please select a valid country.</target>
</trans-unit>
<trans-unit id="105">
<source>Please select a valid currency.</source>
<target>Please select a valid currency.</target>
</trans-unit>
<trans-unit id="106">
<source>Please choose a valid date interval.</source>
<target>Please choose a valid date interval.</target>
</trans-unit>
<trans-unit id="107">
<source>Please enter a valid date and time.</source>
<target>Please enter a valid date and time.</target>
</trans-unit>
<trans-unit id="108">
<source>Please enter a valid date.</source>
<target>Please enter a valid date.</target>
</trans-unit>
<trans-unit id="109">
<source>Please select a valid file.</source>
<target>Please select a valid file.</target>
</trans-unit>
<trans-unit id="110">
<source>The hidden field is invalid.</source>
<target>The hidden field is invalid.</target>
</trans-unit>
<trans-unit id="111">
<source>Please enter an integer.</source>
<target>Please enter an integer.</target>
</trans-unit>
<trans-unit id="112">
<source>Please select a valid language.</source>
<target>Please select a valid language.</target>
</trans-unit>
<trans-unit id="113">
<source>Please select a valid locale.</source>
<target>Please select a valid locale.</target>
</trans-unit>
<trans-unit id="114">
<source>Please enter a valid money amount.</source>
<target>Please enter a valid money amount.</target>
</trans-unit>
<trans-unit id="115">
<source>Please enter a number.</source>
<target>Please enter a number.</target>
</trans-unit>
<trans-unit id="116">
<source>The password is invalid.</source>
<target>The password is invalid.</target>
</trans-unit>
<trans-unit id="117">
<source>Please enter a percentage value.</source>
<target>Please enter a percentage value.</target>
</trans-unit>
<trans-unit id="118">
<source>The values do not match.</source>
<target>The values do not match.</target>
</trans-unit>
<trans-unit id="119">
<source>Please enter a valid time.</source>
<target>Please enter a valid time.</target>
</trans-unit>
<trans-unit id="120">
<source>Please select a valid timezone.</source>
<target>Please select a valid timezone.</target>
</trans-unit>
<trans-unit id="121">
<source>Please enter a valid URL.</source>
<target>Please enter a valid URL.</target>
</trans-unit>
<trans-unit id="122">
<source>Please enter a valid search term.</source>
<target>Please enter a valid search term.</target>
</trans-unit>
<trans-unit id="123">
<source>Please provide a valid phone number.</source>
<target>Please provide a valid phone number.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -14,6 +14,106 @@
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
<target>Hindi balido ang CSRF token. Maagpasa muli ng isang pang porma.</target>
</trans-unit>
<trans-unit id="99">
<source>This value is not a valid HTML5 color.</source>
<target>Ang halagang ito ay hindi wastong HTML5 color.</target>
</trans-unit>
<trans-unit id="100">
<source>Please enter a valid birthdate.</source>
<target>Pakilagay ang tamang petsa ng kapanganakan.</target>
</trans-unit>
<trans-unit id="101">
<source>The selected choice is invalid.</source>
<target>Ang pinagpiliang sagot ay hindi tama.</target>
</trans-unit>
<trans-unit id="102">
<source>The collection is invalid.</source>
<target>Hindi balido ang koleksyon.</target>
</trans-unit>
<trans-unit id="103">
<source>Please select a valid color.</source>
<target>Pakipiliin ang nararapat na kulay.</target>
</trans-unit>
<trans-unit id="104">
<source>Please select a valid country.</source>
<target>Pakipiliin ang nararapat na bansa.</target>
</trans-unit>
<trans-unit id="105">
<source>Please select a valid currency.</source>
<target>Pakipiliin ang tamang pananalapi.</target>
</trans-unit>
<trans-unit id="106">
<source>Please choose a valid date interval.</source>
<target>Piliin ang wastong agwat ng petsa.</target>
</trans-unit>
<trans-unit id="107">
<source>Please enter a valid date and time.</source>
<target>Piliin ang wastong petsa at oras.</target>
</trans-unit>
<trans-unit id="108">
<source>Please enter a valid date.</source>
<target>Ilagay ang wastong petsa.</target>
</trans-unit>
<trans-unit id="109">
<source>Please select a valid file.</source>
<target>Piliin ang balidong file.</target>
</trans-unit>
<trans-unit id="110">
<source>The hidden field is invalid.</source>
<target>Hindi balido ang field na nakatago.</target>
</trans-unit>
<trans-unit id="111">
<source>Please enter an integer.</source>
<target>Pakilagay ang integer.</target>
</trans-unit>
<trans-unit id="112">
<source>Please select a valid language.</source>
<target>Piliin ang nararapat na lengguwahe.</target>
</trans-unit>
<trans-unit id="113">
<source>Please select a valid locale.</source>
<target>Pakipili ang nararapat na locale.</target>
</trans-unit>
<trans-unit id="114">
<source>Please enter a valid money amount.</source>
<target>Pakilagay ang tamang halaga ng pera.</target>
</trans-unit>
<trans-unit id="115">
<source>Please enter a number.</source>
<target>Ilagay ang numero.</target>
</trans-unit>
<trans-unit id="116">
<source>The password is invalid.</source>
<target>Hindi balido ang password.</target>
</trans-unit>
<trans-unit id="117">
<source>Please enter a percentage value.</source>
<target>Pakilagay ang tamang porsyento ng halaga.</target>
</trans-unit>
<trans-unit id="118">
<source>The values do not match.</source>
<target>Hindi tugma ang mga halaga.</target>
</trans-unit>
<trans-unit id="119">
<source>Please enter a valid time.</source>
<target>Pakilagay ang tamang oras.</target>
</trans-unit>
<trans-unit id="120">
<source>Please select a valid timezone.</source>
<target>Pakilagay ang tamang sona ng oras.</target>
</trans-unit>
<trans-unit id="121">
<source>Please enter a valid URL.</source>
<target>Pakilagay ang balidong URL.</target>
</trans-unit>
<trans-unit id="122">
<source>Please enter a valid search term.</source>
<target>Pakilagay ang balidong katagang sinasaliksik.</target>
</trans-unit>
<trans-unit id="123">
<source>Please provide a valid phone number.</source>
<target>Pakilagay ang balidong numero ng telepono.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -4,7 +4,7 @@
<body>
<trans-unit id="28">
<source>This form should not contain extra fields.</source>
<target>Mẫu này không nên chứa trường mở rộng</target>
<target>Mẫu này không nên chứa trường mở rộng.</target>
</trans-unit>
<trans-unit id="29">
<source>The uploaded file was too large. Please try to upload a smaller file.</source>
@ -14,6 +14,106 @@
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
<target>CSRF token không hợp lệ. Vui lòng thử lại.</target>
</trans-unit>
<trans-unit id="99">
<source>This value is not a valid HTML5 color.</source>
<target>Giá trị này không phải là màu HTML5 hợp lệ.</target>
</trans-unit>
<trans-unit id="100">
<source>Please enter a valid birthdate.</source>
<target>Vui lòng nhập ngày sinh hợp lệ.</target>
</trans-unit>
<trans-unit id="101">
<source>The selected choice is invalid.</source>
<target>Lựa chọn không hợp lệ.</target>
</trans-unit>
<trans-unit id="102">
<source>The collection is invalid.</source>
<target>Danh sách không hợp lệ.</target>
</trans-unit>
<trans-unit id="103">
<source>Please select a valid color.</source>
<target>Vui lòng chọn một màu hợp lệ.</target>
</trans-unit>
<trans-unit id="104">
<source>Please select a valid country.</source>
<target>Vui lòng chọn đất nước hợp lệ.</target>
</trans-unit>
<trans-unit id="105">
<source>Please select a valid currency.</source>
<target>Vui lòng chọn tiền tệ hợp lệ.</target>
</trans-unit>
<trans-unit id="106">
<source>Please choose a valid date interval.</source>
<target>Vui lòng chọn một khoảng thời gian hợp lệ.</target>
</trans-unit>
<trans-unit id="107">
<source>Please enter a valid date and time.</source>
<target>Vui lòng nhập ngày và thời gian hợp lệ.</target>
</trans-unit>
<trans-unit id="108">
<source>Please enter a valid date.</source>
<target>Vui lòng nhập ngày hợp lệ.</target>
</trans-unit>
<trans-unit id="109">
<source>Please select a valid file.</source>
<target>Vui lòng chọn tệp hợp lệ.</target>
</trans-unit>
<trans-unit id="110">
<source>The hidden field is invalid.</source>
<target>Phạm vi ẩn không hợp lệ.</target>
</trans-unit>
<trans-unit id="111">
<source>Please enter an integer.</source>
<target>Vui lòng nhập một số nguyên.</target>
</trans-unit>
<trans-unit id="112">
<source>Please select a valid language.</source>
<target>Vui lòng chọn ngôn ngữ hợp lệ.</target>
</trans-unit>
<trans-unit id="113">
<source>Please select a valid locale.</source>
<target>Vui lòng chọn miền hợp lệ.</target>
</trans-unit>
<trans-unit id="114">
<source>Please enter a valid money amount.</source>
<target>Vui lòng nhập một khoảng tiền hợp lệ.</target>
</trans-unit>
<trans-unit id="115">
<source>Please enter a number.</source>
<target>Vui lòng nhập một con số.</target>
</trans-unit>
<trans-unit id="116">
<source>The password is invalid.</source>
<target>Mật khẩu không hợp lệ.</target>
</trans-unit>
<trans-unit id="117">
<source>Please enter a percentage value.</source>
<target>Vui lòng nhập một giá trị phần trăm.</target>
</trans-unit>
<trans-unit id="118">
<source>The values do not match.</source>
<target>Các giá trị không phù hợp.</target>
</trans-unit>
<trans-unit id="119">
<source>Please enter a valid time.</source>
<target>Vui lòng nhập thời gian hợp lệ.</target>
</trans-unit>
<trans-unit id="120">
<source>Please select a valid timezone.</source>
<target>Vui lòng chọn múi giờ hợp lệ.</target>
</trans-unit>
<trans-unit id="121">
<source>Please enter a valid URL.</source>
<target>Vui lòng nhập một URL hợp lệ.</target>
</trans-unit>
<trans-unit id="122">
<source>Please enter a valid search term.</source>
<target>Vui lòng nhập chuỗi tìm kiếm hợp lệ.</target>
</trans-unit>
<trans-unit id="123">
<source>Please provide a valid phone number.</source>
<target>Vui lòng cung cấp số điện thoại hợp lệ.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -1997,6 +1997,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
*/

View File

@ -257,7 +257,11 @@ class PdoStore implements PersistingStoreInterface
$table->setPrimaryKey([$this->idCol]);
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
$conn->exec($sql);
if (method_exists($conn, 'executeStatement')) {
$conn->executeStatement($sql);
} else {
$conn->exec($sql);
}
}
return;
@ -283,7 +287,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);
}
}
/**
@ -293,7 +301,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

View File

@ -126,7 +126,7 @@ class Connection
'available_at' => '?',
]);
$this->executeUpdate($queryBuilder->getSQL(), [
$this->executeStatement($queryBuilder->getSQL(), [
$body,
json_encode($headers),
$this->configuration['queue_name'],
@ -179,7 +179,7 @@ class Connection
->set('delivered_at', '?')
->where('id = ?');
$now = new \DateTime();
$this->executeUpdate($queryBuilder->getSQL(), [
$this->executeStatement($queryBuilder->getSQL(), [
$now,
$doctrineEnvelope['id'],
], [
@ -329,10 +329,14 @@ class Connection
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;
@ -342,7 +346,11 @@ class Connection
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;

View File

@ -532,6 +532,7 @@ class OptionsResolver implements Options
}
if ($forcePrepend) {
$this->normalizers[$option] = $this->normalizers[$option] ?? [];
array_unshift($this->normalizers[$option], $normalizer);
} else {
$this->normalizers[$option][] = $normalizer;

View File

@ -1506,6 +1506,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');