diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 9f7e32ca4f..bd1564b380 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -521,13 +521,15 @@ class Application extends SilexApplication private function setupUrlGenerator() { $this['url_generator'] = $this->share($this->extend('url_generator', function($urlGenerator, $app) { - $data = parse_url($app['phraseanet.configuration']['main']['servername']); + if ($app['phraseanet.configuration']->isSetup()) { + $data = parse_url($app['phraseanet.configuration']['main']['servername']); - if (isset($data['scheme'])) { - $urlGenerator->getContext()->setScheme($data['scheme']); - } - if (isset($data['host'])) { - $urlGenerator->getContext()->setHost($data['host']); + if (isset($data['scheme'])) { + $urlGenerator->getContext()->setScheme($data['scheme']); + } + if (isset($data['host'])) { + $urlGenerator->getContext()->setHost($data['host']); + } } return $urlGenerator; diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/DebuggerSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/DebuggerSubscriber.php index 76e11186bc..e3166b18ee 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/DebuggerSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/DebuggerSubscriber.php @@ -41,7 +41,8 @@ class DebuggerSubscriber implements EventSubscriberInterface return; } - if (isset($this->app['phraseanet.configuration']['debugger']) + if ($this->app['phraseanet.configuration']->isSetup() + && isset($this->app['phraseanet.configuration']['debugger']) && isset($this->app['phraseanet.configuration']['debugger']['allowed-ips'])) { $allowedIps = $this->app['phraseanet.configuration']['debugger']['allowed-ips']; diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/MaintenanceSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/MaintenanceSubscriber.php index 7d2aa4c617..aa5c7a8ddf 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/MaintenanceSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/MaintenanceSubscriber.php @@ -34,7 +34,7 @@ class MaintenanceSubscriber implements EventSubscriberInterface public function checkForMaintenance(GetResponseEvent $event) { - if ($this->app['phraseanet.configuration']['main']['maintenance']) { + if ($this->app['phraseanet.configuration']->isSetup() && $this->app['phraseanet.configuration']['main']['maintenance']) { $this->app->abort(503, 'Service Temporarily Unavailable', array('Retry-After' => 3600)); } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PersistentCookieSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PersistentCookieSubscriber.php index 3a4a31c575..76b6be59d6 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PersistentCookieSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PersistentCookieSubscriber.php @@ -36,7 +36,7 @@ class PersistentCookieSubscriber implements EventSubscriberInterface { $request = $event->getRequest(); - if ($request->cookies->has('persistent') && !$this->app['authentication']->isAuthenticated()) { + if ($this->app['phraseanet.configuration']->isSetup() && $request->cookies->has('persistent') && !$this->app['authentication']->isAuthenticated()) { if (false !== $session = $this->app['authentication.persistent-manager']->getSession($request->cookies->get('persistent'))) { $this->app['authentication']->refreshAccount($session); } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/TrustedProxySubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/TrustedProxySubscriber.php index 198c74767a..8be4c78530 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/TrustedProxySubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/TrustedProxySubscriber.php @@ -35,6 +35,10 @@ class TrustedProxySubscriber implements EventSubscriberInterface public function setProxyConf(GetResponseEvent $event) { + if (!$this->configuration->isSetup()) { + return; + } + $proxies = isset($this->configuration['trusted-proxies']) ? $this->configuration['trusted-proxies'] : array(); Request::setTrustedProxies($proxies); } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/XSendFileSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/XSendFileSubscriber.php index d6aff6bc14..edaaea3be2 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/XSendFileSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/XSendFileSubscriber.php @@ -35,6 +35,10 @@ class XSendFileSubscriber implements EventSubscriberInterface public function applyHeaders(GetResponseEvent $event) { + if (!$this->app['phraseanet.configuration']->isSetup()) { + return; + } + if ($this->app['phraseanet.xsendfile-factory']->isXSendFileModeEnabled()) { BinaryFileResponse::trustXSendfileTypeHeader(); $this->app['phraseanet.xsendfile-factory']->getMode()->setHeaders($event->getRequest()); diff --git a/tests/Alchemy/Tests/Phrasea/ApplicationTest.php b/tests/Alchemy/Tests/Phrasea/ApplicationTest.php index 458e63b62a..ac110887e0 100644 --- a/tests/Alchemy/Tests/Phrasea/ApplicationTest.php +++ b/tests/Alchemy/Tests/Phrasea/ApplicationTest.php @@ -294,6 +294,9 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract { $app = new Application('test'); $app['phraseanet.configuration'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface'); + $app['phraseanet.configuration']->expects($this->once()) + ->method('isSetup') + ->will($this->returnValue(true)); $app['phraseanet.configuration']->expects($this->once()) ->method('offsetGet') ->with('main') diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/TrustedProxySubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/TrustedProxySubscriberTest.php index 4e1e9dcdad..45d8f06f4b 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/TrustedProxySubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/TrustedProxySubscriberTest.php @@ -19,6 +19,9 @@ class TrustedProxySubscriberTest extends \PHPUnit_Framework_TestCase public function testAllowedIpsAreSetAsArray() { $configuration = $this->getConfigurationMock(); + $configuration->expects($this->once()) + ->method('isSetup') + ->will($this->returnValue(true)); $configuration->expects($this->once()) ->method('offsetGet') ->with('trusted-proxies') @@ -45,6 +48,9 @@ class TrustedProxySubscriberTest extends \PHPUnit_Framework_TestCase public function testAllowedIpsAreSetWhenEmpty() { $configuration = $this->getConfigurationMock(); + $configuration->expects($this->once()) + ->method('isSetup') + ->will($this->returnValue(true)); $configuration->expects($this->once()) ->method('offsetExists') ->with('trusted-proxies')