Skip to content

Commit

Permalink
[HttpKernel] fixed deprecation notices for ESI classes
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 8, 2015
1 parent ef7600f commit bd954aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/Symfony/Component/HttpKernel/HttpCache/Esi.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getName()
*/
public function createCacheStrategy()
{
return new EsiResponseCacheStrategy();
return new ResponseCacheStrategy();
}

/**
Expand All @@ -65,7 +65,11 @@ public function createCacheStrategy()
*/
public function hasSurrogateCapability(Request $request)
{
return $this->hasSurrogateEsiCapability($request);
if (null === $value = $request->headers->get('Surrogate-Capability')) {
return false;
}

return false !== strpos($value, 'ESI/1.0');
}

/**
Expand All @@ -81,11 +85,7 @@ public function hasSurrogateEsiCapability(Request $request)
{
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);

if (null === $value = $request->headers->get('Surrogate-Capability')) {
return false;
}

return false !== strpos($value, 'ESI/1.0');
return $this->hasSurrogateCapability($request);
}

/**
Expand All @@ -95,7 +95,10 @@ public function hasSurrogateEsiCapability(Request $request)
*/
public function addSurrogateCapability(Request $request)
{
$this->addSurrogateEsiCapability($request);
$current = $request->headers->get('Surrogate-Capability');
$new = 'symfony2="ESI/1.0"';

$request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new);
}

/**
Expand All @@ -109,10 +112,7 @@ public function addSurrogateEsiCapability(Request $request)
{
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);

$current = $request->headers->get('Surrogate-Capability');
$new = 'symfony2="ESI/1.0"';

$request->headers->set('Surrogate-Capability', $current ? $current.', '.$new : $new);
$this->addSurrogateCapability($request);
}

/**
Expand All @@ -138,7 +138,11 @@ public function addSurrogateControl(Response $response)
*/
public function needsParsing(Response $response)
{
return $this->needsEsiParsing($response);
if (!$control = $response->headers->get('Surrogate-Control')) {
return false;
}

return (bool) preg_match('#content="[^"]*ESI/1.0[^"]*"#', $control);
}

/**
Expand All @@ -154,11 +158,7 @@ public function needsEsiParsing(Response $response)
{
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);

if (!$control = $response->headers->get('Surrogate-Control')) {
return false;
}

return (bool) preg_match('#content="[^"]*ESI/1.0[^"]*"#', $control);
return $this->needsParsing($response);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

namespace Symfony\Component\HttpKernel\HttpCache;

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);

/**
* ResponseCacheStrategyInterface implementations know how to compute the
* Response cache HTTP header based on the different response cache headers.
Expand Down

0 comments on commit bd954aa

Please sign in to comment.