Merge branch '4.3' into 4.4

* 4.3:
  [FrameworkBundle] Fix framework bundle lock configuration not working as expected
  [Validator] Add the missing translations for the Azerbaijani locale
  [HttpClient] workaround bad Content-Length sent by old libcurl
  [Cache] dont override native Memcached options
  Fix CS
  Fix exceptions (PDOException) error code type
  Fix return type of Process::restart().
  [Cache] fail gracefully when locking is not supported
  [HttpClient] fix race condition when reading response with informational status
  Names for buttons should start with lowercase
This commit is contained in:
Nicolas Grekas 2019-09-27 00:09:58 +02:00
commit fc78e200db
17 changed files with 289 additions and 17 deletions

View File

@ -96,7 +96,7 @@ Form
----
* Using the `format` option of `DateType` and `DateTimeType` when the `html5` option is enabled is deprecated.
* Using names for buttons that do not start with a letter, a digit, or an underscore is deprecated and will lead to an
* Using names for buttons that do not start with a lowercase letter, a digit, or an underscore is deprecated and will lead to an
exception in 5.0.
* Using names for buttons that do not contain only letters, digits, underscores, hyphens, and colons is deprecated and
will lead to an exception in 5.0.

View File

@ -160,7 +160,7 @@ Form
without configuring a reference date.
* Removed support for using `int` or `float` as data for the `NumberType` when the `input` option is set to `string`.
* Removed support for using the `format` option of `DateType` and `DateTimeType` when the `html5` option is enabled.
* Using names for buttons that do not start with a letter, a digit, or an underscore leads to an exception.
* Using names for buttons that do not start with a lowercase letter, a digit, or an underscore leads to an exception.
* Using names for buttons that do not contain only letters, digits, underscores, hyphens, and colons leads to an
exception.
* Using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget` option is

View File

@ -1074,7 +1074,11 @@ class Configuration implements ConfigurationInterface
->ifString()->then(function ($v) { return ['enabled' => true, 'resources' => $v]; })
->end()
->beforeNormalization()
->ifTrue(function ($v) { return \is_array($v) && !isset($v['resources']); })
->ifTrue(function ($v) { return \is_array($v) && !isset($v['enabled']); })
->then(function ($v) { return $v + ['enabled' => true]; })
->end()
->beforeNormalization()
->ifTrue(function ($v) { return \is_array($v) && !isset($v['resources']) && !isset($v['resource']); })
->then(function ($v) {
$e = $v['enabled'];
unset($v['enabled']);
@ -1093,7 +1097,19 @@ class Configuration implements ConfigurationInterface
->end()
->beforeNormalization()
->ifTrue(function ($v) { return \is_array($v) && array_keys($v) === range(0, \count($v) - 1); })
->then(function ($v) { return ['default' => $v]; })
->then(function ($v) {
$resources = [];
foreach ($v as $resource) {
$resources = array_merge_recursive(
$resources,
\is_array($resource) && isset($resource['name'])
? [$resource['name'] => $resource['value']]
: ['default' => $resource]
);
}
return $resources;
})
->end()
->prototype('array')
->beforeNormalization()->ifString()->then(function ($v) { return [$v]; })->end()

View File

@ -187,6 +187,69 @@ class ConfigurationTest extends TestCase
yield [$createPackageConfig($config), 'You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.'];
}
/**
* @dataProvider provideValidLockConfigurationTests
*/
public function testValidLockConfiguration($lockConfig, $processedConfig)
{
$processor = new Processor();
$configuration = new Configuration(true);
$config = $processor->processConfiguration($configuration, [
[
'lock' => $lockConfig,
],
]);
$this->assertArrayHasKey('lock', $config);
$this->assertEquals($processedConfig, $config['lock']);
}
public function provideValidLockConfigurationTests()
{
yield [null, ['enabled' => true, 'resources' => ['default' => [class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphore' : 'flock']]]];
yield ['flock', ['enabled' => true, 'resources' => ['default' => ['flock']]]];
yield [['flock', 'semaphore'], ['enabled' => true, 'resources' => ['default' => ['flock', 'semaphore']]]];
yield [['foo' => 'flock', 'bar' => 'semaphore'], ['enabled' => true, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
yield [['foo' => ['flock', 'semaphore'], 'bar' => 'semaphore'], ['enabled' => true, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
yield [['default' => 'flock'], ['enabled' => true, 'resources' => ['default' => ['flock']]]];
yield [['enabled' => false, 'flock'], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
yield [['enabled' => false, ['flock', 'semaphore']], ['enabled' => false, 'resources' => ['default' => ['flock', 'semaphore']]]];
yield [['enabled' => false, 'foo' => 'flock', 'bar' => 'semaphore'], ['enabled' => false, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
yield [['enabled' => false, 'foo' => ['flock', 'semaphore']], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore']]]];
yield [['enabled' => false, 'default' => 'flock'], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
yield [['resources' => 'flock'], ['enabled' => true, 'resources' => ['default' => ['flock']]]];
yield [['resources' => ['flock', 'semaphore']], ['enabled' => true, 'resources' => ['default' => ['flock', 'semaphore']]]];
yield [['resources' => ['foo' => 'flock', 'bar' => 'semaphore']], ['enabled' => true, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
yield [['resources' => ['foo' => ['flock', 'semaphore'], 'bar' => 'semaphore']], ['enabled' => true, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
yield [['resources' => ['default' => 'flock']], ['enabled' => true, 'resources' => ['default' => ['flock']]]];
yield [['enabled' => false, 'resources' => 'flock'], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
yield [['enabled' => false, 'resources' => ['flock', 'semaphore']], ['enabled' => false, 'resources' => ['default' => ['flock', 'semaphore']]]];
yield [['enabled' => false, 'resources' => ['foo' => 'flock', 'bar' => 'semaphore']], ['enabled' => false, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
yield [['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => 'semaphore']], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
yield [['enabled' => false, 'resources' => ['default' => 'flock']], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
// xml
yield [['resource' => ['flock']], ['enabled' => true, 'resources' => ['default' => ['flock']]]];
yield [['resource' => ['flock', ['name' => 'foo', 'value' => 'semaphore']]], ['enabled' => true, 'resources' => ['default' => ['flock'], 'foo' => ['semaphore']]]];
yield [['resource' => [['name' => 'foo', 'value' => 'flock']]], ['enabled' => true, 'resources' => ['foo' => ['flock']]]];
yield [['resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore']]], ['enabled' => true, 'resources' => ['foo' => ['flock', 'semaphore']]]];
yield [['resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => true, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
yield [['resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => true, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
yield [['enabled' => false, 'resource' => ['flock']], ['enabled' => false, 'resources' => ['default' => ['flock']]]];
yield [['enabled' => false, 'resource' => ['flock', ['name' => 'foo', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['default' => ['flock'], 'foo' => ['semaphore']]]];
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock']]], ['enabled' => false, 'resources' => ['foo' => ['flock']]]];
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore']]]];
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock'], 'bar' => ['semaphore']]]];
yield [['enabled' => false, 'resource' => [['name' => 'foo', 'value' => 'flock'], ['name' => 'foo', 'value' => 'semaphore'], ['name' => 'bar', 'value' => 'semaphore']]], ['enabled' => false, 'resources' => ['foo' => ['flock', 'semaphore'], 'bar' => ['semaphore']]]];
}
public function testItShowANiceMessageIfTwoMessengerBusesAreConfiguredButNoDefaultBus()
{
$expectedMessage = 'You must specify the "default_bus" if you define more than one bus.';

View File

@ -90,8 +90,10 @@ final class LockRegistry
while (true) {
try {
// race to get the lock in non-blocking mode
if (flock($lock, LOCK_EX | LOCK_NB)) {
$logger && $logger->info('Lock acquired, now computing item "{key}"', ['key' => $item->getKey()]);
$locked = flock($lock, LOCK_EX | LOCK_NB, $wouldBlock);
if ($locked || !$wouldBlock) {
$logger && $logger->info(sprintf('Lock %s, now computing item "{key}"', $locked ? 'acquired' : 'not supported'), ['key' => $item->getKey()]);
self::$lockedFiles[$key] = true;
$value = $callback($item, $save);

View File

@ -28,7 +28,7 @@ trait MemcachedTrait
'persistent_id' => null,
'username' => null,
'password' => null,
'serializer' => 'php',
\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_PHP,
];
private $marshaller;

View File

@ -63,7 +63,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
if (preg_match('/^([^a-z0-9_].*)?(.*[^a-zA-Z0-9_\-:].*)?$/D', $name, $matches)) {
if (isset($matches[1])) {
@trigger_error(sprintf('Using names for buttons that do not start with a letter, a digit, or an underscore is deprecated since Symfony 4.3 and will throw an exception in 5.0 ("%s" given).', $name), E_USER_DEPRECATED);
@trigger_error(sprintf('Using names for buttons that do not start with a lowercase letter, a digit, or an underscore is deprecated since Symfony 4.3 and will throw an exception in 5.0 ("%s" given).', $name), E_USER_DEPRECATED);
}
if (isset($matches[2])) {
@trigger_error(sprintf('Using names for buttons that do not contain only letters, digits, underscores ("_"), hyphens ("-") and colons (":") ("%s" given) is deprecated since Symfony 4.3 and will throw an exception in 5.0.', $name), E_USER_DEPRECATED);

View File

@ -18,7 +18,7 @@ CHANGELOG
* added a `symbol` option to the `PercentType` that allows to disable or customize the output of the percent character
* Using the `format` option of `DateType` and `DateTimeType` when the `html5` option is enabled is deprecated.
* Using names for buttons that do not start with a letter, a digit, or an underscore is deprecated and will lead to an
* Using names for buttons that do not start with a lowercase letter, a digit, or an underscore is deprecated and will lead to an
exception in 5.0.
* Using names for buttons that do not contain only letters, digits, underscores, hyphens, and colons is deprecated and
will lead to an exception in 5.0.

View File

@ -47,6 +47,14 @@ class ButtonBuilderTest extends TestCase
$this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder('button[]'));
}
/**
* @group legacy
*/
public function testNameStartingWithIllegalCharacters()
{
$this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder('Button'));
}
public function getInvalidNames()
{
return [

View File

@ -269,7 +269,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface
if ('POST' !== $method) {
$curlopts[CURLOPT_UPLOAD] = true;
}
} elseif ('' !== $body) {
} elseif ('' !== $body || 'POST' === $method) {
$curlopts[CURLOPT_POSTFIELDS] = $body;
}
@ -383,7 +383,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface
*/
private static function acceptPushForRequest(string $method, array $options, PushedResponse $pushedResponse): bool
{
if ($options['body'] || $method !== $pushedResponse->requestHeaders[':method'][0]) {
if ('' !== $options['body'] || $method !== $pushedResponse->requestHeaders[':method'][0]) {
return false;
}

View File

@ -133,15 +133,17 @@ final class CurlResponse implements ResponseInterface
if (\in_array($waitFor, ['headers', 'destruct'], true)) {
try {
self::stream([$response])->current();
foreach (self::stream([$response]) as $chunk) {
if ($chunk->isFirst()) {
break;
}
}
} catch (\Throwable $e) {
// Persist timeouts thrown during initialization
$response->info['error'] = $e->getMessage();
$response->close();
throw $e;
}
} elseif ('content' === $waitFor && ($response->multi->handlesActivity[$response->id][0] ?? null) instanceof FirstChunk) {
self::stream([$response])->current();
}
curl_setopt($ch, CURLOPT_HEADERFUNCTION, null);

View File

@ -67,7 +67,11 @@ final class NativeResponse implements ResponseInterface
}
if (null === $response->remaining) {
self::stream([$response])->current();
foreach (self::stream([$response]) as $chunk) {
if ($chunk->isFirst()) {
break;
}
}
}
};
}

View File

@ -29,7 +29,7 @@ class HandlerFailedException extends RuntimeException
1 === \count($exceptions)
? $firstFailure->getMessage()
: sprintf('%d handlers failed. First failure is: "%s"', \count($exceptions), $firstFailure->getMessage()),
$firstFailure->getCode(),
(int) $firstFailure->getCode(),
$firstFailure
);

View File

@ -0,0 +1,31 @@
<?php
namespace Symfony\Component\Messenger\Tests\Exception;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\HandlerFailedException;
class HandlerFailedExceptionTest extends TestCase
{
public function testThatStringErrorCodeConvertsToInteger()
{
$envelope = new Envelope(new \stdClass());
$exception = new class() extends \RuntimeException {
public function __construct()
{
$this->code = 'HY000';
$this->message = 'test';
// no to call parent constructor, it will fail with string error code
}
};
$handlerException = new HandlerFailedException($envelope, [$exception]);
$originalException = $handlerException->getNestedExceptions()[0];
$this->assertIsInt($handlerException->getCode(), 'Exception codes must converts to int');
$this->assertSame(0, $handlerException->getCode(), 'String code (HY000) converted to int must be 0');
$this->assertIsString($originalException->getCode(), 'Original exception code still with original type (string)');
$this->assertSame($exception->getCode(), $originalException->getCode(), 'Original exception code is not modified');
}
}

View File

@ -361,7 +361,7 @@ class Process implements \IteratorAggregate
* @param callable|null $callback A PHP callback to run whenever there is some
* output available on STDOUT or STDERR
*
* @return $this
* @return static
*
* @throws RuntimeException When process can't be launched
* @throws RuntimeException When process is already running

View File

@ -222,6 +222,150 @@
<source>Unsupported card type or invalid card number.</source>
<target>Dəstəklənməyən kart tipi və ya yanlış kart nömrəsi.</target>
</trans-unit>
<trans-unit id="59">
<source>This is not a valid International Bank Account Number (IBAN).</source>
<target>Bu dəyər doğru bir Beynəlxalq Bank Hesap Nömrəsi (IBAN) deyil.</target>
</trans-unit>
<trans-unit id="60">
<source>This value is not a valid ISBN-10.</source>
<target>Bu dəyər doğru bir ISBN-10 deyil.</target>
</trans-unit>
<trans-unit id="61">
<source>This value is not a valid ISBN-13.</source>
<target>Bu dəyər doğru bir ISBN-13 deyil.</target>
</trans-unit>
<trans-unit id="62">
<source>This value is neither a valid ISBN-10 nor a valid ISBN-13.</source>
<target>Bu dəyər doğru bir ISBN-10 və ya ISBN-13 deyil.</target>
</trans-unit>
<trans-unit id="63">
<source>This value is not a valid ISSN.</source>
<target>Bu dəyər doğru bir ISSN deyil.</target>
</trans-unit>
<trans-unit id="64">
<source>This value is not a valid currency.</source>
<target>Bu dəyər doğru bir valyuta deyil.</target>
</trans-unit>
<trans-unit id="65">
<source>This value should be equal to {{ compared_value }}.</source>
<target>Bu dəyər {{ compared_value }} ilə bərabər olmalıdır.</target>
</trans-unit>
<trans-unit id="66">
<source>This value should be greater than {{ compared_value }}.</source>
<target>Bu dəyər {{ compared_value }} dəyərindən büyük olmalıdır.</target>
</trans-unit>
<trans-unit id="67">
<source>This value should be greater than or equal to {{ compared_value }}.</source>
<target>Bu dəyər {{ compared_value }} ilə bərabər və ya daha böyük olmaldır.</target>
</trans-unit>
<trans-unit id="68">
<source>This value should be identical to {{ compared_value_type }} {{ compared_value }}.</source>
<target>Bu dəyər {{ compared_value_type }} {{ compared_value }} ilə eyni olmalıdır.</target>
</trans-unit>
<trans-unit id="69">
<source>This value should be less than {{ compared_value }}.</source>
<target>Bu dəyər {{ compared_value }} dəyərindən kiçik olmalıdır.</target>
</trans-unit>
<trans-unit id="70">
<source>This value should be less than or equal to {{ compared_value }}.</source>
<target>Bu dəyər {{ compared_value }} dəyərindən kiçik və ya bərabər olmalıdır.</target>
</trans-unit>
<trans-unit id="71">
<source>This value should not be equal to {{ compared_value }}.</source>
<target>Bu değer {{ compared_value }} ile eşit olmamalıdır.</target>
</trans-unit>
<trans-unit id="72">
<source>This value should not be identical to {{ compared_value_type }} {{ compared_value }}.</source>
<target>Bu dəyər {{ compared_value_type }} {{ compared_value }} ilə eyni olmamalıdır.</target>
</trans-unit>
<trans-unit id="73">
<source>The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}.</source>
<target>Şəkil nisbəti çox büyükdür ({{ ratio }}). İcazə verilən maksimum nisbət: {{ max_ratio }}.</target>
</trans-unit>
<trans-unit id="74">
<source>The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}.</source>
<target>Şəkil nisbəti çox balacadır ({{ ratio }}). İcazə verilən minimum nisbət: {{ min_ratio }}.</target>
</trans-unit>
<trans-unit id="75">
<source>The image is square ({{ width }}x{{ height }}px). Square images are not allowed.</source>
<target>Şəkil kvadratdır ({{ width }}x{{ height }}px). Kvadrat şəkillərə icazə verilmir.</target>
</trans-unit>
<trans-unit id="76">
<source>The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.</source>
<target>Şəkil albom rejimindədir ({{ width }}x{{ height }}px). Albom rejimli şəkillərə icazə verilmir.</target>
</trans-unit>
<trans-unit id="77">
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
<target>Şəkil portret rejimindədir ({{ width }}x{{ height }}px). Portret rejimli şəkillərə icazə verilmir.</target>
</trans-unit>
<trans-unit id="78">
<source>An empty file is not allowed.</source>
<target>Boş fayla icazə verilmir.</target>
</trans-unit>
<trans-unit id="79">
<source>The host could not be resolved.</source>
<target>Ünvan tapılmadı.</target>
</trans-unit>
<trans-unit id="80">
<source>This value does not match the expected {{ charset }} charset.</source>
<target>Bu dəyər gözlənilən {{ charset }} simvol cədvəli ilə uyğun gəlmir.</target>
</trans-unit>
<trans-unit id="81">
<source>This is not a valid Business Identifier Code (BIC).</source>
<target>Bu dəyər doğru bir Biznes Təyinedici Kodu (BIC) deyil.</target>
</trans-unit>
<trans-unit id="82">
<source>Error</source>
<target>Xəta</target>
</trans-unit>
<trans-unit id="83">
<source>This is not a valid UUID.</source>
<target>Bu dəyər doğru bir UUID deyil.</target>
</trans-unit>
<trans-unit id="84">
<source>This value should be a multiple of {{ compared_value }}.</source>
<target>Bu dəyər {{ compare_value }} dəyərinin bölənlərindən biri olmalıdır.</target>
</trans-unit>
<trans-unit id="85">
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
<target>Bu Biznes Təyinedici Kodu (BIC) {{ iban }} IBAN kodu ilə əlaqəli deyil.</target>
</trans-unit>
<trans-unit id="86">
<source>This value should be valid JSON.</source>
<target>Bu dəyər doğru bir JSON olmalıdır.</target>
</trans-unit>
<trans-unit id="87">
<source>This collection should contain only unique elements.</source>
<target>Bu kolleksiyada sadəcə unikal elementlər olmalıdır.</target>
</trans-unit>
<trans-unit id="88">
<source>This value should be positive.</source>
<target>Bu dəyər müsbət olmalıdır.</target>
</trans-unit>
<trans-unit id="89">
<source>This value should be either positive or zero.</source>
<target>Bu dəyər müsbət və ya sıfır olmalıdır.</target>
</trans-unit>
<trans-unit id="90">
<source>This value should be negative.</source>
<target>Bu dəyər mənfi olmaldır.</target>
</trans-unit>
<trans-unit id="91">
<source>This value should be either negative or zero.</source>
<target>Bu dəyər mənfi və ya sıfır olmaldır.</target>
</trans-unit>
<trans-unit id="92">
<source>This value is not a valid timezone.</source>
<target>Bu dəyər doğru bir zaman zolağı deyil.</target>
</trans-unit>
<trans-unit id="93">
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
<target>Bu parol data oğurluğunda tapıldığı üçün işlədilməməlidir. Zəhmət olmasa, başqa parol seçin.</target>
</trans-unit>
<trans-unit id="94">
<source>This value should be between {{ min }} and {{ max }}.</source>
<target>Bu dəyər {{ min }} və {{ max }} arasında olmaldır.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -45,6 +45,8 @@ switch ($vars['REQUEST_URI']) {
header('HTTP/1.1 103 Early Hints');
header('Link: </style.css>; rel=preload; as=style', false);
header('Link: </script.js>; rel=preload; as=script', false);
flush();
usleep(1000);
echo "HTTP/1.1 200 OK\r\n";
echo "Date: Fri, 26 May 2017 10:02:11 GMT\r\n";
echo "Content-Length: 13\r\n";