Skip to content

Commit b33bd44

Browse files
committed
Merge branch '4.4' into 5.3
* 4.4: [HttpClient] Don't ignore errors from curl_multi_exec() [HttpClient] Double check if handle is complete CI for macOS [DependencyInjection] Resolve ChildDefinition in AbstractRecursivePass [Process] fixed uppercase ARGC and ARGV should also be skipped [FrameworkBundle] Fix cache pool configuration with one adapter and one provider Missing translations for Belarusian (be) symfony#41032
2 parents 3b6cc05 + bf82d54 commit b33bd44

File tree

8 files changed

+204
-21
lines changed

8 files changed

+204
-21
lines changed

.github/workflows/unit-tests.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212

1313
tests:
1414
name: Tests
15-
runs-on: Ubuntu-20.04
1615

1716
env:
1817
extensions: amqp,apcu,igbinary,intl,mbstring,memcached,redis-5.3.4
@@ -21,15 +20,24 @@ jobs:
2120
matrix:
2221
include:
2322
- php: '7.2'
23+
os: ubuntu-20.04
2424
- php: '7.4'
25+
os: ubuntu-20.04
26+
- php: '8.0'
27+
os: macos-11
2528
- php: '8.0'
2629
mode: high-deps
30+
os: ubuntu-20.04
2731
- php: '8.1'
2832
mode: low-deps
33+
os: ubuntu-20.04
2934
- php: '8.2'
3035
mode: experimental
36+
os: ubuntu-20.04
3137
fail-fast: false
3238

39+
runs-on: "${{ matrix.os }}"
40+
3341
steps:
3442
- name: Checkout
3543
uses: actions/checkout@v2
@@ -50,6 +58,11 @@ jobs:
5058
extensions: "${{ env.extensions }}"
5159
tools: flex
5260

61+
- name: Install Homebrew packages
62+
if: "matrix.os == 'macos-11'"
63+
run: |
64+
brew install parallel
65+
5366
- name: Configure environment
5467
run: |
5568
git config --global user.email ""
@@ -61,11 +74,11 @@ jobs:
6174
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
6275
6376
echo COLUMNS=120 >> $GITHUB_ENV
64-
echo PHPUNIT="$(readlink -f ./phpunit) --exclude-group tty,benchmark,intl-data" >> $GITHUB_ENV
77+
echo PHPUNIT="$(pwd)/phpunit --exclude-group tty,benchmark,intl-data" >> $GITHUB_ENV
6578
echo COMPOSER_UP='composer update --no-progress --ansi' >> $GITHUB_ENV
6679
6780
SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V)
68-
SYMFONY_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | grep -P -o '[0-9]+\.[0-9]+')
81+
SYMFONY_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | cut -d "'" -f2 | cut -d '.' -f 1-2)
6982
SYMFONY_FEATURE_BRANCH=$(curl -s https://raw.githubusercontent.com/symfony/recipes/flex/main/index.json | jq -r '.versions."dev-name"')
7083
7184
# Install the phpunit-bridge from a PR if required
@@ -111,9 +124,9 @@ jobs:
111124
112125
# Skip the phpunit-bridge on bugfix-branches when not in *-deps mode
113126
if [[ ! "${{ matrix.mode }}" = *-deps && $SYMFONY_VERSION != $SYMFONY_FEATURE_BRANCH ]]; then
114-
echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -not -wholename '*/Bridge/PhpUnit/*' -printf '%h ') >> $GITHUB_ENV
127+
echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -not -wholename '*/Bridge/PhpUnit/*' | xargs -I{} dirname {}) >> $GITHUB_ENV
115128
else
116-
echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h ') >> $GITHUB_ENV
129+
echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist | xargs -I{} dirname {}) >> $GITHUB_ENV
117130
fi
118131
119132
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one
@@ -135,7 +148,7 @@ jobs:
135148
echo "::endgroup::"
136149
137150
- name: Patch return types
138-
if: "matrix.php == '8.1' && ! matrix.mode"
151+
if: "matrix.php == '8.1' && ! matrix.mode && matrix.os == 'ubuntu-20.04'"
139152
run: |
140153
sed -i 's/"\*\*\/Tests\/"//' composer.json
141154
composer install -q --optimize-autoloader

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,13 +1052,14 @@ private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBe
10521052
->prototype('array')
10531053
->fixXmlConfig('adapter')
10541054
->beforeNormalization()
1055-
->ifTrue(function ($v) { return (isset($v['adapters']) || \is_array($v['adapter'] ?? null)) && isset($v['provider']); })
1056-
->thenInvalid('Pool cannot have a "provider" while "adapter" is set to a map')
1055+
->ifTrue(function ($v) { return isset($v['provider']) && \is_array($v['adapters'] ?? $v['adapter'] ?? null) && 1 < \count($v['adapters'] ?? $v['adapter']); })
1056+
->thenInvalid('Pool cannot have a "provider" while more than one adapter is defined')
10571057
->end()
10581058
->children()
10591059
->arrayNode('adapters')
10601060
->performNoDeepMerging()
10611061
->info('One or more adapters to chain for creating the pool, defaults to "cache.app".')
1062+
->beforeNormalization()->castToArray()->end()
10621063
->beforeNormalization()
10631064
->always()->then(function ($values) {
10641065
if ([0] === array_keys($values) && \is_array($values[0])) {

src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
15+
use Symfony\Component\DependencyInjection\ChildDefinition;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Definition;
1718
use Symfony\Component\DependencyInjection\Exception\LogicException;
@@ -128,25 +129,35 @@ protected function getConstructor(Definition $definition, bool $required)
128129

129130
if ($factory) {
130131
[$class, $method] = $factory;
132+
133+
if ('__construct' === $method) {
134+
throw new RuntimeException(sprintf('Invalid service "%s": "__construct()" cannot be used as a factory method.', $this->currentId));
135+
}
136+
131137
if ($class instanceof Reference) {
132-
$class = $this->container->findDefinition((string) $class)->getClass();
138+
$factoryDefinition = $this->container->findDefinition((string) $class);
139+
while ((null === $class = $factoryDefinition->getClass()) && $factoryDefinition instanceof ChildDefinition) {
140+
$factoryDefinition = $this->container->findDefinition($factoryDefinition->getParent());
141+
}
133142
} elseif ($class instanceof Definition) {
134143
$class = $class->getClass();
135144
} elseif (null === $class) {
136145
$class = $definition->getClass();
137146
}
138147

139-
if ('__construct' === $method) {
140-
throw new RuntimeException(sprintf('Invalid service "%s": "__construct()" cannot be used as a factory method.', $this->currentId));
141-
}
142-
143148
return $this->getReflectionMethod(new Definition($class), $method);
144149
}
145150

146-
$class = $definition->getClass();
151+
while ((null === $class = $definition->getClass()) && $definition instanceof ChildDefinition) {
152+
$definition = $this->container->findDefinition($definition->getParent());
153+
}
147154

148155
try {
149156
if (!$r = $this->container->getReflectionClass($class)) {
157+
if (null === $class) {
158+
throw new RuntimeException(sprintf('Invalid service "%s": the class is not set.', $this->currentId));
159+
}
160+
150161
throw new RuntimeException(sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
151162
}
152163
} catch (\ReflectionException $e) {
@@ -174,7 +185,11 @@ protected function getReflectionMethod(Definition $definition, string $method)
174185
return $this->getConstructor($definition, true);
175186
}
176187

177-
if (!$class = $definition->getClass()) {
188+
while ((null === $class = $definition->getClass()) && $definition instanceof ChildDefinition) {
189+
$definition = $this->container->findDefinition($definition->getParent());
190+
}
191+
192+
if (null === $class) {
178193
throw new RuntimeException(sprintf('Invalid service "%s": the class is not set.', $this->currentId));
179194
}
180195

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\DependencyInjection\ChildDefinition;
16+
use Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass;
17+
use Symfony\Component\DependencyInjection\ContainerBuilder;
18+
use Symfony\Component\DependencyInjection\Definition;
19+
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
20+
use Symfony\Component\DependencyInjection\Reference;
21+
use Symfony\Component\DependencyInjection\Tests\Fixtures\Bar;
22+
use Symfony\Component\DependencyInjection\Tests\Fixtures\FactoryDummy;
23+
24+
class AbstractRecursivePassTest extends TestCase
25+
{
26+
public function testGetConstructorResolvesFactoryChildDefinitionsClass()
27+
{
28+
$container = new ContainerBuilder();
29+
$container->setParameter('factory_dummy_class', FactoryDummy::class);
30+
$container
31+
->register('parent', '%factory_dummy_class%')
32+
->setAbstract(true);
33+
$container->setDefinition('child', new ChildDefinition('parent'));
34+
$container
35+
->register('foo', \stdClass::class)
36+
->setFactory([new Reference('child'), 'createFactory']);
37+
38+
$pass = new class() extends AbstractRecursivePass {
39+
public $actual;
40+
41+
protected function processValue($value, $isRoot = false)
42+
{
43+
if ($value instanceof Definition && 'foo' === $this->currentId) {
44+
$this->actual = $this->getConstructor($value, true);
45+
}
46+
47+
return parent::processValue($value, $isRoot);
48+
}
49+
};
50+
$pass->process($container);
51+
52+
$this->assertInstanceOf(\ReflectionMethod::class, $pass->actual);
53+
$this->assertSame(FactoryDummy::class, $pass->actual->class);
54+
}
55+
56+
public function testGetConstructorResolvesChildDefinitionsClass()
57+
{
58+
$container = new ContainerBuilder();
59+
$container
60+
->register('parent', Bar::class)
61+
->setAbstract(true);
62+
$container->setDefinition('foo', new ChildDefinition('parent'));
63+
64+
$pass = new class() extends AbstractRecursivePass {
65+
public $actual;
66+
67+
protected function processValue($value, $isRoot = false)
68+
{
69+
if ($value instanceof Definition && 'foo' === $this->currentId) {
70+
$this->actual = $this->getConstructor($value, true);
71+
}
72+
73+
return parent::processValue($value, $isRoot);
74+
}
75+
};
76+
$pass->process($container);
77+
78+
$this->assertInstanceOf(\ReflectionMethod::class, $pass->actual);
79+
$this->assertSame(Bar::class, $pass->actual->class);
80+
}
81+
82+
public function testGetReflectionMethodResolvesChildDefinitionsClass()
83+
{
84+
$container = new ContainerBuilder();
85+
$container
86+
->register('parent', Bar::class)
87+
->setAbstract(true);
88+
$container->setDefinition('foo', new ChildDefinition('parent'));
89+
90+
$pass = new class() extends AbstractRecursivePass {
91+
public $actual;
92+
93+
protected function processValue($value, $isRoot = false)
94+
{
95+
if ($value instanceof Definition && 'foo' === $this->currentId) {
96+
$this->actual = $this->getReflectionMethod($value, 'create');
97+
}
98+
99+
return parent::processValue($value, $isRoot);
100+
}
101+
};
102+
$pass->process($container);
103+
104+
$this->assertInstanceOf(\ReflectionMethod::class, $pass->actual);
105+
$this->assertSame(Bar::class, $pass->actual->class);
106+
}
107+
108+
public function testGetConstructorDefinitionNoClass()
109+
{
110+
$this->expectException(RuntimeException::class);
111+
$this->expectExceptionMessage('Invalid service "foo": the class is not set.');
112+
113+
$container = new ContainerBuilder();
114+
$container->register('foo');
115+
116+
(new class() extends AbstractRecursivePass {
117+
protected function processValue($value, $isRoot = false)
118+
{
119+
if ($value instanceof Definition && 'foo' === $this->currentId) {
120+
$this->getConstructor($value, true);
121+
}
122+
123+
return parent::processValue($value, $isRoot);
124+
}
125+
})->process($container);
126+
}
127+
}

src/Symfony/Component/HttpClient/Response/CurlResponse.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,16 @@ private static function perform(ClientState $multi, array &$responses = null): v
297297
self::$performing = true;
298298
++$multi->execCounter;
299299
$active = 0;
300-
while (\CURLM_CALL_MULTI_PERFORM === curl_multi_exec($multi->handle, $active));
300+
while (\CURLM_CALL_MULTI_PERFORM === ($err = curl_multi_exec($multi->handle, $active)));
301+
302+
if (\CURLM_OK !== $err) {
303+
throw new TransportException(curl_multi_strerror($err));
304+
}
301305

302306
while ($info = curl_multi_info_read($multi->handle)) {
307+
if (\CURLMSG_DONE !== $info['msg']) {
308+
continue;
309+
}
303310
$result = $info['result'];
304311
$id = (int) $ch = $info['handle'];
305312
$waitFor = @curl_getinfo($ch, \CURLINFO_PRIVATE) ?: '_0';

src/Symfony/Component/Process/Process.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public function start(callable $callback = null, array $env = [])
338338

339339
$envPairs = [];
340340
foreach ($env as $k => $v) {
341-
if (false !== $v && 'argc' !== $k && 'argv' !== $k) {
341+
if (false !== $v && false === \in_array($k, ['argc', 'argv', 'ARGC', 'ARGV'], true)) {
342342
$envPairs[] = $k.'='.$v;
343343
}
344344
}
@@ -971,8 +971,6 @@ public function addErrorOutput(string $line)
971971

972972
/**
973973
* Gets the last output time in seconds.
974-
*
975-
* @return float|null The last output time in seconds or null if it isn't started
976974
*/
977975
public function getLastOutputTime(): ?float
978976
{
@@ -1491,8 +1489,6 @@ private function resetProcessData()
14911489
* @param int $signal A valid POSIX signal (see https://php.net/pcntl.constants)
14921490
* @param bool $throwException Whether to throw exception in case signal failed
14931491
*
1494-
* @return bool True if the signal was sent successfully, false otherwise
1495-
*
14961492
* @throws LogicException In case the process is not running
14971493
* @throws RuntimeException In case --enable-sigchild is activated and the process can't be killed
14981494
* @throws RuntimeException In case of failure

src/Symfony/Component/Security/Core/Resources/translations/security.be.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@
7070
<source>Invalid or expired login link.</source>
7171
<target>Спасылка для ўваходу несапраўдная або пратэрмінаваная.</target>
7272
</trans-unit>
73+
<trans-unit id="19">
74+
<source>Too many failed login attempts, please try again in %minutes% minute.</source>
75+
<target>Занадта шмат няўдалых спроб уваходу ў сістэму, паспрабуйце спробу праз %minutes% хвіліну.</target>
76+
</trans-unit>
77+
<trans-unit id="20">
78+
<source>Too many failed login attempts, please try again in %minutes% minutes.</source>
79+
<target>Занадта шмат няўдалых спроб уваходу ў сістэму, паспрабуйце спробу праз %minutes% хвілін.</target>
80+
</trans-unit>
7381
</body>
7482
</file>
7583
</xliff>

src/Symfony/Component/Validator/Resources/translations/validators.be.xlf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,22 @@
386386
<source>This value is not a valid International Securities Identification Number (ISIN).</source>
387387
<target>Значэнне не з'яўляецца карэктным міжнародным ідэнтыфікацыйным нумарам каштоўных папер (ISIN).</target>
388388
</trans-unit>
389+
<trans-unit id="100">
390+
<source>This value should be a valid expression.</source>
391+
<target>Значэнне не з'яўляецца сапраўдным выразам.</target>
392+
</trans-unit>
393+
<trans-unit id="101">
394+
<source>This value is not a valid CSS color.</source>
395+
<target>Значэнне не з'яўляецца дапушчальным колерам CSS.</target>
396+
</trans-unit>
397+
<trans-unit id="102">
398+
<source>This value is not a valid CIDR notation.</source>
399+
<target>Значэнне не з'яўляецца сапраўднай натацыяй CIDR.</target>
400+
</trans-unit>
401+
<trans-unit id="103">
402+
<source>The value of the netmask should be between {{ min }} and {{ max }}.</source>
403+
<target>Значэнне сеткавай маскі павінна быць ад {{min}} да {{max}}.</target>
404+
</trans-unit>
389405
</body>
390406
</file>
391407
</xliff>

0 commit comments

Comments
 (0)