diff options
author | Christian Raue <christian.raue@gmail.com> | 2015-06-26 12:32:52 +0300 |
---|---|---|
committer | Christian Raue <christian.raue@gmail.com> | 2015-06-26 12:49:40 +0300 |
commit | 75469d13e15245b605037b48ebd6df516971665d (patch) | |
tree | 65def8fe8dff947f1ed3475322bc38c1df8ff34a | |
parent | 565117f01ac7ab413f6b372a69efa9569fc2547f (diff) |
add constant PIWIK_VENDOR_PATH
-rw-r--r-- | core/Tracker/Visit/ReferrerSpamFilter.php | 6 | ||||
-rw-r--r-- | core/bootstrap.php | 15 | ||||
-rw-r--r-- | core/testMinimumPhpVersion.php | 3 | ||||
-rw-r--r-- | js/tracker.php | 11 | ||||
-rw-r--r-- | plugins/ScheduledReports/config/tcpdf_config.php | 2 | ||||
-rw-r--r-- | plugins/TestRunner/Commands/TestsRun.php | 2 |
6 files changed, 19 insertions, 20 deletions
diff --git a/core/Tracker/Visit/ReferrerSpamFilter.php b/core/Tracker/Visit/ReferrerSpamFilter.php index 142546eaa2..534f713395 100644 --- a/core/Tracker/Visit/ReferrerSpamFilter.php +++ b/core/Tracker/Visit/ReferrerSpamFilter.php @@ -68,11 +68,7 @@ class ReferrerSpamFilter $this->spammerList = unserialize($list); } else { // Fallback to reading the bundled list - if (file_exists(PIWIK_INCLUDE_PATH . '/vendor/piwik/referrer-spam-blacklist/spammers.txt')) { - $file = PIWIK_INCLUDE_PATH . '/vendor/piwik/referrer-spam-blacklist/spammers.txt'; // Piwik is the main project - } else { - $file = PIWIK_INCLUDE_PATH . '/../../piwik/referrer-spam-blacklist/spammers.txt'; // Piwik is installed as a dependency - } + $file = PIWIK_VENDOR_PATH . '/piwik/referrer-spam-blacklist/spammers.txt'; $this->spammerList = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); } diff --git a/core/bootstrap.php b/core/bootstrap.php index ddb23c6016..44103a54b9 100644 --- a/core/bootstrap.php +++ b/core/bootstrap.php @@ -14,6 +14,14 @@ error_reporting(E_ALL | E_NOTICE); @ini_set('xdebug.show_exception_trace', 0); @ini_set('magic_quotes_runtime', 0); +if (!defined('PIWIK_VENDOR_PATH')) { + if (is_dir(PIWIK_INCLUDE_PATH . '/vendor')) { + define('PIWIK_VENDOR_PATH', PIWIK_INCLUDE_PATH . '/vendor'); // Piwik is the main project + } else { + define('PIWIK_VENDOR_PATH', PIWIK_INCLUDE_PATH . '/../..'); // Piwik is installed as a Composer dependency + } +} + // NOTE: the code above must be PHP 4 compatible require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; @@ -25,12 +33,7 @@ disableEaccelerator(); require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; // Composer autoloader -if (file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php')) { - $path = PIWIK_INCLUDE_PATH . '/vendor/autoload.php'; // Piwik is the main project -} else { - $path = PIWIK_INCLUDE_PATH . '/../../autoload.php'; // Piwik is installed as a dependency -} -require_once $path; +require_once PIWIK_VENDOR_PATH . '/autoload.php'; /** * Eaccelerator does not support closures and is known to be not comptabile with Piwik. Therefore we are disabling diff --git a/core/testMinimumPhpVersion.php b/core/testMinimumPhpVersion.php index e1fc84f5d3..f0c9bbd4cb 100644 --- a/core/testMinimumPhpVersion.php +++ b/core/testMinimumPhpVersion.php @@ -50,8 +50,7 @@ if ($minimumPhpInvalid) { To use Piwik, please ask your web host to install php5-json or install it yourself, for example on debian system: <code>sudo apt-get install php5-json</code>. <br/>Then restart your webserver and refresh this page.</p>"; } - if (!file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php') - && !file_exists(PIWIK_INCLUDE_PATH . '/../../autoload.php')) { + if (!file_exists(PIWIK_VENDOR_PATH . '/autoload.php')) { $composerInstall = "In the piwik directory, run in the command line the following (eg. via ssh): \n\n" . "<pre> curl -sS https://getcomposer.org/installer | php \n\n php composer.phar install\n\n</pre> "; if (DIRECTORY_SEPARATOR === '\\' /* ::isWindows() */) { diff --git a/js/tracker.php b/js/tracker.php index c7c546f46e..b06cca49f6 100644 --- a/js/tracker.php +++ b/js/tracker.php @@ -28,13 +28,14 @@ define('PIWIK_USER_PATH', '..'); require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; -// Composer autoloader -if (file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php')) { - $path = PIWIK_INCLUDE_PATH . '/vendor/autoload.php'; // Piwik is the main project +if (is_dir(PIWIK_INCLUDE_PATH . '/vendor')) { + define('PIWIK_VENDOR_PATH', PIWIK_INCLUDE_PATH . '/vendor'); // Piwik is the main project } else { - $path = PIWIK_INCLUDE_PATH . '/../../autoload.php'; // Piwik is installed as a dependency + define('PIWIK_VENDOR_PATH', PIWIK_INCLUDE_PATH . '/../..'); // Piwik is installed as a Composer dependency } -require $path; + +// Composer autoloader +require PIWIK_VENDOR_PATH . '/autoload.php'; $file = '../piwik.js'; diff --git a/plugins/ScheduledReports/config/tcpdf_config.php b/plugins/ScheduledReports/config/tcpdf_config.php index 256bde750b..0fd19a1232 100644 --- a/plugins/ScheduledReports/config/tcpdf_config.php +++ b/plugins/ScheduledReports/config/tcpdf_config.php @@ -13,7 +13,7 @@ use Piwik\Container\StaticContainer; * */ -define('K_PATH_MAIN', PIWIK_INCLUDE_PATH . '/vendor/tecnick.com/tcpdf/'); +define('K_PATH_MAIN', PIWIK_VENDOR_PATH . '/tecnick.com/tcpdf/'); $pathTmpTCPDF = StaticContainer::get('path.tmp') . '/tcpdf/'; diff --git a/plugins/TestRunner/Commands/TestsRun.php b/plugins/TestRunner/Commands/TestsRun.php index 21c4c81678..b025330f9b 100644 --- a/plugins/TestRunner/Commands/TestsRun.php +++ b/plugins/TestRunner/Commands/TestsRun.php @@ -44,7 +44,7 @@ class TestsRun extends ConsoleCommand $groups = $this->getGroupsFromString($groups); - $command = '../../vendor/phpunit/phpunit/phpunit'; + $command = PIWIK_VENDOR_PATH . '/phpunit/phpunit/phpunit'; if (version_compare(PHP_VERSION, '5.4.0', '<')) { $command = 'php -dzend.enable_gc=0 ' . $command; |