Skip to content

Commit

Permalink
bug #23088 [FrameworkBundle] Dont set pre-defined esi/ssi services (r…
Browse files Browse the repository at this point in the history
…o0NL)

This PR was squashed before being merged into the 3.3 branch (closes #23088).

Discussion
----------

[FrameworkBundle] Dont set pre-defined esi/ssi services

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | not sure
| Deprecations? | no
| Tests pass?   | yes/no
| Fixed tickets | #23080
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

It fixes the issue, but im not sure what's expected if you dont use http cache (solely enabled ssi/esi in config). Before the services were initialized, now they are synthetic as http cache sets them, but thats optional =/

Commits
-------

8c26aab [FrameworkBundle] Dont set pre-defined esi/ssi services
  • Loading branch information
fabpot committed Jun 14, 2017
2 parents 57bed81 + 8c26aab commit 4667262
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php
Expand Up @@ -54,8 +54,7 @@ public function __construct(HttpKernelInterface $kernel, $cacheDir = null)
protected function forward(Request $request, $raw = false, Response $entry = null)
{
$this->getKernel()->boot();
$this->getKernel()->getContainer()->set('cache', $this);
$this->getKernel()->getContainer()->set($this->getSurrogate()->getName(), $this->getSurrogate());
$this->getKernel()->getContainer()->set('cache', $this); // to be removed in 4.0?
return parent::forward($request, $raw, $entry);
}
Expand Down
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\EventListener;

use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\HttpCache\HttpCache;
use Symfony\Component\HttpKernel\HttpCache\SurrogateInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand Down Expand Up @@ -42,11 +43,24 @@ public function __construct(SurrogateInterface $surrogate = null)
*/
public function onKernelResponse(FilterResponseEvent $event)
{
if (!$event->isMasterRequest() || null === $this->surrogate) {
if (!$event->isMasterRequest()) {
return;
}

$this->surrogate->addSurrogateControl($event->getResponse());
$kernel = $event->getKernel();
$surrogate = $this->surrogate;
if ($kernel instanceof HttpCache) {
$surrogate = $kernel->getSurrogate();
if (null !== $this->surrogate && $this->surrogate->getName() !== $surrogate->getName()) {
$surrogate = $this->surrogate;
}
}

if (null === $surrogate) {
return;
}

$surrogate->addSurrogateControl($event->getResponse());
}

public static function getSubscribedEvents()
Expand Down

0 comments on commit 4667262

Please sign in to comment.