Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0360b09

Browse filesBrowse files
committed
Merge branch '5.3' into 5.4
* 5.3: cs fix [Security][Validator] Add missing translations for Indonesian (id) [Notifier] fix typo firebase Add trailing Line return if last line is non empty 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 Don't pass null to preg_replace() Don't pass null to strpos() Remove preloading of unused class [Messenger] Separate unit tests from integration tests Fix ServiceLocator indexing when service is decorated always close open stopwatch section after handling kernel.request events
2 parents 22ce8f6 + c4b1ec5 commit 0360b09
Copy full SHA for 0360b09

File tree

Expand file treeCollapse file tree

22 files changed

+329
-179
lines changed
Filter options
Expand file treeCollapse file tree

22 files changed

+329
-179
lines changed

‎.github/workflows/integration-tests.yml

Copy file name to clipboardExpand all lines: .github/workflows/integration-tests.yml
+10Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php
+3-2Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php
+18Lines 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/Console/Helper/Helper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/Helper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public static function removeDecoration(OutputFormatterInterface $formatter, ?st
170170
// remove <...> formatting
171171
$string = $formatter->format($string ?? '');
172172
// remove already formatted characters
173-
$string = preg_replace("/\033\[[^m]*m/", '', $string);
173+
$string = preg_replace("/\033\[[^m]*m/", '', $string ?? '');
174174
$formatter->setDecorated($isDecorated);
175175

176176
return $string;

‎src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public function __construct()
6262
new AutowireRequiredMethodsPass(),
6363
new AutowireRequiredPropertiesPass(),
6464
new ResolveBindingsPass(),
65-
new DecoratorServicePass(),
6665
new CheckDefinitionValidityPass(),
6766
new AutowirePass(false),
6867
new ServiceLocatorTagPass(),
68+
new DecoratorServicePass(),
6969
new ResolveTaggedIteratorArgumentPass(),
7070
new ResolveServiceSubscribersPass(),
7171
new ResolveReferencesToAliasesPass(),

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php
+55Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
16+
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
17+
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
1618
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
1719
use Symfony\Component\DependencyInjection\ContainerBuilder;
20+
use Symfony\Component\DependencyInjection\Definition;
1821
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1922
use Symfony\Component\DependencyInjection\Reference;
2023
use Symfony\Component\DependencyInjection\ServiceLocator;
@@ -143,4 +146,56 @@ public function testBindingsAreCopied()
143146
$this->assertSame(['foo'], array_keys($locator->getBindings()));
144147
$this->assertInstanceOf(BoundArgument::class, $locator->getBindings()['foo']);
145148
}
149+
150+
public function testIndexedByServiceIdWithDecoration()
151+
{
152+
$container = new ContainerBuilder();
153+
154+
$locator = new Definition(Locator::class);
155+
$locator->setPublic(true);
156+
$locator->addArgument(new ServiceLocatorArgument(new TaggedIteratorArgument('test_tag', null, null, true)));
157+
158+
$container->setDefinition(Locator::class, $locator);
159+
160+
$service = new Definition(Service::class);
161+
$service->setPublic(true);
162+
$service->addTag('test_tag');
163+
164+
$container->setDefinition(Service::class, $service);
165+
166+
$decorated = new Definition(Decorated::class);
167+
$decorated->setPublic(true);
168+
$decorated->setDecoratedService(Service::class);
169+
170+
$container->setDefinition(Decorated::class, $decorated);
171+
172+
$container->compile();
173+
174+
/** @var ServiceLocator $locator */
175+
$locator = $container->get(Locator::class)->locator;
176+
static::assertTrue($locator->has(Service::class));
177+
static::assertFalse($locator->has(Decorated::class));
178+
static::assertInstanceOf(Decorated::class, $locator->get(Service::class));
179+
}
180+
}
181+
182+
class Locator
183+
{
184+
/**
185+
* @var ServiceLocator
186+
*/
187+
public $locator;
188+
189+
public function __construct(ServiceLocator $locator)
190+
{
191+
$this->locator = $locator;
192+
}
193+
}
194+
195+
class Service
196+
{
197+
}
198+
199+
class DecoratedService
200+
{
146201
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php
+1Lines 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/HttpFoundation/Request.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Request.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ public static function getMimeTypes(string $format)
13351335
public function getFormat(?string $mimeType)
13361336
{
13371337
$canonicalMimeType = null;
1338-
if (false !== $pos = strpos($mimeType, ';')) {
1338+
if ($mimeType && false !== $pos = strpos($mimeType, ';')) {
13391339
$canonicalMimeType = trim(substr($mimeType, 0, $pos));
13401340
}
13411341

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php
+10-9Lines 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/HttpKernel.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/HttpKernel.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
3434

3535
// Help opcache.preload discover always-needed symbols
36-
class_exists(LegacyEventDispatcherProxy::class);
3736
class_exists(ControllerArgumentsEvent::class);
3837
class_exists(ControllerEvent::class);
3938
class_exists(ExceptionEvent::class);

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php
+9-7Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Data/Util/ArrayAccessibleResourceBundle.php
+1Lines 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]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.