Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/AssetManager/UIAssetFetcher/JScriptUIAssetFetcher.php1
-rw-r--r--core/Db/Schema.php16
-rw-r--r--core/Db/Schema/Mysql.php27
-rw-r--r--core/Db/SchemaInterface.php10
-rw-r--r--core/DbHelper.php25
-rw-r--r--core/FileIntegrity.php2
-rw-r--r--core/SettingsPiwik.php9
-rw-r--r--core/Tracker/Db/Pdo/Mysql.php2
-rw-r--r--core/Tracker/Db/Pdo/Pgsql.php2
-rw-r--r--core/Tracker/TrackerCodeGenerator.php45
-rw-r--r--core/Tracker/Visit.php2
-rw-r--r--core/Updater.php4
12 files changed, 138 insertions, 7 deletions
diff --git a/core/AssetManager/UIAssetFetcher/JScriptUIAssetFetcher.php b/core/AssetManager/UIAssetFetcher/JScriptUIAssetFetcher.php
index f50508a7e2..b9dc818651 100644
--- a/core/AssetManager/UIAssetFetcher/JScriptUIAssetFetcher.php
+++ b/core/AssetManager/UIAssetFetcher/JScriptUIAssetFetcher.php
@@ -74,6 +74,7 @@ class JScriptUIAssetFetcher extends UIAssetFetcher
'libs/',
'js/',
'piwik.js',
+ 'matomo.js',
'plugins/CoreHome/javascripts/require.js',
'plugins/Morpheus/javascripts/piwikHelper.js',
'plugins/Morpheus/javascripts/',
diff --git a/core/Db/Schema.php b/core/Db/Schema.php
index b973af0b3b..e6e26a9907 100644
--- a/core/Db/Schema.php
+++ b/core/Db/Schema.php
@@ -142,6 +142,22 @@ class Schema extends Singleton
}
/**
+ * Records the Matomo version a user used when installing this Matomo for the first time
+ */
+ public function recordInstallVersion()
+ {
+ $this->getSchema()->recordInstallVersion();
+ }
+
+ /**
+ * Returns which Matomo version was used to install this Matomo for the first time.
+ */
+ public function getInstallVersion()
+ {
+ return $this->getSchema()->getInstallVersion();
+ }
+
+ /**
* Truncate all tables
*/
public function truncateAllTables()
diff --git a/core/Db/Schema/Mysql.php b/core/Db/Schema/Mysql.php
index 60048bc30d..b033940118 100644
--- a/core/Db/Schema/Mysql.php
+++ b/core/Db/Schema/Mysql.php
@@ -14,12 +14,17 @@ use Piwik\Date;
use Piwik\Db\SchemaInterface;
use Piwik\Db;
use Piwik\DbHelper;
+use Piwik\Option;
+use Piwik\Plugins\Installation\Installation;
+use Piwik\Version;
/**
* MySQL schema
*/
class Mysql implements SchemaInterface
{
+ const OPTION_NAME_MATOMO_INSTALL_VERSION = 'install_version';
+
private $tablesInstalled = null;
/**
@@ -473,6 +478,28 @@ class Mysql implements SchemaInterface
}
/**
+ * Records the Matomo version a user used when installing this Matomo for the first time
+ */
+ public function recordInstallVersion()
+ {
+ if (!self::getInstallVersion()) {
+ Option::set(self::OPTION_NAME_MATOMO_INSTALL_VERSION, Version::VERSION);
+ }
+ }
+
+ /**
+ * Returns which Matomo version was used to install this Matomo for the first time.
+ */
+ public function getInstallVersion()
+ {
+ Option::clearCachedOption(self::OPTION_NAME_MATOMO_INSTALL_VERSION);
+ $version = Option::get(self::OPTION_NAME_MATOMO_INSTALL_VERSION);
+ if (!empty($version)) {
+ return $version;
+ }
+ }
+
+ /**
* Truncate all tables
*/
public function truncateAllTables()
diff --git a/core/Db/SchemaInterface.php b/core/Db/SchemaInterface.php
index 8c22bb6818..9fcf54008d 100644
--- a/core/Db/SchemaInterface.php
+++ b/core/Db/SchemaInterface.php
@@ -60,6 +60,16 @@ interface SchemaInterface
public function createAnonymousUser();
/**
+ * Records the Matomo version a user used when installing this Matomo for the first time
+ */
+ public function recordInstallVersion();
+
+ /**
+ * Returns which Matomo version was used to install this Matomo for the first time.
+ */
+ public function getInstallVersion();
+
+ /**
* Truncate all tables
*/
public function truncateAllTables();
diff --git a/core/DbHelper.php b/core/DbHelper.php
index 1687cc89e8..fdbbf3bd1f 100644
--- a/core/DbHelper.php
+++ b/core/DbHelper.php
@@ -94,6 +94,31 @@ class DbHelper
}
/**
+ * Records the Matomo version a user used when installing this Matomo for the first time
+ */
+ public static function recordInstallVersion()
+ {
+ Schema::getInstance()->recordInstallVersion();
+ }
+
+ /**
+ * Returns which Matomo version was used to install this Matomo for the first time.
+ */
+ public static function getInstallVersion()
+ {
+ return Schema::getInstance()->getInstallVersion();
+ }
+
+ public static function wasMatomoInstalledBeforeVersion($version)
+ {
+ $installVersion = self::getInstallVersion();
+ if (empty($installVersion)) {
+ return true; // we assume yes it was installed
+ }
+ return true === version_compare($version, $installVersion, '>');
+ }
+
+ /**
* Create all tables
*/
public static function createTables()
diff --git a/core/FileIntegrity.php b/core/FileIntegrity.php
index 9f95f2a66e..9840975665 100644
--- a/core/FileIntegrity.php
+++ b/core/FileIntegrity.php
@@ -366,7 +366,7 @@ class FileIntegrity
protected static function isModifiedPathValid($path)
{
- if ($path === 'piwik.js') {
+ if ($path === 'piwik.js' || $path === 'matomo.js') {
// we could have used a postEvent hook to enrich "\Piwik\Manifest::$files;" which would also benefit plugins
// that want to check for file integrity but we do not want to risk to break anything right now. It is not
// as trivial because piwik.js might be already updated, or updated on the next request. We cannot define
diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php
index bfd4ab4aeb..dc208687e7 100644
--- a/core/SettingsPiwik.php
+++ b/core/SettingsPiwik.php
@@ -214,6 +214,15 @@ class SettingsPiwik
}
/**
+ * @see SettingsPiwik::isPiwikInstalled
+ * @return bool
+ */
+ public static function isMatomoInstalled()
+ {
+ return self::isPiwikInstalled();
+ }
+
+ /**
* Return true if Piwik is installed (installation is done).
* @return bool
*/
diff --git a/core/Tracker/Db/Pdo/Mysql.php b/core/Tracker/Db/Pdo/Mysql.php
index 7641b7167a..262d703a68 100644
--- a/core/Tracker/Db/Pdo/Mysql.php
+++ b/core/Tracker/Db/Pdo/Mysql.php
@@ -112,7 +112,7 @@ class Mysql extends Db
$this->connection = @new PDO($this->dsn, $this->username, $this->password, $this->mysqlOptions);
// we may want to setAttribute(PDO::ATTR_TIMEOUT ) to a few seconds (default is 60) in case the DB is locked
- // the piwik.php would stay waiting for the database... bad!
+ // the matomo.php would stay waiting for the database... bad!
// we delete the password from this object "just in case" it could be printed
$this->password = '';
diff --git a/core/Tracker/Db/Pdo/Pgsql.php b/core/Tracker/Db/Pdo/Pgsql.php
index b70122aa4a..930a8bc29b 100644
--- a/core/Tracker/Db/Pdo/Pgsql.php
+++ b/core/Tracker/Db/Pdo/Pgsql.php
@@ -43,7 +43,7 @@ class Pgsql extends Mysql
$this->connection = new PDO($this->dsn, $this->username, $this->password, $config = array());
$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// we may want to setAttribute(PDO::ATTR_TIMEOUT ) to a few seconds (default is 60) in case the DB is locked
- // the piwik.php would stay waiting for the database... bad!
+ // the matomo.php would stay waiting for the database... bad!
// we delete the password from this object "just in case" it could be printed
$this->password = '';
diff --git a/core/Tracker/TrackerCodeGenerator.php b/core/Tracker/TrackerCodeGenerator.php
index 5870f09800..1585186291 100644
--- a/core/Tracker/TrackerCodeGenerator.php
+++ b/core/Tracker/TrackerCodeGenerator.php
@@ -9,6 +9,8 @@
namespace Piwik\Tracker;
use Piwik\Common;
+use Piwik\DbHelper;
+use Piwik\Option;
use Piwik\Piwik;
use Piwik\Plugins\CustomVariables\CustomVariables;
use Piwik\Plugins\SitesManager\API as APISitesManager;
@@ -21,6 +23,17 @@ use Piwik\View;
class TrackerCodeGenerator
{
/**
+ * whether matomo.js|php should be forced over piwik.js|php
+ * @var bool
+ */
+ private $shouldForceMatomoEndpoint = false;
+
+ public function forceMatomoEndpoint()
+ {
+ $this->shouldForceMatomoEndpoint = true;
+ }
+
+ /**
* @param int $idSite
* @param string $piwikUrl http://path/to/piwik/site/
* @param bool $mergeSubdomains
@@ -134,7 +147,9 @@ class TrackerCodeGenerator
'optionsBeforeTrackerUrl' => $optionsBeforeTrackerUrl,
'protocol' => '//',
'loadAsync' => true,
- 'trackNoScript' => $trackNoScript
+ 'trackNoScript' => $trackNoScript,
+ 'matomoJsFilename' => $this->getJsTrackerEndpoint(),
+ 'matomoPhpFilename' => $this->getPhpTrackerEndpoint(),
);
if (SettingsPiwik::isHttpsForced()) {
@@ -191,6 +206,34 @@ class TrackerCodeGenerator
return $jsCode;
}
+ public function getJsTrackerEndpoint()
+ {
+ $name = 'matomo.js';
+ if ($this->shouldPreferPiwikEndpoint()) {
+ $name = 'piwik.js';
+ }
+ return $name;
+ }
+
+ public function getPhpTrackerEndpoint()
+ {
+ $name = 'matomo.php';
+ if ($this->shouldPreferPiwikEndpoint()) {
+ $name = 'piwik.php';
+ }
+ return $name;
+ }
+
+ public function shouldPreferPiwikEndpoint()
+ {
+ if ($this->shouldForceMatomoEndpoint) {
+ return false;
+ }
+
+ // only since 3.7.0 we use the default matomo.js|php... for all other installs we need to keep BC
+ return DbHelper::wasMatomoInstalledBeforeVersion('3.7.0-b1');
+ }
+
private function getJavascriptTagOptions($idSite, $mergeSubdomains, $mergeAliasUrls)
{
try {
diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php
index 737c24c380..c48f065dc7 100644
--- a/core/Tracker/Visit.php
+++ b/core/Tracker/Visit.php
@@ -31,7 +31,7 @@ use Piwik\Tracker\Visit\VisitProperties;
* views, time spent, etc.
*
* Whether a visit is NEW or KNOWN we also save the action in the DB.
- * One request to the piwik.php script is associated to one action.
+ * One request to the matomo.php script is associated to one action.
*
*/
class Visit implements VisitInterface
diff --git a/core/Updater.php b/core/Updater.php
index dded2d245c..ba9a0caa83 100644
--- a/core/Updater.php
+++ b/core/Updater.php
@@ -10,12 +10,12 @@ namespace Piwik;
use Piwik\Columns\Updater as ColumnUpdater;
use Piwik\Container\StaticContainer;
+use Piwik\Plugins\Installation\ServerFilesGenerator;
use Piwik\Updater\Migration;
use Piwik\Updater\Migration\Db\Sql;
use Piwik\Exception\MissingFilePermissionException;
use Piwik\Updater\UpdateObserver;
use Zend_Db_Exception;
-use Piwik\Plugins\Installation\ServerFilesGenerator;
/**
* Load and execute all relevant, incremental update scripts for Piwik core and plugins, and bump the component version numbers for completed updates.
@@ -325,7 +325,7 @@ class Updater
$this->markComponentSuccessfullyUpdated($componentName, $updatedVersion);
$this->executeListenerHook('onComponentUpdateFinished', array($componentName, $updatedVersion, $warningMessages));
-
+ ServerFilesGenerator::createHtAccessFiles();
return $warningMessages;
}