diff options
-rwxr-xr-x | console | 17 | ||||
-rw-r--r-- | core/Plugin/ControllerAdmin.php | 23 | ||||
-rw-r--r-- | core/bootstrap.php | 38 | ||||
-rw-r--r-- | core/dispatch.php | 3 | ||||
-rw-r--r-- | index.php | 22 | ||||
-rw-r--r-- | misc/others/cli-script-bootstrap.php | 11 | ||||
-rw-r--r-- | piwik.php | 19 | ||||
-rw-r--r-- | tests/PHPUnit/bootstrap.php | 7 |
8 files changed, 55 insertions, 85 deletions
@@ -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 @@ +<?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 1359dd8ee5..c63f2f76b4 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(); @@ -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 e2374bbe10..7e7e091448 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(); @@ -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 0273e60d20..f77d2b6708 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'; |