Skip to content

Commit 0660226

Browse files
committed
[HttpKernel] fixed deprecation notices for ESI classes
1 parent 3f292d5 commit 0660226

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

HttpCache/Esi.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function getName()
5353
*/
5454
public function createCacheStrategy()
5555
{
56-
return new EsiResponseCacheStrategy();
56+
return new ResponseCacheStrategy();
5757
}
5858

5959
/**
@@ -65,7 +65,11 @@ public function createCacheStrategy()
6565
*/
6666
public function hasSurrogateCapability(Request $request)
6767
{
68-
return $this->hasSurrogateEsiCapability($request);
68+
if (null === $value = $request->headers->get('Surrogate-Capability')) {
69+
return false;
70+
}
71+
72+
return false !== strpos($value, 'ESI/1.0');
6973
}
7074

7175
/**
@@ -81,11 +85,7 @@ public function hasSurrogateEsiCapability(Request $request)
8185
{
8286
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the hasSurrogateCapability() method instead.', E_USER_DEPRECATED);
8387

84-
if (null === $value = $request->headers->get('Surrogate-Capability')) {
85-
return false;
86-
}
87-
88-
return false !== strpos($value, 'ESI/1.0');
88+
return $this->hasSurrogateCapability($request);
8989
}
9090

9191
/**
@@ -95,7 +95,10 @@ public function hasSurrogateEsiCapability(Request $request)
9595
*/
9696
public function addSurrogateCapability(Request $request)
9797
{
98-
$this->addSurrogateEsiCapability($request);
98+
$current = $request->headers->get('Surrogate-Capability');
99+
$new = 'symfony2="ESI/1.0"';
100+
101+
$request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new);
99102
}
100103

101104
/**
@@ -109,10 +112,7 @@ public function addSurrogateEsiCapability(Request $request)
109112
{
110113
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the addSurrogateCapability() method instead.', E_USER_DEPRECATED);
111114

112-
$current = $request->headers->get('Surrogate-Capability');
113-
$new = 'symfony2="ESI/1.0"';
114-
115-
$request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new);
115+
$this->addSurrogateCapability($request);
116116
}
117117

118118
/**
@@ -138,7 +138,11 @@ public function addSurrogateControl(Response $response)
138138
*/
139139
public function needsParsing(Response $response)
140140
{
141-
return $this->needsEsiParsing($response);
141+
if (!$control = $response->headers->get('Surrogate-Control')) {
142+
return false;
143+
}
144+
145+
return (bool) preg_match('#content="[^"]*ESI/1.0[^"]*"#', $control);
142146
}
143147

144148
/**
@@ -154,11 +158,7 @@ public function needsEsiParsing(Response $response)
154158
{
155159
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the needsParsing() method instead.', E_USER_DEPRECATED);
156160

157-
if (!$control = $response->headers->get('Surrogate-Control')) {
158-
return false;
159-
}
160-
161-
return (bool) preg_match('#content="[^"]*ESI/1.0[^"]*"#', $control);
161+
return $this->needsParsing($response);
162162
}
163163

164164
/**

HttpCache/EsiResponseCacheStrategyInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
namespace Symfony\Component\HttpKernel\HttpCache;
1717

18+
trigger_error('The '.__NAMESPACE__.'\EsiResponseCacheStrategyInterface class is deprecated since version 2.6 and will be removed in 3.0. Use the Symfony\Component\HttpKernel\HttpCache\ResponseCacheStrategyInterface class instead.', E_USER_DEPRECATED);
19+
1820
/**
1921
* ResponseCacheStrategyInterface implementations know how to compute the
2022
* Response cache HTTP header based on the different response cache headers.

0 commit comments

Comments
 (0)