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 83b53f4

Browse filesBrowse files
committed
feature #17611 [HttpKernel] Deprecate passing objects as URI attributes to the ESI and SSI renderers (jakzal)
This PR was merged into the 3.1-dev branch. Discussion ---------- [HttpKernel] Deprecate passing objects as URI attributes to the ESI and SSI renderers | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #15056 | License | MIT | Doc PR | - Commits ------- a38d96e [HttpKernel] Deprecate passing objects as URI attributes to the ESI and SSI renderers
2 parents 8f3c06b + a38d96e commit 83b53f4
Copy full SHA for 83b53f4

File tree

4 files changed

+54
-0
lines changed
Filter options

4 files changed

+54
-0
lines changed

‎UPGRADE-3.1.md

Copy file name to clipboardExpand all lines: UPGRADE-3.1.md
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ Form
1616
* The `choices_as_values` option of the `ChoiceType` has been deprecated and
1717
will be removed in Symfony 4.0.
1818

19+
HttpKernel
20+
----------
21+
22+
* Passing objects as URI attributes to the ESI and SSI renderers has been
23+
deprecated and will be removed in Symfony 4.0. The inline fragment
24+
renderer should be used with object attributes.
25+
1926
Serializer
2027
----------
2128

‎src/Symfony/Component/HttpKernel/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
CHANGELOG
22
=========
33

4+
3.1.0
5+
-----
6+
* deprecated passing objects as URI attributes to the ESI and SSI renderers
7+
48
3.0.0
59
-----
610

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Fragment/AbstractSurrogateFragmentRenderer.php
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ public function __construct(SurrogateInterface $surrogate = null, FragmentRender
6464
public function render($uri, Request $request, array $options = array())
6565
{
6666
if (!$this->surrogate || !$this->surrogate->hasSurrogateCapability($request)) {
67+
if ($uri instanceof ControllerReference && $this->containsNonScalars($uri->attributes)) {
68+
@trigger_error('Passing objects as part of URI attributes to the ESI and SSI rendering strategies is deprecated since version 3.1, and will be removed in 4.0. Use a different rendering strategy or pass scalar values.', E_USER_DEPRECATED);
69+
}
70+
6771
return $this->inlineStrategy->render($uri, $request, $options);
6872
}
6973

@@ -92,4 +96,17 @@ private function generateSignedFragmentUri($uri, Request $request)
9296

9397
return substr($fragmentUri, strlen($request->getSchemeAndHttpHost()));
9498
}
99+
100+
private function containsNonScalars(array $values)
101+
{
102+
foreach ($values as $value) {
103+
if (is_array($value) && $this->containsNonScalars($value)) {
104+
return true;
105+
} elseif (!is_scalar($value) && null !== $value) {
106+
return true;
107+
}
108+
}
109+
110+
return false;
111+
}
95112
}

‎src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,32 @@ public function testRenderFallbackToInlineStrategyIfEsiNotSupported()
2525
$strategy->render('/', Request::create('/'));
2626
}
2727

28+
/**
29+
* @group legacy
30+
*/
31+
public function testRenderFallbackWithObjectAttributesIsDeprecated()
32+
{
33+
$deprecations = array();
34+
set_error_handler(function ($type, $message) use (&$deprecations) {
35+
if (E_USER_DEPRECATED === $type) {
36+
$deprecations[] = $message;
37+
}
38+
});
39+
40+
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo'));
41+
42+
$request = Request::create('/');
43+
44+
$reference = new ControllerReference('main_controller', array('foo' => array('a' => array(), 'b' => new \stdClass())), array());
45+
46+
$strategy->render($reference, $request);
47+
48+
$this->assertCount(1, $deprecations);
49+
$this->assertContains('Passing objects as part of URI attributes to the ESI and SSI rendering strategies is deprecated', $deprecations[0]);
50+
51+
restore_error_handler();
52+
}
53+
2854
public function testRender()
2955
{
3056
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy());

0 commit comments

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