From b4af652dd9284f5565ba658389840a47dac48211 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Mon, 22 Dec 2014 15:32:45 +1300 Subject: Moved common bootstrap code in a `core/bootstrap.php` file This file is not in a class because it needs to be compatible with PHP 4. --- console | 17 +++++----------- core/Plugin/ControllerAdmin.php | 23 ++-------------------- core/bootstrap.php | 38 ++++++++++++++++++++++++++++++++++++ core/dispatch.php | 3 --- index.php | 22 +++------------------ misc/others/cli-script-bootstrap.php | 11 ++--------- piwik.php | 19 ++---------------- tests/PHPUnit/bootstrap.php | 7 +++---- 8 files changed, 55 insertions(+), 85 deletions(-) create mode 100644 core/bootstrap.php diff --git a/console b/console index 020b0d2706..9bc11d38ec 100755 --- a/console +++ b/console @@ -11,18 +11,11 @@ if (file_exists(PIWIK_DOCUMENT_ROOT . '/bootstrap.php')) { if (!defined('PIWIK_INCLUDE_PATH')) { define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT); } -if (!defined('PIWIK_USER_PATH')) { - define('PIWIK_USER_PATH', PIWIK_DOCUMENT_ROOT); -} - -require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; -@date_default_timezone_set('UTC'); +require_once PIWIK_INCLUDE_PATH . '/core/bootstrap.php'; require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; -\Piwik\Loader::init(); - -require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; +Piwik\Loader::init(); Piwik\Translate::loadEnglishTranslation(); @@ -31,9 +24,9 @@ if (!Piwik\Common::isPhpCliMode()) { } if (!defined('PIWIK_ENABLE_ERROR_HANDLER') || PIWIK_ENABLE_ERROR_HANDLER) { - \Piwik\ErrorHandler::registerErrorHandler(); - \Piwik\ExceptionHandler::setUp(); + Piwik\ErrorHandler::registerErrorHandler(); + Piwik\ExceptionHandler::setUp(); } $console = new Piwik\Console(); -$console->run(); \ No newline at end of file +$console->run(); diff --git a/core/Plugin/ControllerAdmin.php b/core/Plugin/ControllerAdmin.php index 008cb4d2f4..23184caa8f 100644 --- a/core/Plugin/ControllerAdmin.php +++ b/core/Plugin/ControllerAdmin.php @@ -29,8 +29,6 @@ use Piwik\View; */ abstract class ControllerAdmin extends Controller { - private static $isEacceleratorUsed = false; - private static function notifyWhenTrackingStatisticsDisabled() { $statsEnabled = PiwikConfig::getInstance()->Tracker['record_statistics']; @@ -105,27 +103,10 @@ abstract class ControllerAdmin extends Controller } } - /** - * See https://github.com/piwik/piwik/issues/4439#comment:8 and https://github.com/eaccelerator/eaccelerator/issues/12 - * - * Eaccelerator does not support closures and is known to be not comptabile with Piwik. Therefore we are disabling - * it automatically. At this point it looks like Eaccelerator is no longer under development and the bug has not - * been fixed within a year. - */ - public static function disableEacceleratorIfEnabled() - { - $isEacceleratorUsed = ini_get('eaccelerator.enable'); - - if (!empty($isEacceleratorUsed)) { - self::$isEacceleratorUsed = true; - - @ini_set('eaccelerator.enable', 0); - } - } - private static function notifyIfEAcceleratorIsUsed() { - if (!self::$isEacceleratorUsed) { + $isEacceleratorUsed = ini_get('eaccelerator.enable'); + if (empty($isEacceleratorUsed)) { return; } $message = sprintf("You are using the PHP accelerator & optimizer eAccelerator which is known to be not compatible with Piwik. diff --git a/core/bootstrap.php b/core/bootstrap.php new file mode 100644 index 0000000000..546625b8c6 --- /dev/null +++ b/core/bootstrap.php @@ -0,0 +1,38 @@ +