diff --git a/console b/console index 020b0d27063c83e1a521d7f4634da37f6bfca39a..9bc11d38ec3b045e7809b33c26222730666c40c1 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 008cb4d2f4ba269883f24cfb376e425a99c091dd..23184caa8f16d757330e9fbc60421f7d50bcd864 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 0000000000000000000000000000000000000000..546625b8c698a441851d52675702df3c0a6149eb --- /dev/null +++ b/core/bootstrap.php @@ -0,0 +1,38 @@ +<?php +/** + * Bootstraps the Piwik application. + */ + +if (!defined('PIWIK_USER_PATH')) { + define('PIWIK_USER_PATH', PIWIK_DOCUMENT_ROOT); +} + +error_reporting(E_ALL | E_NOTICE); +@ini_set('display_errors', defined('PIWIK_DISPLAY_ERRORS') ? PIWIK_DISPLAY_ERRORS : @ini_get('display_errors')); +@ini_set('xdebug.show_exception_trace', 0); +@ini_set('magic_quotes_runtime', 0); + +// NOTE: the code above must be PHP4 compatible +require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; + +session_cache_limiter('nocache'); +@date_default_timezone_set('UTC'); + +disableEaccelerator(); + +require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; + +/** + * 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. + */ +function disableEaccelerator() +{ + $isEacceleratorUsed = ini_get('eaccelerator.enable'); + if (!empty($isEacceleratorUsed)) { + @ini_set('eaccelerator.enable', 0); + } +} diff --git a/core/dispatch.php b/core/dispatch.php index 1359dd8ee5f584d76ed0c9dea6e5532e93d444a1..c63f2f76b4107082f7f2362ba073d3591db760d1 100644 --- a/core/dispatch.php +++ b/core/dispatch.php @@ -11,9 +11,6 @@ use Piwik\ErrorHandler; use Piwik\ExceptionHandler; use Piwik\FrontController; -use Piwik\Plugin\ControllerAdmin as PluginControllerAdmin; - -PluginControllerAdmin::disableEacceleratorIfEnabled(); if (!defined('PIWIK_ENABLE_ERROR_HANDLER') || PIWIK_ENABLE_ERROR_HANDLER) { ErrorHandler::registerErrorHandler(); diff --git a/index.php b/index.php index 3a26f9ff7cb3b59c4e1e3e55a93ca89b39cec1a5..4b92d7fe2b1bdca9632fc5e7db115ff9f2f7122f 100644 --- a/index.php +++ b/index.php @@ -14,33 +14,17 @@ if(!defined('PIWIK_DOCUMENT_ROOT')) { if (file_exists(PIWIK_DOCUMENT_ROOT . '/bootstrap.php')) { require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php'; } - -error_reporting(E_ALL | E_NOTICE); -@ini_set('display_errors', defined('PIWIK_DISPLAY_ERRORS') ? PIWIK_DISPLAY_ERRORS : @ini_get('display_errors')); -@ini_set('xdebug.show_exception_trace', 0); -@ini_set('magic_quotes_runtime', 0); - -if (!defined('PIWIK_USER_PATH')) { - define('PIWIK_USER_PATH', PIWIK_DOCUMENT_ROOT); -} if (!defined('PIWIK_INCLUDE_PATH')) { define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT); } -require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; - -// NOTE: the code above this comment must be PHP4 compatible - -session_cache_limiter('nocache'); -@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'; - -if(!defined('PIWIK_PRINT_ERROR_BACKTRACE')) { +if (!defined('PIWIK_PRINT_ERROR_BACKTRACE')) { define('PIWIK_PRINT_ERROR_BACKTRACE', false); } -require_once PIWIK_INCLUDE_PATH . '/core/dispatch.php'; \ No newline at end of file +require_once PIWIK_INCLUDE_PATH . '/core/dispatch.php'; diff --git a/misc/others/cli-script-bootstrap.php b/misc/others/cli-script-bootstrap.php index e2374bbe102d9502a903b7aaf7a4154f35c4ab41..7e7e0914482fb96351bb60133f666d74eba405c1 100644 --- a/misc/others/cli-script-bootstrap.php +++ b/misc/others/cli-script-bootstrap.php @@ -10,27 +10,20 @@ use Piwik\Container\StaticContainer; use Piwik\FrontController; use Symfony\Bridge\Monolog\Handler\ConsoleHandler; use Symfony\Component\Console\Output\ConsoleOutput; -use Symfony\Component\Console\Output\OutputInterface; - -error_reporting(E_ALL | E_NOTICE); define('PIWIK_DOCUMENT_ROOT', dirname(__FILE__) == '/' ? '' : dirname(__FILE__) . '/../..'); if (file_exists(PIWIK_DOCUMENT_ROOT . '/bootstrap.php')) { require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php'; } -if (!defined('PIWIK_USER_PATH')) { - define('PIWIK_USER_PATH', PIWIK_DOCUMENT_ROOT); -} if (!defined('PIWIK_INCLUDE_PATH')) { define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT); } +require_once PIWIK_INCLUDE_PATH . '/core/bootstrap.php'; + ignore_user_abort(true); set_time_limit(0); -@date_default_timezone_set('UTC'); -require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; -require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; \Piwik\Loader::init(); diff --git a/piwik.php b/piwik.php index cd58b3d526fde53a7b09e50d4704df2ee92f1347..5cc1040f0e056a0a36a6917691f6510bec45c5c2 100644 --- a/piwik.php +++ b/piwik.php @@ -18,22 +18,15 @@ use Piwik\Tracker\Handler; if (!defined('PIWIK_DOCUMENT_ROOT')) { define('PIWIK_DOCUMENT_ROOT', dirname(__FILE__) == '/' ? '' : dirname(__FILE__)); } - if (file_exists(PIWIK_DOCUMENT_ROOT . '/bootstrap.php')) { require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php'; } - -error_reporting(E_ALL | E_NOTICE); -@ini_set('xdebug.show_exception_trace', 0); -@ini_set('magic_quotes_runtime', 0); - -if (!defined('PIWIK_USER_PATH')) { - define('PIWIK_USER_PATH', PIWIK_DOCUMENT_ROOT); -} if (!defined('PIWIK_INCLUDE_PATH')) { define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT); } +require_once PIWIK_INCLUDE_PATH . '/core/bootstrap.php'; + @ignore_user_abort(true); if (file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php')) { @@ -45,11 +38,6 @@ require_once $vendorDirectory . '/autoload.php'; require_once PIWIK_INCLUDE_PATH . '/core/Plugin/Controller.php'; require_once PIWIK_INCLUDE_PATH . '/core/Plugin/ControllerAdmin.php'; - -\Piwik\Plugin\ControllerAdmin::disableEacceleratorIfEnabled(); - -require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; -require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; require_once PIWIK_INCLUDE_PATH . '/core/Singleton.php'; require_once PIWIK_INCLUDE_PATH . '/core/Plugin/Manager.php'; require_once PIWIK_INCLUDE_PATH . '/core/Plugin.php'; @@ -67,9 +55,6 @@ require_once PIWIK_INCLUDE_PATH . '/core/Tracker/Cache.php'; require_once PIWIK_INCLUDE_PATH . '/core/Tracker/Request.php'; require_once PIWIK_INCLUDE_PATH . '/core/Cookie.php'; -session_cache_limiter('nocache'); -@date_default_timezone_set('UTC'); - Tracker::loadTrackerEnvironment(); $tracker = new Tracker(); diff --git a/tests/PHPUnit/bootstrap.php b/tests/PHPUnit/bootstrap.php index 0273e60d208b09d96701b0982abf5e151d68c668..f77d2b67089bb08f44515e68717fafe697c5a35a 100644 --- a/tests/PHPUnit/bootstrap.php +++ b/tests/PHPUnit/bootstrap.php @@ -17,6 +17,9 @@ if (!defined('PIWIK_USER_PATH')) { if (!defined('PIWIK_INCLUDE_PATH')) { define('PIWIK_INCLUDE_PATH', PIWIK_PATH_TEST_TO_ROOT); } + +require_once PIWIK_INCLUDE_PATH . '/core/bootstrap.php'; + if (!defined('PIWIK_INCLUDE_SEARCH_PATH')) { define('PIWIK_INCLUDE_SEARCH_PATH', get_include_path() . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/vendor/bin' @@ -27,15 +30,11 @@ if (!defined('PIWIK_INCLUDE_SEARCH_PATH')) { @ini_set('include_path', PIWIK_INCLUDE_SEARCH_PATH); @set_include_path(PIWIK_INCLUDE_SEARCH_PATH); @ini_set('memory_limit', -1); -error_reporting(E_ALL | E_NOTICE); -@date_default_timezone_set('UTC'); require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; \Piwik\Loader::init(); -require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; -require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/DatabaseTestCase.php'; require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/IntegrationTestCase.php'; require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/BenchmarkTestCase.php';