8000 Merge branch '4.4' into 5.3 · rtek/symfony@c4b1ec5 · GitHub
[go: up one dir, main page]

Skip to content

Commit c4b1ec5

Browse files
Merge branch '4.4' into 5.3
* 4.4: cs fix [Security][Validator] Add missing translations for Indonesian (id) Report mismatches between trans-unit id and source text via status script Do not add namespace argument to NullAdapter in CachePoolPass [FrameworkBundle] Update cache:clear help Fix ExecutionContextInterface::setParameter phpdoc example always close open stopwatch section after handling kernel.request events
2 parents ca203b6 + 50bcb22 commit c4b1ec5

File tree

14 files changed

+151
-36
lines changed

14 files changed

+151
-36
lines changed

.github/workflows/integration-tests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,13 @@ jobs:
180180
# docker run --rm -e COMPOSER_ROOT_VERSION -v $(pwd):/app -v $(which composer):/usr/local/bin/composer -v $(which vulcain):/usr/local/bin/vulcain -w /app php:8.0-alpine ./phpunit src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php --filter testHttp2Push
181181
# sudo rm -rf .phpunit
182182
# [ -d .phpunit.bak ] && mv .phpunit.bak .phpunit
183+
184+
- uses: marceloprado/has-changed-path@v1
185+
id: changed-translation-files
186+
with:
187+
paths: src/**/Resources/translations/*.xlf
188+
189+
- name: Check Translation Status
190+
if: steps.changed-translation-files.outputs.changed == 'true'
191+
run: |
192+
php src/Symfony/Component/Translation/Resources/bin/translation-status.php -v

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected function configure()
6161
])
6262
->setDescription(self::$defaultDescription)
6363
->setHelp(<<<'EOF'
64-
The <info>%command.name%</info> command clears the application cache for a given environment
64+
The <info>%command.name%</info> command clears and warms up the application cache for a given environment
6565
and debug mode:
6666
6767
<info>php %command.full_name% --env=dev</info>

src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Cache\Adapter\AbstractAdapter;
1515
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1616
use Symfony\Component\Cache\Adapter\ChainAdapter;
17+
use Symfony\Component\Cache\Adapter\NullAdapter;
1718
use Symfony\Component\Cache\Adapter\ParameterNormalizer;
1819
use Symfony\Component\Cache\Messenger\EarlyExpirationDispatcher;
1920
use Symfony\Component\DependencyInjection\ChildDefinition;
@@ -144,7 +145,7 @@ public function process(ContainerBuilder $container)
144145
$chainedPool->replaceArgument($i++, new Reference(static::getServiceProvider($container, $chainedTags[0]['provider'])));
145146
}
146147

147-
if (isset($tags[0]['namespace']) && ArrayAdapter::class !== $adapter->getClass()) {
148+
if (isset($tags[0]['namespace']) && !\in_array($adapter->getClass(), [ArrayAdapter::class, NullAdapter::class], true)) {
148149
$chainedPool->replaceArgument($i++, $tags[0]['namespace']);
149150
}
150151

@@ -180,7 +181,7 @@ public function process(ContainerBuilder $container)
180181
),
181182
]);
182183
$pool->addTag($this->reversibleTag);
183-
} elseif ('namespace' !== $attr || ArrayAdapter::class !== $class) {
184+
} elseif ('namespace' !== $attr || !\in_array($class, [ArrayAdapter::class, NullAdapter::class], true)) {
184185
$argument = $tags[0][$attr];
185186

186187
if ('default_lifetime' === $attr && !is_numeric($argument)) {

src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Cache\Adapter\ApcuAdapter;
1616
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1717
use Symfony\Component\Cache\Adapter\ChainAdapter;
18+
use Symfony\Component\Cache\Adapter\NullAdapter;
1819
use Symfony\Component\Cache\Adapter\RedisAdapter;
1920
use Symfony\Component\Cache\DependencyInjection\CachePoolPass;
2021
use Symfony\Component\DependencyInjection\ChildDefinition;
@@ -116,6 +117,23 @@ public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
116117
$this->assertCount(0, $container->getDefinition('app.cache_pool')->getArguments());
117118
}
118119

120+
public function testNamespaceArgumentIsNotReplacedIfNullAdapterIsUsed()
121+
{
122+
$container = new ContainerBuilder();
123+
$container->setParameter('kernel.container_class', 'app');
124+
$container->setParameter('kernel.project_dir', 'foo');
125+
126+
$container->register('cache.adapter.null', NullAdapter::class);
127+
128+
$cachePool = new ChildDefinition('cache.adapter.null');
129+
$cachePool->addTag('cache.pool');
130+
$container->setDefinition('app.cache_pool', $cachePool);
131+
132+
$this->cachePoolPass->process($container);
133+
134+
$this->assertCount(0, $container->getDefinition('app.cache_pool')->getArguments());
135+
}
136+
119137
public function testArgsAreReplaced()
120138
{
121139
$container = new ContainerBuilder();

src/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function offsetExists($offset): bool
3131

3232
/**
3333
* @param mixed $offset
34+
*
3435
* @return mixed
3536
*/
3637
#[\ReturnTypeWillChange]

src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ protected function beforeDispatch(string $eventName, object $event)
3030
{
3131
switch ($eventName) {
3232
case KernelEvents::REQUEST:
33+
$event->getRequest()->attributes->set('_stopwatch_token', substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
3334
$this->stopwatch->openSection();
3435
break;
3536
case KernelEvents::VIEW:
@@ -40,8 +41,8 @@ protected function beforeDispatch(string $eventName, object $event)
4041
}
4142
break;
4243
case KernelEvents::TERMINATE:
43-
$token = $event->getResponse()->headers->get('X-Debug-Token');
44-
if (null === $token) {
44+
$sectionId = $event->getRequest()->attributes->get('_stopwatch_token');
45+
if (null === $sectionId) {
4546
break;
4647
}
4748
// There is a very special case when using built-in AppCache class as kernel wrapper, in the case
@@ -50,7 +51,7 @@ protected function beforeDispatch(string $eventName, object $event)
5051
// is equal to the [A] debug token. Trying to reopen section with the [B] token throws an exception
5152
// which must be caught.
5253
try {
53-
$this->stopwatch->openSection($token);
54+
$this->stopwatch->openSection($sectionId);
5455
} catch (\LogicException $e) {
5556
}
5657
break;
@@ -67,21 +68,21 @@ protected function afterDispatch(string $eventName, object $event)
6768
$this->stopwatch->start('controller', 'section');
6869
break;
6970
case KernelEvents::RESPONSE:
70-
$token = $event->getResponse()->headers->get('X-Debug-Token');
71-
if (null === $token) {
71+
$sectionId = $event->getRequest()->attributes->get('_stopwatch_token');
72+
if (null === $sectionId) {
7273
break;
7374
}
74-
$this->stopwatch->stopSection($token);
75+
$this->stopwatch->stopSection($sectionId);
7576
break;
7677
case KernelEvents::TERMINATE:
7778
// In the special case described in the `preDispatch` method above, the `$token` section
7879
// does not exist, then closing it throws an exception which must be caught.
79-
$token = $event->getResponse()->headers->get('X-Debug-Token');
80-
if (null === $token) {
80+
$sectionId = $event->getRequest()->attributes->get('_stopwatch_token');
81+
if (null === $sectionId) {
8182
break;
8283
}
8384
try {
84-
$this->stopwatch->stopSection($token);
85+
$this->stopwatch->stopSection($sectionId);
8586
} catch (\LogicException $e) {
8687
}
8788
break;

src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ class TraceableEventDispatcherTest extends TestCase
2828
public function testStopwatchSections()
2929
{
3030
$dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch = new Stopwatch());
31-
$kernel = $this->getHttpKernel($dispatcher, function () { return new Response('', 200, ['X-Debug-Token' => '292e1e']); });
31+
$kernel = $this->getHttpKernel($dispatcher);
3232
$request = Request::create('/');
3333
$response = $kernel->handle($request);
3434
$kernel->terminate($request, $response);
3535

36-
$events = $stopwatch->getSectionEvents($response->headers->get('X-Debug-Token'));
36+
$events = $stopwatch->getSectionEvents($request->attributes->get('_stopwatch_token'));
3737
$this->assertEquals([
3838
'__section__',
3939
'kernel.request',
@@ -56,7 +56,7 @@ public function testStopwatchCheckControllerOnRequestEvent()
5656

5757
$dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch);
5858

59-
$kernel = $this->getHttpKernel($dispatcher, function () { return new Response(); });
59+
$kernel = $this->getHttpKernel($dispatcher);
6060
$request = Request::create('/');
6161
$kernel->handle($request);
6262
}
@@ -69,12 +69,12 @@ public function testStopwatchStopControllerOnRequestEvent()
6969
$stopwatch->expects($this->once())
7070
->method('isStarted')
7171
->willReturn(true);
72-
$stopwatch->expects($this->once())
72+
$stopwatch->expects($this->exactly(3))
7373
->method('stop');
7474

7575
$dispatcher = new TraceableEventDispatcher(new EventDispatcher(), $stopwatch);
7676

77-
$kernel = $this->getHttpKernel($dispatcher, function () { return new Response(); });
77+
$kernel = $this->getHttpKernel($dispatcher);
7878
$request = Request::create('/');
7979
$kernel->handle($request);
8080
}
@@ -110,10 +110,12 @@ public function testListenerCanRemoveItselfWhenExecuted()
110110
$this->assertCount(1, $eventDispatcher->getListeners('foo'), 'expected listener1 to be removed');
111111
}
112112

113-
protected function getHttpKernel($dispatcher, $controller)
113+
protected function getHttpKernel($dispatcher)
114114
{
115115
$controllerResolver = $this->createMock(ControllerResolverInterface::class);
116-
$controllerResolver->expects($this->once())->method('getController')->willReturn($controller);
116+
$controllerResolver->expects($this->once())->method('getController')->willReturn(function () {
117+
return new Response();
118+
});
117119
$argumentResolver = $this->createMock(ArgumentResolverInterface::class);
118120
$argumentResolver->expects($this->once())->method('getArguments')->willReturn([]);
119121

src/Symfony/Component/Intl/Data/Util/ArrayAccessibleResourceBundle.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function offsetExists($offset): bool
4646

4747
/**
4848
* @param mixed $offset
49+
*
4950
* @return mixed
5051
*/
5152
#[\ReturnTypeWillChange]

src/Symfony/Component/PropertyAccess/Tests/Fixtures/NonTraversableArrayObject.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function offsetExists($offset): bool
3131

3232
/**
3333
* @param mixed $offset
34+
*
3435
* @return mixed
3536
*/
3637
#[\ReturnTypeWillChange]

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,19 @@
6464
</trans-unit>
6565
<trans-unit id="17">
6666
<source>Too many failed login attempts, please try again later.</source>
67-
<target>Terlalu banyak percobaan login yang salah, Silahkan coba lagi nanti.</target>
67+
<target>Terlalu banyak percobaan login yang salah, silahkan coba lagi nanti.</target>
6868
</trans-unit>
6969
<trans-unit id="18">
7070
<source>Invalid or expired login link.</source>
71-
<target>Link login salah atau sudah kadaluwarsa.</target>
71+
<target>Link login salah atau sudah kedaluwarsa.</target>
72+
</trans-unit>
73+
<trans-unit id="19">
74+
<source>Too many failed login attempts, please try again in %minutes% minute.</source>
75+
<target>Terlalu banyak percobaan login yang salah, silahkan coba lagi dalam %minutes% menit.</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>Terlalu banyak percobaan login yang salah, silahkan coba lagi dalam %minutes% menit.</target>
7280
</trans-unit>
7381
</body>
7482
</file>

0 commit comments

Comments
 (0)
0