From 3e04122e34cc111c93aa49926fde27e1aecfe0e5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 12 Feb 2014 14:51:04 +0100 Subject: [PATCH] Do not set UTC in index.php refs #5638 fixes #5530 --- bin/icingaweb | 1 - library/Icinga/Application/ApplicationBootstrap.php | 13 +++++-------- library/Icinga/Application/Cli.php | 4 +++- library/Icinga/Application/EmbeddedWeb.php | 5 +++-- library/Icinga/Application/Logger.php | 7 +++---- library/Icinga/Application/Web.php | 9 +++++---- public/index.php.in | 7 ------- 7 files changed, 19 insertions(+), 27 deletions(-) diff --git a/bin/icingaweb b/bin/icingaweb index 8e48d6f33..e0f5dad67 100755 --- a/bin/icingaweb +++ b/bin/icingaweb @@ -11,6 +11,5 @@ set_include_path( ); require_once 'Icinga/Application/Cli.php'; -date_default_timezone_set('UTC'); $app = Cli::start(dirname(__FILE__) . '/../config/')->dispatch(); diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index c69c9f2f7..500d63f23 100755 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -32,7 +32,6 @@ namespace Icinga\Application; use \DateTimeZone; use \Exception; use \Icinga\Application\Modules\Manager as ModuleManager; -use \Icinga\Application\Config; use \Icinga\Exception\ConfigurationError; use \Icinga\Util\DateTimeFactory; use \Icinga\Util\Translator; @@ -124,7 +123,7 @@ abstract class ApplicationBootstrap */ protected function __construct($configDir) { - $this->libDir = realpath(__DIR__. '/../..'); + $this->libDir = realpath(__DIR__ . '/../..'); if (!defined('ICINGA_LIBDIR')) { define('ICINGA_LIBDIR', $this->libDir); @@ -257,9 +256,7 @@ abstract class ApplicationBootstrap */ public static function start($configDir) { - $class = get_called_class(); - /** @var ApplicationBootstrap $obj */ - $application = new $class($configDir); + $application = new static($configDir); $application->bootstrap(); if (Logger::hasErrorsOccurred()) { @@ -302,7 +299,7 @@ abstract class ApplicationBootstrap */ public function setupAutoloader() { - require $this->libDir. '/Icinga/Application/Loader.php'; + require $this->libDir . '/Icinga/Application/Loader.php'; $this->loader = new Loader(); $this->loader->registerNamespace('Icinga', $this->libDir. '/Icinga'); @@ -368,11 +365,11 @@ abstract class ApplicationBootstrap } /** - * Load Configuration + * Load configuration * * @return self */ - protected function setupConfig() + protected function loadConfig() { Config::$configDir = $this->configDir; $this->config = Config::app(); diff --git a/library/Icinga/Application/Cli.php b/library/Icinga/Application/Cli.php index ee61605df..583d6fc0b 100644 --- a/library/Icinga/Application/Cli.php +++ b/library/Icinga/Application/Cli.php @@ -61,7 +61,9 @@ class Cli extends ApplicationBootstrap protected function bootstrap() { $this->assertRunningOnCli(); - $this->setupConfig() + $this + ->loadConfig() + ->setupTimezone() ->setupInternationalization() ->parseBasicParams() ->fixLoggingConfig() diff --git a/library/Icinga/Application/EmbeddedWeb.php b/library/Icinga/Application/EmbeddedWeb.php index de0b8a904..c5ec9fc04 100644 --- a/library/Icinga/Application/EmbeddedWeb.php +++ b/library/Icinga/Application/EmbeddedWeb.php @@ -54,9 +54,10 @@ class EmbeddedWeb extends ApplicationBootstrap */ protected function bootstrap() { - return $this->setupConfig() - ->setupErrorHandling() + return $this + ->loadConfig() ->setupTimezone() + ->setupErrorHandling() ->setupModules(); } } diff --git a/library/Icinga/Application/Logger.php b/library/Icinga/Application/Logger.php index f7480d040..718354b78 100755 --- a/library/Icinga/Application/Logger.php +++ b/library/Icinga/Application/Logger.php @@ -29,18 +29,17 @@ namespace Icinga\Application; -use Icinga\Protocol\Ldap\Exception; use \Zend_Config; use \Zend_Log; use \Zend_Log_Filter_Priority; use \Zend_Log_Writer_Abstract; use \Zend_Log_Exception; -use \Icinga\Exception\ConfigurationError; +use Icinga\Exception\ConfigurationError; /** - * Singleton logger + * Zend_Log wrapper */ -final class Logger +class Logger { /** * Default log type diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 193558f97..ef3c44e23 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -116,13 +116,14 @@ class Web extends ApplicationBootstrap */ protected function bootstrap() { - return $this->setupConfig() - ->setupErrorHandling() - ->setupResourceFactory() + return $this + ->loadConfig() ->setupSession() ->setupUser() - ->setupInternationalization() ->setupTimezone() + ->setupErrorHandling() + ->setupResourceFactory() + ->setupInternationalization() ->setupRequest() ->setupZendMvc() ->setupModuleManager() diff --git a/public/index.php.in b/public/index.php.in index 474960426..5bb7a0f3c 100644 --- a/public/index.php.in +++ b/public/index.php.in @@ -2,13 +2,6 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -/* - * Set timezone before bootstrapping the application and therefore before calling `setupTimezone()` because in case an - * error occurred whilst, the logger calls date/time functions which would generate a warning if the php.ini lacks a - * valid timezone. - */ -date_default_timezone_set('UTC'); - require_once dirname(__FILE__). '/../library/Icinga/Application/Web.php'; use Icinga\Application\Web;