File tree Expand file tree Collapse file tree 4 files changed +62
-0
lines changed
Filter options
src/Symfony/Component/HttpKernel Expand file tree Collapse file tree 4 files changed +62
-0
lines changed
Original file line number Diff line number Diff line change
1
+ CHANGELOG for 3.1.x
2
+ ===================
3
+
4
+ This changelog references the relevant changes (bug and security fixes) done
5
+ in 3.1 minor versions.
6
+
7
+ To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
8
+ To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.1.0...v3.1.1
9
+
10
+ * 3.1.0
11
+
12
+ * bug #17611 [ HttpKernel] Deprecate passing objects as URI attributes to the ESI and SSI renderers
Original file line number Diff line number Diff line change 16
16
* The ` choices_as_values ` option of the ` ChoiceType ` has been deprecated and
17
17
will be removed in Symfony 4.0.
18
18
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
+
19
26
Serializer
20
27
----------
21
28
Original file line number Diff line number Diff line change @@ -64,6 +64,10 @@ public function __construct(SurrogateInterface $surrogate = null, FragmentRender
64
64
public function render ($ uri , Request $ request , array $ options = array ())
65
65
{
66
66
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
+
67
71
return $ this ->inlineStrategy ->render ($ uri , $ request , $ options );
68
72
}
69
73
@@ -92,4 +96,17 @@ private function generateSignedFragmentUri($uri, Request $request)
92
96
93
97
return substr ($ fragmentUri , strlen ($ request ->getSchemeAndHttpHost ()));
94
98
}
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
+ }
95
112
}
Original file line number Diff line number Diff line change @@ -25,6 +25,32 @@ public function testRenderFallbackToInlineStrategyIfEsiNotSupported()
25
25
$ strategy ->render ('/ ' , Request::create ('/ ' ));
26
26
}
27
27
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
+
28
54
public function testRender ()
29
55
{
30
56
$ strategy = new EsiFragmentRenderer (new Esi (), $ this ->getInlineStrategy ());
You can’t perform that action at this time.
0 commit comments