8000 [FrameworkBundle] Dont set pre-defined esi/ssi services by ro0NL · Pull Request #23088 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
revised
  • Loading branch information
ro0NL committed Jun 9, 2017
commit e3398e76af1738164d52a9097335c3512fc60cdc
3 changes: 1 addition & 2 deletions src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php
Original file line number Diff line number Diff line change
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
4 changes: 1 addition & 3 deletions src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<services>
<defaults public="false" />

<service id="cache" class="Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache" public="true" synthetic="true" />

<service id="esi" class="Symfony\Component\HttpKernel\HttpCache\Esi" public="true" synthetic="true" />
<service id="esi" class="Symfony\Component\HttpKernel\HttpCache\Esi" public="true" />

<service id="esi_listener" class="Symfony\Component\HttpKernel\EventListener\SurrogateListener" public="true">
<tag name="kernel.event_subscriber" />
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Bundle/FrameworkBundle/Resources/config/ssi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<services>
<defaults public="false" />

<service id="cache" class="Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache" public="true" synthetic="true" />

<service id="ssi" class="Symfony\Component\HttpKernel\HttpCache\Ssi" public="true" synthetic="true" />
<service id="ssi" class="Symfony\Component\HttpKernel\HttpCache\Ssi" public="true" />

<service id="ssi_listener" class="Symfony\Component\HttpKernel\EventListener\SurrogateListener" public="true">
<tag name="kernel.event_subscriber" />
Expand Down
Original file line number Diff line number Diff line change
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