Skip to content

Commit 6a8838a

Browse files
Merge branch '6.4' into 7.0
* 6.4: [TwigBridge] foundation 5 layout: use form_label_content block for checkbox and radio labels [TwigBridge] Fix compat with Twig v3.9 [Cache] Sync the Redis proxies with upstream [Doctrine Messenger] Fix support for pgsql + pgbouncer. [Mailer] Simplify fix Do not produce notice/warning when consuming from multiple transports and explicitly listed queues [FrameworkBundle] Check if the _route attribute exists on the request [Scheduler] fix documentation link [PropertyAccess] Fixes getValue() on an unitialized object property on a lazy ghost [HttpClient] Make retry strategy work again AssetMapper: Remove 'auto-generated' info [Mailer] Fix signed emails breaking the profiler [Mailer] [Mailgun] Fix expecting payload without tags or user variables [Validator] Update Spanish (es) translations Fix fetching data in `W3CReferenceTest` on AppVeyor Fix SQS visibility_timeout type [VarDumper] Fix serialization of stubs with null or uninitialized values
2 parents 4bdda51 + e8bb1d3 commit 6a8838a

File tree

3 files changed

+68
-2
lines changed

3 files changed

+68
-2
lines changed

DataCollector/RouterDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function guessRoute(Request $request, mixed $controller): string
2828
$controller = $controller[0];
2929
}
3030

31-
if ($controller instanceof RedirectController) {
31+
if ($controller instanceof RedirectController && $request->attributes->has('_route')) {
3232
return $request->attributes->get('_route');
3333
}
3434

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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\Bundle\FrameworkBundle\Tests\DataCollector;
13+
14+
use Symfony\Bundle\FrameworkBundle\Controller\RedirectController;
15+
use Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector;
16+
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
17+
use Symfony\Component\HttpFoundation\RedirectResponse;
18+
use Symfony\Component\HttpFoundation\Request;
19+
use Symfony\Component\HttpKernel\Event\ControllerEvent;
20+
use Symfony\Component\HttpKernel\KernelInterface;
21+
22+
class RouterDataCollectorTest extends TestCase
23+
{
24+
public function testRouteRedirectControllerNoRouteAtrribute()
25+
{
26+
$collector = new RouterDataCollector();
27+
28+
$request = Request::create('http://test.com/foo?bar=baz');
29+
$response = new RedirectResponse('http://test.com/redirect');
30+
31+
$event = $this->createControllerEvent($request);
32+
33+
$collector->onKernelController($event);
34+
$collector->collect($request, $response);
35+
36+
$this->assertTrue($collector->getRedirect());
37+
$this->assertEquals('http://test.com/redirect', $collector->getTargetUrl());
38+
$this->assertEquals('n/a', $collector->getTargetRoute());
39+
}
40+
41+
public function testRouteRedirectControllerWithRouteAttribute()
42+
{
43+
$collector = new RouterDataCollector();
44+
45+
$request = Request::create('http://test.com/foo?bar=baz');
46+
$request->attributes->set('_route', 'current-route');
47+
48+
$response = new RedirectResponse('http://test.com/redirect');
49+
50+
$event = $this->createControllerEvent($request);
51+
52+
$collector->onKernelController($event);
53+
$collector->collect($request, $response);
54+
55+
$this->assertTrue($collector->getRedirect());
56+
$this->assertEquals('http://test.com/redirect', $collector->getTargetUrl());
57+
$this->assertEquals('current-route', $collector->getTargetRoute());
58+
}
59+
60+
protected function createControllerEvent(Request $request): ControllerEvent
61+
{
62+
$kernel = $this->createMock(KernelInterface::class);
63+
64+
return new ControllerEvent($kernel, new RedirectController(), $request, null);
65+
}
66+
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"symfony/uid": "^6.4|^7.0",
7272
"symfony/web-link": "^6.4|^7.0",
7373
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
74-
"twig/twig": "~3.8.0"
74+
"twig/twig": "^3.0.4"
7575
},
7676
"conflict": {
7777
"doctrine/persistence": "<1.3",

0 commit comments

Comments
 (0)