diff --git a/core/lib/Thelia/Command/ModuleActivateCommand.php b/core/lib/Thelia/Command/ModuleActivateCommand.php
index 1b8ac600f..139f21e9e 100755
--- a/core/lib/Thelia/Command/ModuleActivateCommand.php
+++ b/core/lib/Thelia/Command/ModuleActivateCommand.php
@@ -63,8 +63,6 @@ class ModuleActivateCommand extends BaseModuleGenerate
}
try {
- new \TheliaDebugBar\TheliaDebugBar();
-
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
$moduleInstance = $moduleReflection->newInstance();
diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml
index 5a3548a9c..54b699b71 100755
--- a/core/lib/Thelia/Config/Resources/config.xml
+++ b/core/lib/Thelia/Config/Resources/config.xml
@@ -71,7 +71,9 @@
-
+
+
+
diff --git a/core/lib/Thelia/Core/EventListener/ResponseListener.php b/core/lib/Thelia/Core/EventListener/ResponseListener.php
new file mode 100644
index 000000000..eb03bde81
--- /dev/null
+++ b/core/lib/Thelia/Core/EventListener/ResponseListener.php
@@ -0,0 +1,76 @@
+. */
+/* */
+/*************************************************************************************/
+
+namespace Thelia\Core\EventListener;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
+use Symfony\Component\HttpKernel\KernelEvents;
+
+
+/**
+ * Class ResponseListener
+ * @package Thelia\Core\EventListener
+ * @author manuel raynaud
+ */
+class ResponseListener implements EventSubscriberInterface
+{
+
+ public function onResponse(FilterResponseEvent $event)
+ {
+ $request = $event->getRequest();
+
+ if($request->headers->has('Surrogate-Capability'))
+ {
+ $response = $event->getResponse();
+ $response->headers->set('Surrogate-Control', 'content="ESI/1.0"');
+ $event->setResponse($response);
+ }
+ }
+
+ /**
+ * Returns an array of event names this subscriber wants to listen to.
+ *
+ * The array keys are event names and the value can be:
+ *
+ * * The method name to call (priority defaults to 0)
+ * * An array composed of the method name to call and the priority
+ * * An array of arrays composed of the method names to call and respective
+ * priorities, or 0 if unset
+ *
+ * For instance:
+ *
+ * * array('eventName' => 'methodName')
+ * * array('eventName' => array('methodName', $priority))
+ * * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
+ *
+ * @return array The event names to listen to
+ *
+ * @api
+ */
+ public static function getSubscribedEvents()
+ {
+ return array(
+ KernelEvents::RESPONSE => array('onResponse', 0)
+ );
+ }
+}
\ No newline at end of file
diff --git a/core/lib/Thelia/Core/HttpKernel/HttpCache/HttpCache.php b/core/lib/Thelia/Core/HttpKernel/HttpCache/HttpCache.php
index 01ad22733..b45f0f812 100644
--- a/core/lib/Thelia/Core/HttpKernel/HttpCache/HttpCache.php
+++ b/core/lib/Thelia/Core/HttpKernel/HttpCache/HttpCache.php
@@ -23,17 +23,20 @@
namespace Thelia\Core\HttpKernel\HttpCache;
+use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpCache\Esi;
use Symfony\Component\HttpKernel\HttpCache\HttpCache as BaseHttpCache;
use Symfony\Component\HttpKernel\HttpCache\Store;
use Symfony\Component\HttpKernel\HttpKernelInterface;
+use Thelia\Core\HttpFoundation\Request as TheliaRequest;
+
/**
* Class HttpCache
* @package Thelia\Core\HttpKernel\HttpCache
* @author manuel raynaud
*/
-class HttpCache extends BaseHttpCache
+class HttpCache extends BaseHttpCache implements HttpKernelInterface
{
public function __construct(HttpKernelInterface $kernel, $options = array())
@@ -49,4 +52,20 @@ class HttpCache extends BaseHttpCache
);
}
+ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
+ {
+ if (!($request instanceof \Thelia\Core\HttpFoundation\Request)) {
+ $request = TheliaRequest::create(
+ $request->getUri(),
+ $request->getMethod(),
+ $request->getMethod() == 'GET' ? $request->query->all() : $request->request->all(),
+ $request->cookies->all(),
+ $request->files->all(),
+ $request->server->all(),
+ $request->getContent()
+ );
+ }
+ return parent::handle($request, $type, $catch);
+ }
+
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php
index 94ad7f9de..ed4dd672b 100755
--- a/core/lib/Thelia/Core/TheliaHttpKernel.php
+++ b/core/lib/Thelia/Core/TheliaHttpKernel.php
@@ -43,6 +43,7 @@ use Thelia\Model;
class TheliaHttpKernel extends HttpKernel
{
+ protected static $session;
protected $container;
@@ -79,8 +80,11 @@ class TheliaHttpKernel extends HttpKernel
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
//$request->headers->set('X-Php-Ob-Level', ob_get_level());
- $request = $this->initSession($request);
- $this->initParam($request);
+ if ($type == HttpKernelInterface::MASTER_REQUEST) {
+ $request = $this->initSession($request);
+ $this->initParam($request);
+ }
+
$this->container->enterScope('request');
$this->container->set('request', $request, 'request');
@@ -211,26 +215,29 @@ class TheliaHttpKernel extends HttpKernel
protected function initSession(Request $request)
{
+ if(null === self::$session) {
+ $storage = new Session\Storage\NativeSessionStorage();
- $storage = new Session\Storage\NativeSessionStorage();
+ if (Model\ConfigQuery::read("session_config.default")) {
+ $storage->setSaveHandler(new Session\Storage\Handler\NativeFileSessionHandler(Model\ConfigQuery::read("session_config.save_path", THELIA_ROOT . '/local/session/')));
+ } else {
+ $handlerString = Model\ConfigQuery::read("session_config.handlers", 'Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler');
- if (Model\ConfigQuery::read("session_config.default")) {
- $storage->setSaveHandler(new Session\Storage\Handler\NativeFileSessionHandler(Model\ConfigQuery::read("session_config.save_path", THELIA_LOCAL_DIR . 'session/')));
+ $handler = new $handlerString;
+
+ $storage->setSaveHandler($handler);
+ }
+
+ if (Model\ConfigQuery::read("session_config.config", null)) {
+ $storage->setOptions(json_decode(Model\ConfigQuery::read("session_config.config")));
+ }
+
+ self::$session = $session = new \Thelia\Core\HttpFoundation\Session\Session($storage);
} else {
- $handlerString = Model\ConfigQuery::read("session_config.handlers", 'Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler');
-
- $handler = new $handlerString;
-
- $storage->setSaveHandler($handler);
+ $session = self::$session;
}
- if (Model\ConfigQuery::read("session_config.config", null)) {
- $storage->setOptions(json_decode(Model\ConfigQuery::read("session_config.config")));
- }
-
- $session = new \Thelia\Core\HttpFoundation\Session\Session($storage);
$session->start();
-
$request->setSession($session);
return $request;
diff --git a/web/index_dev.php b/web/index_dev.php
index 7d9e61bd8..2ac651a5a 100755
--- a/web/index_dev.php
+++ b/web/index_dev.php
@@ -44,9 +44,10 @@ if ( false === in_array($request->getClientIp(), $trustedIp)) {
$response = Response::create('Forbidden', 403)->send();
$thelia->terminate($request, $response);
} else {
- //$thelia = new HttpCache($thelia);
- $response = $thelia->handle($request)->prepare($request)->send();
- $thelia->terminate($request, $response);
+ $thelia = new HttpCache($thelia);
+ $response = $thelia->handle($request)->send();
+ //$thelia->terminate($request, $response);
+
}