mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Fix #1368 : Disable call to configuration when application is not installed
This commit is contained in:
@@ -521,6 +521,7 @@ class Application extends SilexApplication
|
||||
private function setupUrlGenerator()
|
||||
{
|
||||
$this['url_generator'] = $this->share($this->extend('url_generator', function($urlGenerator, $app) {
|
||||
if ($app['phraseanet.configuration']->isSetup()) {
|
||||
$data = parse_url($app['phraseanet.configuration']['main']['servername']);
|
||||
|
||||
if (isset($data['scheme'])) {
|
||||
@@ -529,6 +530,7 @@ class Application extends SilexApplication
|
||||
if (isset($data['host'])) {
|
||||
$urlGenerator->getContext()->setHost($data['host']);
|
||||
}
|
||||
}
|
||||
|
||||
return $urlGenerator;
|
||||
}));
|
||||
|
@@ -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'];
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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());
|
||||
|
@@ -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')
|
||||
|
@@ -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')
|
||||
|
Reference in New Issue
Block a user