Skip to content

Commit 1984b96

Browse files
minor symfony#52501 [HttpKernel] Check controllers are allowed when using the fallback surrogate strategy (nicolas-grekas)
This PR was merged into the 6.4 branch. Discussion ---------- [HttpKernel] Check controllers are allowed when using the fallback surrogate strategy | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT A good idea suggested by `@stof` to help spot not allowed controllers before they hit production. Commits ------- 86898a6 [HttpKernel] Check controllers are allowed when using the fallback surrogate strategy
2 parents 132d8e4 + 86898a6 commit 1984b96

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public function __construct(?SurrogateInterface $surrogate, FragmentRendererInte
5959
public function render(string|ControllerReference $uri, Request $request, array $options = []): Response
6060
{
6161
if (!$this->surrogate || !$this->surrogate->hasSurrogateCapability($request)) {
62+
$request->attributes->set('_check_controller_is_allowed', -1); // @deprecated, switch to true in Symfony 7
63+
6264
if ($uri instanceof ControllerReference && $this->containsNonScalars($uri->attributes)) {
6365
throw new \InvalidArgumentException('Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is not supported. Use a different rendering strategy or pass scalar values.');
6466
}

src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ protected function createSubRequest(string $uri, Request $request)
133133
if ($request->attributes->has('_stateless')) {
134134
$subRequest->attributes->set('_stateless', $request->attributes->get('_stateless'));
135135
}
136+
if ($request->attributes->has('_check_controller_is_allowed')) {
137+
$subRequest->attributes->set('_check_controller_is_allowed', $request->attributes->get('_check_controller_is_allowed'));
138+
}
136139

137140
return $subRequest;
138141
}

0 commit comments

Comments
 (0)