update Piwik to version 2.16 (fixes #91)

This commit is contained in:
oliver 2016-04-10 18:55:57 +02:00
commit d885a4baa9
5833 changed files with 418860 additions and 226988 deletions

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -18,7 +18,7 @@ use Piwik\Updates;
*/
class Updates_0_2_10 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'CREATE TABLE `' . Common::prefixTable('option') . '` (
@ -26,38 +26,33 @@ class Updates_0_2_10 extends Updates
option_name VARCHAR( 64 ) NOT NULL ,
option_value LONGTEXT NOT NULL ,
PRIMARY KEY ( idoption , option_name )
)' => false,
)' => 1050,
// 0.1.7 [463]
'ALTER IGNORE TABLE `' . Common::prefixTable('log_visit') . '`
CHANGE `location_provider` `location_provider` VARCHAR( 100 ) DEFAULT NULL' => '1054',
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
CHANGE `location_provider` `location_provider` VARCHAR( 100 ) DEFAULT NULL' => 1054,
// 0.1.7 [470]
'ALTER TABLE `' . Common::prefixTable('logger_api_call') . '`
CHANGE `parameter_names_default_values` `parameter_names_default_values` TEXT,
CHANGE `parameter_values` `parameter_values` TEXT,
CHANGE `returned_value` `returned_value` TEXT' => false,
CHANGE `returned_value` `returned_value` TEXT' => array(1054, 1146),
'ALTER TABLE `' . Common::prefixTable('logger_error') . '`
CHANGE `message` `message` TEXT' => false,
CHANGE `message` `message` TEXT' => array(1054, 1146),
'ALTER TABLE `' . Common::prefixTable('logger_exception') . '`
CHANGE `message` `message` TEXT' => false,
CHANGE `message` `message` TEXT' => array(1054, 1146),
'ALTER TABLE `' . Common::prefixTable('logger_message') . '`
CHANGE `message` `message` TEXT' => false,
CHANGE `message` `message` TEXT' => 1054,
// 0.2.2 [489]
'ALTER IGNORE TABLE `' . Common::prefixTable('site') . '`
CHANGE `feedburnerName` `feedburnerName` VARCHAR( 100 ) DEFAULT NULL' => '1054',
'ALTER TABLE `' . Common::prefixTable('site') . '`
CHANGE `feedburnerName` `feedburnerName` VARCHAR( 100 ) DEFAULT NULL' => 1054,
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$obsoleteFile = '/plugins/ExamplePlugin/API.php';
if (file_exists(PIWIK_INCLUDE_PATH . $obsoleteFile)) {
@unlink(PIWIK_INCLUDE_PATH . $obsoleteFile);
}
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
$obsoleteDirectories = array(
'/plugins/AdminHome',

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,22 +17,22 @@ use Piwik\Updates;
*/
class Updates_0_2_12 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('site') . '`
CHANGE `ts_created` `ts_created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL' => false,
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
DROP `config_color_depth`' => false,
DROP `config_color_depth`' => 1091,
// 0.2.12 [673]
// Note: requires INDEX privilege
'DROP INDEX index_idaction ON `' . Common::prefixTable('log_action') . '`' => '1091',
'DROP INDEX index_idaction ON `' . Common::prefixTable('log_action') . '`' => 1091,
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_0_2_13 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'DROP TABLE IF EXISTS `' . Common::prefixTable('option') . '`' => false,
@ -27,12 +27,12 @@ class Updates_0_2_13 extends Updates
option_value LONGTEXT NOT NULL ,
autoload TINYINT NOT NULL DEFAULT '1',
PRIMARY KEY ( option_name )
)" => false,
)" => 1050,
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,20 +17,20 @@ use Piwik\Updates;
*/
class Updates_0_2_24 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'CREATE INDEX index_type_name
ON ' . Common::prefixTable('log_action') . ' (type, name(15))' => false,
ON ' . Common::prefixTable('log_action') . ' (type, name(15))' => 1072,
'CREATE INDEX index_idsite_date
ON ' . Common::prefixTable('log_visit') . ' (idsite, visit_server_date)' => false,
'DROP INDEX index_idsite ON ' . Common::prefixTable('log_visit') => false,
'DROP INDEX index_visit_server_date ON ' . Common::prefixTable('log_visit') => false,
ON ' . Common::prefixTable('log_visit') . ' (idsite, visit_server_date)' => 1072,
'DROP INDEX index_idsite ON ' . Common::prefixTable('log_visit') => 1091,
'DROP INDEX index_visit_server_date ON ' . Common::prefixTable('log_visit') => 1091,
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -18,14 +18,14 @@ use Piwik\Updates;
*/
class Updates_0_2_27 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
$sqlarray = array(
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
ADD `visit_goal_converted` VARCHAR( 1 ) NOT NULL AFTER `visit_total_time`' => false,
ADD `visit_goal_converted` VARCHAR( 1 ) NOT NULL AFTER `visit_total_time`' => 1060,
// 0.2.27 [826]
'ALTER IGNORE TABLE `' . Common::prefixTable('log_visit') . '`
CHANGE `visit_goal_converted` `visit_goal_converted` TINYINT(1) NOT NULL' => false,
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
CHANGE `visit_goal_converted` `visit_goal_converted` TINYINT(1) NOT NULL' => 1060,
'CREATE TABLE `' . Common::prefixTable('goal') . "` (
`idsite` int(11) NOT NULL,
@ -38,7 +38,7 @@ class Updates_0_2_27 extends Updates
`revenue` float NOT NULL,
`deleted` tinyint(4) NOT NULL default '0',
PRIMARY KEY (`idsite`,`idgoal`)
)" => false,
)" => 1050,
'CREATE TABLE `' . Common::prefixTable('log_conversion') . '` (
`idvisit` int(10) unsigned NOT NULL,
@ -49,7 +49,6 @@ class Updates_0_2_27 extends Updates
`idaction` int(11) NOT NULL,
`idlink_va` int(11) NOT NULL,
`referer_idvisit` int(10) unsigned default NULL,
`referer_visit_server_date` date default NULL,
`referer_type` int(10) unsigned default NULL,
`referer_name` varchar(70) default NULL,
`referer_keyword` varchar(255) default NULL,
@ -61,21 +60,21 @@ class Updates_0_2_27 extends Updates
`revenue` float default NULL,
PRIMARY KEY (`idvisit`,`idgoal`),
KEY `index_idsite_date` (`idsite`,`visit_server_date`)
)' => false,
)' => 1050,
);
$tables = DbHelper::getTablesInstalled();
foreach ($tables as $tableName) {
if (preg_match('/archive_/', $tableName) == 1) {
$sqlarray['CREATE INDEX index_all ON ' . $tableName . ' (`idsite`,`date1`,`date2`,`name`,`ts_archived`)'] = false;
$sqlarray['CREATE INDEX index_all ON ' . $tableName . ' (`idsite`,`date1`,`date2`,`name`,`ts_archived`)'] = 1072;
}
}
return $sqlarray;
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_0_2_32 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
// 0.2.32 [941]
@ -32,8 +32,8 @@ class Updates_0_2_32 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -18,7 +18,7 @@ use Piwik\Updates;
*/
class Updates_0_2_33 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
$sqlarray = array(
// 0.2.33 [1020]
@ -38,8 +38,8 @@ class Updates_0_2_33 extends Updates
return $sqlarray;
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,28 +0,0 @@
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Piwik;
use Piwik\Plugins\SitesManager\API;
use Piwik\Tracker\Cache;
use Piwik\Updates;
/**
*/
class Updates_0_2_34 extends Updates
{
static function update()
{
// force regeneration of cache files following #648
Piwik::setUserHasSuperUserAccess();
$allSiteIds = API::getInstance()->getAllSitesId();
Cache::regenerateCacheWebsiteAttributes($allSiteIds);
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_0_2_35 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('user_dashboard') . '`
@ -25,8 +25,8 @@ class Updates_0_2_35 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_0_2_37 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'DELETE FROM `' . Common::prefixTable('user_dashboard') . "`
@ -26,8 +26,8 @@ class Updates_0_2_37 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_0_4_1 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('log_conversion') . '`
@ -27,8 +27,8 @@ class Updates_0_4_1 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,22 +17,22 @@ use Piwik\Updates;
*/
class Updates_0_4_2 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
ADD `config_java` TINYINT(1) NOT NULL AFTER `config_flash`' => '1060',
ADD `config_java` TINYINT(1) NOT NULL AFTER `config_flash`' => 1060,
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
ADD `config_quicktime` TINYINT(1) NOT NULL AFTER `config_director`' => '1060',
ADD `config_quicktime` TINYINT(1) NOT NULL AFTER `config_director`' => 1060,
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
ADD `config_gears` TINYINT(1) NOT NULL AFTER `config_windowsmedia`,
ADD `config_silverlight` TINYINT(1) NOT NULL AFTER `config_gears`' => false,
ADD `config_silverlight` TINYINT(1) NOT NULL AFTER `config_gears`' => 1060,
);
}
// when restoring (possibly) previousy dropped columns, ignore mysql code error 1060: duplicate column
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -11,12 +11,13 @@ namespace Piwik\Updates;
use Piwik\Piwik;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_0_4_4 extends Updates
{
static function update()
public function doUpdate(Updater $updater)
{
$obsoleteFile = PIWIK_DOCUMENT_ROOT . '/libs/open-flash-chart/php-ofc-library/ofc_upload_image.php';
if (file_exists($obsoleteFile)) {

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,23 +17,23 @@ use Piwik\Updates;
*/
class Updates_0_4 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
// 0.4 [1140]
'UPDATE `' . Common::prefixTable('log_visit') . '`
SET location_ip=location_ip+CAST(POW(2,32) AS UNSIGNED) WHERE location_ip < 0' => false,
SET location_ip=location_ip+CAST(POW(2,32) AS UNSIGNED) WHERE location_ip < 0' => false,
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
CHANGE `location_ip` `location_ip` BIGINT UNSIGNED NOT NULL' => false,
CHANGE `location_ip` `location_ip` BIGINT UNSIGNED NOT NULL' => 1054,
'UPDATE `' . Common::prefixTable('logger_api_call') . '`
SET caller_ip=caller_ip+CAST(POW(2,32) AS UNSIGNED) WHERE caller_ip < 0' => false,
SET caller_ip=caller_ip+CAST(POW(2,32) AS UNSIGNED) WHERE caller_ip < 0' => 1146,
'ALTER TABLE `' . Common::prefixTable('logger_api_call') . '`
CHANGE `caller_ip` `caller_ip` BIGINT UNSIGNED' => false,
CHANGE `caller_ip` `caller_ip` BIGINT UNSIGNED' => 1146,
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -18,7 +18,7 @@ use Piwik\Updates;
*/
class Updates_0_5_4 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('log_action') . '`
@ -26,7 +26,7 @@ class Updates_0_5_4 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
$salt = Common::generateUniqId();
$config = Config::getInstance();
@ -60,6 +60,6 @@ class Updates_0_5_4 extends Updates
}
}
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -18,29 +18,28 @@ use Piwik\Updates;
*/
class Updates_0_5_5 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
$sqlarray = array(
'DROP INDEX index_idsite_date ON ' . Common::prefixTable('log_visit') => '1091',
'CREATE INDEX index_idsite_date_config ON ' . Common::prefixTable('log_visit') . ' (idsite, visit_server_date, config_md5config(8))' => '1061',
'DROP INDEX index_idsite_date ON ' . Common::prefixTable('log_visit') => 1091,
'CREATE INDEX index_idsite_date_config ON ' . Common::prefixTable('log_visit') . ' (idsite, visit_server_date, config_md5config(8))' => array(1061,1072),
);
$tables = DbHelper::getTablesInstalled();
foreach ($tables as $tableName) {
if (preg_match('/archive_/', $tableName) == 1) {
$sqlarray['DROP INDEX index_all ON ' . $tableName] = '1091';
$sqlarray['DROP INDEX index_all ON ' . $tableName] = 1091;
}
if (preg_match('/archive_numeric_/', $tableName) == 1) {
$sqlarray['CREATE INDEX index_idsite_dates_period ON ' . $tableName . ' (idsite, date1, date2, period)'] = '1061';
$sqlarray['CREATE INDEX index_idsite_dates_period ON ' . $tableName . ' (idsite, date1, date2, period)'] = 1061;
}
}
return $sqlarray;
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,24 +17,24 @@ use Piwik\Updates;
*/
class Updates_0_5 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE ' . Common::prefixTable('log_action') . ' ADD COLUMN `hash` INTEGER(10) UNSIGNED NOT NULL AFTER `name`;' => '1060',
'ALTER TABLE ' . Common::prefixTable('log_visit') . ' CHANGE visit_exit_idaction visit_exit_idaction_url INTEGER(11) NOT NULL;' => '1054',
'ALTER TABLE ' . Common::prefixTable('log_visit') . ' CHANGE visit_entry_idaction visit_entry_idaction_url INTEGER(11) NOT NULL;' => '1054',
'ALTER TABLE ' . Common::prefixTable('log_link_visit_action') . ' CHANGE `idaction_ref` `idaction_url_ref` INTEGER(10) UNSIGNED NOT NULL;' => '1054',
'ALTER TABLE ' . Common::prefixTable('log_link_visit_action') . ' CHANGE `idaction` `idaction_url` INTEGER(10) UNSIGNED NOT NULL;' => '1054',
'ALTER TABLE ' . Common::prefixTable('log_link_visit_action') . ' ADD COLUMN `idaction_name` INTEGER(10) UNSIGNED AFTER `idaction_url_ref`;' => '1060',
'ALTER TABLE ' . Common::prefixTable('log_conversion') . ' CHANGE `idaction` `idaction_url` INTEGER(11) UNSIGNED NOT NULL;' => '1054',
'ALTER TABLE ' . Common::prefixTable('log_action') . ' ADD COLUMN `hash` INTEGER(10) UNSIGNED NOT NULL AFTER `name`;' => 1060,
'ALTER TABLE ' . Common::prefixTable('log_visit') . ' CHANGE visit_exit_idaction visit_exit_idaction_url INTEGER(11) NOT NULL;' => 1054,
'ALTER TABLE ' . Common::prefixTable('log_visit') . ' CHANGE visit_entry_idaction visit_entry_idaction_url INTEGER(11) NOT NULL;' => 1054,
'ALTER TABLE ' . Common::prefixTable('log_link_visit_action') . ' CHANGE `idaction_ref` `idaction_url_ref` INTEGER(10) UNSIGNED NOT NULL;' => 1054,
'ALTER TABLE ' . Common::prefixTable('log_link_visit_action') . ' CHANGE `idaction` `idaction_url` INTEGER(10) UNSIGNED NOT NULL;' => 1054,
'ALTER TABLE ' . Common::prefixTable('log_link_visit_action') . ' ADD COLUMN `idaction_name` INTEGER(10) UNSIGNED AFTER `idaction_url_ref`;' => 1060,
'ALTER TABLE ' . Common::prefixTable('log_conversion') . ' CHANGE `idaction` `idaction_url` INTEGER(11) UNSIGNED NOT NULL;' => 1054,
'UPDATE ' . Common::prefixTable('log_action') . ' SET `hash` = CRC32(name);' => false,
'CREATE INDEX index_type_hash ON ' . Common::prefixTable('log_action') . ' (type, hash);' => '1061',
'DROP INDEX index_type_name ON ' . Common::prefixTable('log_action') . ';' => '1091',
'CREATE INDEX index_type_hash ON ' . Common::prefixTable('log_action') . ' (type, hash);' => 1061,
'DROP INDEX index_type_name ON ' . Common::prefixTable('log_action') . ';' => 1091,
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,33 +17,33 @@ use Piwik\Updates;
*/
class Updates_0_6_rc1 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
$defaultTimezone = 'UTC';
$defaultCurrency = 'USD';
return array(
'ALTER TABLE ' . Common::prefixTable('user') . ' CHANGE date_registered date_registered TIMESTAMP NULL' => false,
'ALTER TABLE ' . Common::prefixTable('site') . ' CHANGE ts_created ts_created TIMESTAMP NULL' => false,
'ALTER TABLE ' . Common::prefixTable('site') . ' ADD `timezone` VARCHAR( 50 ) NOT NULL AFTER `ts_created` ;' => false,
'UPDATE ' . Common::prefixTable('site') . ' SET `timezone` = "' . $defaultTimezone . '";' => false,
'ALTER TABLE ' . Common::prefixTable('site') . ' ADD currency CHAR( 3 ) NOT NULL AFTER `timezone` ;' => false,
'UPDATE ' . Common::prefixTable('site') . ' SET `currency` = "' . $defaultCurrency . '";' => false,
'ALTER TABLE ' . Common::prefixTable('site') . ' ADD `excluded_ips` TEXT NOT NULL AFTER `currency` ;' => false,
'ALTER TABLE ' . Common::prefixTable('site') . ' ADD excluded_parameters VARCHAR( 255 ) NOT NULL AFTER `excluded_ips` ;' => false,
'ALTER TABLE ' . Common::prefixTable('log_visit') . ' ADD INDEX `index_idsite_datetime_config` ( `idsite` , `visit_last_action_time` , `config_md5config` ( 8 ) ) ;' => false,
'ALTER TABLE ' . Common::prefixTable('log_visit') . ' ADD INDEX index_idsite_idvisit (idsite, idvisit) ;' => false,
'ALTER TABLE ' . Common::prefixTable('log_conversion') . ' DROP INDEX index_idsite_date' => false,
'ALTER TABLE ' . Common::prefixTable('log_conversion') . ' DROP visit_server_date;' => false,
'ALTER TABLE ' . Common::prefixTable('log_conversion') . ' ADD INDEX index_idsite_datetime ( `idsite` , `server_time` )' => false,
'ALTER TABLE ' . Common::prefixTable('user') . ' CHANGE date_registered date_registered TIMESTAMP NULL' => 1054,
'ALTER TABLE ' . Common::prefixTable('site') . ' CHANGE ts_created ts_created TIMESTAMP NULL' => 1054,
'ALTER TABLE ' . Common::prefixTable('site') . ' ADD `timezone` VARCHAR( 50 ) NOT NULL AFTER `ts_created` ;' => 1060,
'UPDATE ' . Common::prefixTable('site') . ' SET `timezone` = "' . $defaultTimezone . '";' => 1060,
'ALTER TABLE ' . Common::prefixTable('site') . ' ADD currency CHAR( 3 ) NOT NULL AFTER `timezone` ;' => 1060,
'UPDATE ' . Common::prefixTable('site') . ' SET `currency` = "' . $defaultCurrency . '";' => 1060,
'ALTER TABLE ' . Common::prefixTable('site') . ' ADD `excluded_ips` TEXT NOT NULL AFTER `currency` ;' => 1060,
'ALTER TABLE ' . Common::prefixTable('site') . ' ADD excluded_parameters VARCHAR( 255 ) NOT NULL AFTER `excluded_ips` ;' => 1060,
'ALTER TABLE ' . Common::prefixTable('log_visit') . ' ADD INDEX `index_idsite_datetime_config` ( `idsite` , `visit_last_action_time` , `config_md5config` ( 8 ) ) ;' => array(1061, 1072),
'ALTER TABLE ' . Common::prefixTable('log_visit') . ' ADD INDEX index_idsite_idvisit (idsite, idvisit) ;' => array(1061, 1072),
'ALTER TABLE ' . Common::prefixTable('log_conversion') . ' DROP INDEX index_idsite_date' => 1091,
'ALTER TABLE ' . Common::prefixTable('log_conversion') . ' DROP visit_server_date;' => 1091,
'ALTER TABLE ' . Common::prefixTable('log_conversion') . ' ADD INDEX index_idsite_datetime ( `idsite` , `server_time` )' => array(1072, 1061),
);
}
static function update()
public function doUpdate(Updater $updater)
{
// first we disable the plugins and keep an array of warnings messages
$pluginsToDisableMessage = array(
'SearchEnginePosition' => "SearchEnginePosition plugin was disabled, because it is not compatible with the new Piwik 0.6. \n You can download the latest version of the plugin, compatible with Piwik 0.6.\n<a target='_blank' href='?module=Proxy&action=redirect&url=http://dev.piwik.org/trac/ticket/502'>Click here.</a>",
'GeoIP' => "GeoIP plugin was disabled, because it is not compatible with the new Piwik 0.6. \nYou can download the latest version of the plugin, compatible with Piwik 0.6.\n<a target='_blank' href='?module=Proxy&action=redirect&url=http://dev.piwik.org/trac/ticket/45'>Click here.</a>"
'SearchEnginePosition' => "SearchEnginePosition plugin was disabled, because it is not compatible with the new Piwik 0.6. \n You can download the latest version of the plugin, compatible with Piwik 0.6.\n<a target='_blank' href='?module=Proxy&action=redirect&url=https://github.com/piwik/piwik/issues/502'>Click here.</a>",
'GeoIP' => "GeoIP plugin was disabled, because it is not compatible with the new Piwik 0.6. \nYou can download the latest version of the plugin, compatible with Piwik 0.6.\n<a target='_blank' href='?module=Proxy&action=redirect&url=https://github.com/piwik/piwik/issues/45'>Click here.</a>"
);
$disabledPlugins = array();
foreach ($pluginsToDisableMessage as $pluginToDisable => $warningMessage) {
@ -54,7 +54,7 @@ class Updates_0_6_rc1 extends Updates
}
// Run the SQL
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
// Outputs warning message, pointing users to the plugin download page
if (!empty($disabledPlugins)) {

View file

@ -1,47 +0,0 @@
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Filesystem;
use Piwik\Piwik;
use Piwik\Plugins\SitesManager\API;
use Piwik\Tracker\Cache;
use Piwik\Updates;
/**
*/
class Updates_0_6_2 extends Updates
{
static function update()
{
$obsoleteFiles = array(
PIWIK_INCLUDE_PATH . '/core/Db/Mysqli.php',
);
foreach ($obsoleteFiles as $obsoleteFile) {
if (file_exists($obsoleteFile)) {
@unlink($obsoleteFile);
}
}
$obsoleteDirectories = array(
PIWIK_INCLUDE_PATH . '/core/Db/Pdo',
);
foreach ($obsoleteDirectories as $dir) {
if (file_exists($dir)) {
Filesystem::unlinkRecursive($dir, true);
}
}
// force regeneration of cache files
Piwik::setUserHasSuperUserAccess();
$allSiteIds = API::getInstance()->getAllSitesId();
Cache::regenerateCacheWebsiteAttributes($allSiteIds);
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -18,17 +18,17 @@ use Piwik\Updates;
*/
class Updates_0_6_3 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
CHANGE `location_ip` `location_ip` INT UNSIGNED NOT NULL' => false,
CHANGE `location_ip` `location_ip` INT UNSIGNED NOT NULL' => 1054,
'ALTER TABLE `' . Common::prefixTable('logger_api_call') . '`
CHANGE `caller_ip` `caller_ip` INT UNSIGNED' => false,
CHANGE `caller_ip` `caller_ip` INT UNSIGNED' => array(1054, 1146),
);
}
static function update()
public function doUpdate(Updater $updater)
{
$config = Config::getInstance();
$dbInfos = $config->database;
@ -44,6 +44,6 @@ class Updates_0_6_3 extends Updates
}
}
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_0_7 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('option') . '`
@ -25,8 +25,8 @@ class Updates_0_7 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -18,7 +18,7 @@ use Piwik\Updates;
*/
class Updates_0_9_1 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
if (!SettingsServer::isTimezoneSupportEnabled()) {
return array();
@ -38,20 +38,20 @@ class Updates_0_9_1 extends Updates
return array(
'UPDATE ' . Common::prefixTable('site') . '
SET timezone = "UTC"
SET timezone = "UTC"
WHERE timezone IN (' . $timezoneList . ')' => false,
'UPDATE `' . Common::prefixTable('option') . '`
SET option_value = "UTC"
WHERE option_name = "SitesManager_DefaultTimezone"
SET option_value = "UTC"
WHERE option_name = "SitesManager_DefaultTimezone"
AND option_value IN (' . $timezoneList . ')' => false,
);
}
static function update()
public function doUpdate(Updater $updater)
{
if (SettingsServer::isTimezoneSupportEnabled()) {
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -12,12 +12,13 @@ namespace Piwik\Updates;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_1_1 extends Updates
{
static function update()
public function doUpdate(Updater $updater)
{
$config = Config::getInstance();

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,17 +10,18 @@
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_1_10_b4 extends Updates
{
static function isMajorUpdate()
public static function isMajorUpdate()
{
return false;
}
static function update()
public function doUpdate(Updater $updater)
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('MobileMessaging');

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,17 +10,18 @@
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_1_10_1 extends Updates
{
static function isMajorUpdate()
public static function isMajorUpdate()
{
return false;
}
static function update()
public function doUpdate(Updater $updater)
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('Overlay');

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_1_10_2_b1 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
// ignore existing column name error (1060)
@ -26,8 +26,8 @@ class Updates_1_10_2_b1 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_1_10_2_b2 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
// ignore existing column name error (1060)
@ -26,8 +26,8 @@ class Updates_1_10_2_b2 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,17 +10,18 @@
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_1_11_b1 extends Updates
{
static function isMajorUpdate()
public static function isMajorUpdate()
{
return false;
}
static function update()
public function doUpdate(Updater $updater)
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('UserCountryMap');

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,12 +17,12 @@ use Piwik\Updates;
*/
class Updates_1_12_b1 extends Updates
{
static function isMajorUpdate()
public static function isMajorUpdate()
{
return true;
}
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('log_link_visit_action') . '`
@ -30,9 +30,8 @@ class Updates_1_12_b1 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,12 +10,13 @@
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_1_12_b15 extends Updates
{
static function update()
public function doUpdate(Updater $updater)
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('SegmentEditor');

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_1_12_b16 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
// ignore existing column name error (1060)
@ -26,8 +26,8 @@ class Updates_1_12_b16 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_1_2_rc1 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
// Various performance improvements schema updates
@ -25,17 +25,19 @@ class Updates_1_2_rc1 extends Updates
DROP `visit_server_date`,
DROP INDEX `index_idsite_date_config`,
DROP INDEX `index_idsite_datetime_config`,
ADD `idvisitor` BINARY(8) NOT NULL AFTER `idsite`,
ADD `config_id` BINARY(8) NOT NULL AFTER `config_md5config`
' => array(1054, 1091),
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
ADD `visit_entry_idaction_name` INT UNSIGNED NOT NULL AFTER `visit_entry_idaction_url`,
ADD `visit_exit_idaction_name` INT UNSIGNED NOT NULL AFTER `visit_exit_idaction_url`,
CHANGE `visit_exit_idaction_url` `visit_exit_idaction_url` INT UNSIGNED NOT NULL,
CHANGE `visit_exit_idaction_url` `visit_exit_idaction_url` INT UNSIGNED NOT NULL,
CHANGE `visit_entry_idaction_url` `visit_entry_idaction_url` INT UNSIGNED NOT NULL,
CHANGE `referer_type` `referer_type` TINYINT UNSIGNED NULL DEFAULT NULL,
ADD `idvisitor` BINARY(8) NOT NULL AFTER `idsite`,
ADD visitor_count_visits SMALLINT(5) UNSIGNED NOT NULL AFTER `visitor_returning`,
ADD visitor_days_since_last SMALLINT(5) UNSIGNED NOT NULL,
ADD visitor_days_since_first SMALLINT(5) UNSIGNED NOT NULL,
ADD `config_id` BINARY(8) NOT NULL AFTER `config_md5config`
' => false,
ADD visitor_days_since_first SMALLINT(5) UNSIGNED NOT NULL
' => 1060,
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
ADD custom_var_k1 VARCHAR(100) DEFAULT NULL,
ADD custom_var_v1 VARCHAR(100) DEFAULT NULL,
@ -49,19 +51,23 @@ class Updates_1_2_rc1 extends Updates
ADD custom_var_v5 VARCHAR(100) DEFAULT NULL
' => 1060,
'ALTER TABLE `' . Common::prefixTable('log_link_visit_action') . '`
ADD `idsite` INT( 10 ) UNSIGNED NOT NULL AFTER `idlink_va` ,
ADD `server_time` DATETIME AFTER `idsite`,
ADD `idsite` INT( 10 ) UNSIGNED NOT NULL AFTER `idlink_va` ,
ADD `idvisitor` BINARY(8) NOT NULL AFTER `idsite`,
ADD `idaction_name_ref` INT UNSIGNED NOT NULL AFTER `idaction_name`,
ADD `idaction_name_ref` INT UNSIGNED NOT NULL AFTER `idaction_name`
' => 1060,
'ALTER TABLE `' . Common::prefixTable('log_link_visit_action') . '`
ADD `server_time` DATETIME AFTER `idsite`,
ADD INDEX `index_idsite_servertime` ( `idsite` , `server_time` )
' => false,
' => 1060,
'ALTER TABLE `' . Common::prefixTable('log_conversion') . '`
DROP `referer_idvisit`,
ADD `idvisitor` BINARY(8) NOT NULL AFTER `idsite`,
ADD `idvisitor` BINARY(8) NOT NULL AFTER `idsite`
' => array(1060, 1091),
'ALTER TABLE `' . Common::prefixTable('log_conversion') . '`
ADD visitor_count_visits SMALLINT(5) UNSIGNED NOT NULL,
ADD visitor_days_since_first SMALLINT(5) UNSIGNED NOT NULL
' => false,
' => 1060,
'ALTER TABLE `' . Common::prefixTable('log_conversion') . '`
ADD custom_var_k1 VARCHAR(100) DEFAULT NULL,
ADD custom_var_v1 VARCHAR(100) DEFAULT NULL,
@ -73,36 +79,36 @@ class Updates_1_2_rc1 extends Updates
ADD custom_var_v4 VARCHAR(100) DEFAULT NULL,
ADD custom_var_k5 VARCHAR(100) DEFAULT NULL,
ADD custom_var_v5 VARCHAR(100) DEFAULT NULL
' => 1060,
' => array(1060, 1061),
// Migrate 128bits IDs inefficiently stored as 8bytes (256 bits) into 64bits
'UPDATE ' . Common::prefixTable('log_visit') . '
SET idvisitor = binary(unhex(substring(visitor_idcookie,1,16))),
config_id = binary(unhex(substring(config_md5config,1,16)))
' => false,
' => 1054,
'UPDATE ' . Common::prefixTable('log_conversion') . '
SET idvisitor = binary(unhex(substring(visitor_idcookie,1,16)))
' => false,
' => 1054,
// Drop migrated fields
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
DROP visitor_idcookie,
DROP visitor_idcookie,
DROP config_md5config
' => false,
' => 1091,
'ALTER TABLE `' . Common::prefixTable('log_conversion') . '`
DROP visitor_idcookie
' => false,
' => 1091,
// Recreate INDEX on new field
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
ADD INDEX `index_idsite_datetime_config` (idsite, visit_last_action_time, config_id)
' => false,
' => 1061,
// Backfill action logs as best as we can
'UPDATE ' . Common::prefixTable('log_link_visit_action') . ' as action,
' . Common::prefixTable('log_visit') . ' as visit
SET action.idsite = visit.idsite,
action.server_time = visit.visit_last_action_time,
SET action.idsite = visit.idsite,
action.server_time = visit.visit_last_action_time,
action.idvisitor = visit.idvisitor
WHERE action.idvisit=visit.idvisit
' => false,
@ -112,18 +118,18 @@ class Updates_1_2_rc1 extends Updates
' => false,
// New index used max once per request, in case this table grows significantly in the future
'ALTER TABLE `' . Common::prefixTable('option') . '` ADD INDEX ( `autoload` ) ' => false,
'ALTER TABLE `' . Common::prefixTable('option') . '` ADD INDEX ( `autoload` ) ' => 1061,
// new field for websites
'ALTER TABLE `' . Common::prefixTable('site') . '` ADD `group` VARCHAR( 250 ) NOT NULL' => false,
'ALTER TABLE `' . Common::prefixTable('site') . '` ADD `group` VARCHAR( 250 ) NOT NULL' => 1060,
);
}
static function update()
public function doUpdate(Updater $updater)
{
// first we disable the plugins and keep an array of warnings messages
$pluginsToDisableMessage = array(
'GeoIP' => "GeoIP plugin was disabled, because it is not compatible with the new Piwik 1.2. \nYou can download the latest version of the plugin, compatible with Piwik 1.2.\n<a target='_blank' href='?module=Proxy&action=redirect&url=http://dev.piwik.org/trac/ticket/45'>Click here.</a>",
'GeoIP' => "GeoIP plugin was disabled, because it is not compatible with the new Piwik 1.2. \nYou can download the latest version of the plugin, compatible with Piwik 1.2.\n<a target='_blank' href='?module=Proxy&action=redirect&url=https://github.com/piwik/piwik/issues/45'>Click here.</a>",
'EntryPage' => "EntryPage plugin is not compatible with this version of Piwik, it was disabled.",
);
$disabledPlugins = array();
@ -135,7 +141,7 @@ class Updates_1_2_rc1 extends Updates
}
// Run the SQL
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
// Outputs warning message, pointing users to the plugin download page
if (!empty($disabledPlugins)) {
@ -144,7 +150,5 @@ class Updates_1_2_rc1 extends Updates
implode('</li><li>', $disabledPlugins) .
"</li></ul>");
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,12 +10,13 @@
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_1_2_rc2 extends Updates
{
static function update()
public function doUpdate(Updater $updater)
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('CustomVariables');
@ -23,4 +24,3 @@ class Updates_1_2_rc2 extends Updates
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -18,24 +18,23 @@ use Piwik\Updates;
*/
class Updates_1_2_3 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
// LOAD DATA INFILE uses the database's charset
'ALTER DATABASE `' . Config::getInstance()->database['dbname'] . '` DEFAULT CHARACTER SET utf8' => false,
'ALTER DATABASE `' . Config::getInstance()->database['dbname'] . '` DEFAULT CHARACTER SET utf8' => false,
// Various performance improvements schema updates
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
DROP INDEX index_idsite_datetime_config,
DROP INDEX index_idsite_idvisit,
ADD INDEX index_idsite_config_datetime (idsite, config_id, visit_last_action_time),
ADD INDEX index_idsite_datetime (idsite, visit_last_action_time)' => false,
ADD INDEX index_idsite_datetime (idsite, visit_last_action_time)' => array(1061, 1091),
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,21 +17,20 @@ use Piwik\Updates;
*/
class Updates_1_2_5_rc1 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('goal') . '`
ADD `allow_multiple` tinyint(4) NOT NULL AFTER case_sensitive' => false,
ADD `allow_multiple` tinyint(4) NOT NULL AFTER case_sensitive' => 1060,
'ALTER TABLE `' . Common::prefixTable('log_conversion') . '`
ADD buster int unsigned NOT NULL AFTER revenue,
DROP PRIMARY KEY,
ADD PRIMARY KEY (idvisit, idgoal, buster)' => false,
ADD PRIMARY KEY (idvisit, idgoal, buster)' => 1060,
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,18 +17,16 @@ use Piwik\Updates;
*/
class Updates_1_2_5_rc7 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
ADD INDEX index_idsite_idvisitor (idsite, idvisitor)' => false,
ADD INDEX index_idsite_idvisitor (idsite, idvisitor)' => 1061,
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,20 +17,20 @@ use Piwik\Updates;
*/
class Updates_1_4_rc1 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'UPDATE `' . Common::prefixTable('pdf') . '`
SET format = "pdf"' => '42S22',
SET format = "pdf"' => '42S22',
'ALTER TABLE `' . Common::prefixTable('pdf') . '`
ADD COLUMN `format` VARCHAR(10)' => '42S22',
);
}
static function update()
public function doUpdate(Updater $updater)
{
try {
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
} catch (\Exception $e) {
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,28 +17,28 @@ use Piwik\Updates;
*/
class Updates_1_4_rc2 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
"SET sql_mode=''" => false,
"SET sql_mode=''" => false,
// this converts the 32-bit UNSIGNED INT column to a 16 byte VARBINARY;
// _but_ MySQL does string conversion! (e.g., integer 1 is converted to 49 -- the ASCII code for "1")
'ALTER TABLE ' . Common::prefixTable('log_visit') . '
MODIFY location_ip VARBINARY(16) NOT NULL' => false,
'ALTER TABLE ' . Common::prefixTable('logger_api_call') . '
MODIFY caller_ip VARBINARY(16) NOT NULL' => false,
MODIFY caller_ip VARBINARY(16) NOT NULL' => 1146,
// fortunately, 2^32 is 10 digits long and fits in the VARBINARY(16) without truncation;
// to fix this, we cast to an integer, convert to hex, pad out leading zeros, and unhex it
'UPDATE ' . Common::prefixTable('log_visit') . "
SET location_ip = UNHEX(LPAD(HEX(CONVERT(location_ip, UNSIGNED)), 8, '0'))" => false,
'UPDATE ' . Common::prefixTable('logger_api_call') . "
SET caller_ip = UNHEX(LPAD(HEX(CONVERT(caller_ip, UNSIGNED)), 8, '0'))" => false,
SET caller_ip = UNHEX(LPAD(HEX(CONVERT(caller_ip, UNSIGNED)), 8, '0'))" => 1146,
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -9,7 +9,6 @@
namespace Piwik\Updates;
use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;
@ -18,8 +17,10 @@ use Piwik\Updates;
*/
class Updates_1_5_b1 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
$logConversionTable = Common::prefixTable('log_conversion');
return array(
'CREATE TABLE `' . Common::prefixTable('log_conversion_item') . '` (
idsite int(10) UNSIGNED NOT NULL,
@ -27,37 +28,39 @@ class Updates_1_5_b1 extends Updates
server_time DATETIME NOT NULL,
idvisit INTEGER(10) UNSIGNED NOT NULL,
idorder varchar(100) NOT NULL,
idaction_sku INTEGER(10) UNSIGNED NOT NULL,
idaction_name INTEGER(10) UNSIGNED NOT NULL,
idaction_category INTEGER(10) UNSIGNED NOT NULL,
price FLOAT NOT NULL,
quantity INTEGER(10) UNSIGNED NOT NULL,
deleted TINYINT(1) UNSIGNED NOT NULL,
PRIMARY KEY(idvisit, idorder, idaction_sku),
INDEX index_idsite_servertime ( idsite, server_time )
) DEFAULT CHARSET=utf8 ' => false,
) DEFAULT CHARSET=utf8 ' => 1050,
'ALTER IGNORE TABLE `' . Common::prefixTable('log_visit') . '`
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
ADD visitor_days_since_order SMALLINT(5) UNSIGNED NOT NULL AFTER visitor_days_since_last,
ADD visit_goal_buyer TINYINT(1) NOT NULL AFTER visit_goal_converted' => false,
ADD visit_goal_buyer TINYINT(1) NOT NULL AFTER visit_goal_converted' => 1060,
'ALTER IGNORE TABLE `' . Common::prefixTable('log_conversion') . '`
ADD visitor_days_since_order SMALLINT(5) UNSIGNED NOT NULL AFTER visitor_days_since_first,
'ALTER TABLE `' . $logConversionTable . '`
ADD visitor_days_since_order SMALLINT(5) UNSIGNED NOT NULL AFTER visitor_days_since_first' => 1060,
'ALTER TABLE `' . $logConversionTable . '`
ADD idorder varchar(100) default NULL AFTER buster,
ADD items SMALLINT UNSIGNED DEFAULT NULL,
ADD revenue_subtotal float default NULL,
ADD revenue_tax float default NULL,
ADD revenue_shipping float default NULL,
ADD revenue_discount float default NULL,
ADD UNIQUE KEY unique_idsite_idorder (idsite, idorder),
MODIFY idgoal int(10) NOT NULL' => false,
MODIFY idgoal int(10) NOT NULL' => 1060,
'ALTER TABLE `' . Common::prefixTable('log_conversion') . '`
ADD UNIQUE KEY unique_idsite_idorder (idsite, idorder)' => 1061,
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_1_5_b2 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('log_link_visit_action') . '`
@ -34,8 +34,8 @@ class Updates_1_5_b2 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_1_5_b3 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
@ -56,8 +56,8 @@ class Updates_1_5_b3 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,16 +17,16 @@ use Piwik\Updates;
*/
class Updates_1_5_b4 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('site') . '`
ADD ecommerce TINYINT DEFAULT 0' => false,
ADD ecommerce TINYINT DEFAULT 0' => 1060,
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_1_5_b5 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'CREATE TABLE `' . Common::prefixTable('session') . '` (
@ -26,12 +26,12 @@ class Updates_1_5_b5 extends Updates
lifetime INTEGER,
data TEXT,
PRIMARY KEY ( id )
) DEFAULT CHARSET=utf8' => false,
) DEFAULT CHARSET=utf8' => 1050,
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,12 +10,13 @@
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_1_5_rc6 extends Updates
{
static function update()
public function doUpdate(Updater $updater)
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('PrivacyManager');
@ -23,4 +24,3 @@ class Updates_1_5_rc6 extends Updates
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,14 +17,14 @@ use Piwik\Updates;
*/
class Updates_1_6_b1 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('log_conversion_item') . '`
ADD idaction_category2 INTEGER(10) UNSIGNED NOT NULL AFTER idaction_category,
ADD idaction_category3 INTEGER(10) UNSIGNED NOT NULL,
ADD idaction_category4 INTEGER(10) UNSIGNED NOT NULL,
ADD idaction_category5 INTEGER(10) UNSIGNED NOT NULL' => false,
ADD idaction_category5 INTEGER(10) UNSIGNED NOT NULL' => 1060,
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
CHANGE custom_var_k1 custom_var_k1 VARCHAR(200) DEFAULT NULL,
CHANGE custom_var_v1 custom_var_v1 VARCHAR(200) DEFAULT NULL,
@ -61,8 +61,8 @@ class Updates_1_6_b1 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,12 +10,13 @@
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_1_6_rc1 extends Updates
{
static function update()
public function doUpdate(Updater $updater)
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('ImageGraph');
@ -23,4 +24,3 @@ class Updates_1_6_rc1 extends Updates
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,20 +17,20 @@ use Piwik\Updates;
*/
class Updates_1_7_b1 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('pdf') . '`
ADD COLUMN `aggregate_reports_format` TINYINT(1) NOT NULL AFTER `reports`' => false,
ADD COLUMN `aggregate_reports_format` TINYINT(1) NOT NULL AFTER `reports`' => 1060,
'UPDATE `' . Common::prefixTable('pdf') . '`
SET `aggregate_reports_format` = 1' => false,
);
}
static function update()
public function doUpdate(Updater $updater)
{
try {
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
} catch (\Exception $e) {
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_1_7_2_rc5 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('pdf') . '`
@ -25,10 +25,10 @@ class Updates_1_7_2_rc5 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
try {
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
} catch (\Exception $e) {
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -18,19 +18,19 @@ use Piwik\Updates;
*/
class Updates_1_7_2_rc7 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('user_dashboard') . '`
ADD `name` VARCHAR( 100 ) NULL DEFAULT NULL AFTER `iddashboard`' => false,
ADD `name` VARCHAR( 100 ) NULL DEFAULT NULL AFTER `iddashboard`' => 1060,
);
}
static function update()
public function doUpdate(Updater $updater)
{
try {
$dashboards = Db::fetchAll('SELECT * FROM `' . Common::prefixTable('user_dashboard') . '`');
foreach ($dashboards AS $dashboard) {
foreach ($dashboards as $dashboard) {
$idDashboard = $dashboard['iddashboard'];
$login = $dashboard['login'];
$layout = $dashboard['layout'];
@ -38,7 +38,7 @@ class Updates_1_7_2_rc7 extends Updates
$layout = str_replace("\\\"", "\"", $layout);
Db::query('UPDATE `' . Common::prefixTable('user_dashboard') . '` SET layout = ? WHERE iddashboard = ? AND login = ?', array($layout, $idDashboard, $login));
}
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
} catch (\Exception $e) {
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -20,7 +20,7 @@ use Piwik\Updates;
class Updates_1_8_3_b1 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('site') . '`
@ -44,9 +44,9 @@ class Updates_1_8_3_b1 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
if (!\Piwik\Plugin\Manager::getInstance()->isPluginLoaded('ScheduledReports')) {
return;
}
@ -60,8 +60,7 @@ class Updates_1_8_3_b1 extends Updates
// - delete Common::prefixTable('pdf')
$reports = Db::fetchAll('SELECT * FROM `' . Common::prefixTable('pdf') . '`');
foreach ($reports AS $report) {
foreach ($reports as $report) {
$idreport = $report['idreport'];
$idsite = $report['idsite'];
$login = $report['login'];
@ -98,8 +97,8 @@ class Updates_1_8_3_b1 extends Updates
is_null($period) ? ScheduledReports::DEFAULT_PERIOD : $period,
ScheduledReports::EMAIL_TYPE,
is_null($format) ? ScheduledReports::DEFAULT_REPORT_FORMAT : $format,
Common::json_encode(preg_split('/,/', $reports)),
Common::json_encode($parameters),
json_encode(preg_split('/,/', $reports)),
json_encode($parameters),
$ts_created,
$ts_last_sent,
$deleted
@ -110,6 +109,5 @@ class Updates_1_8_3_b1 extends Updates
Db::query('DROP TABLE `' . Common::prefixTable('pdf') . '`');
} catch (\Exception $e) {
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -18,12 +18,12 @@ use Piwik\Updates;
class Updates_1_8_4_b1 extends Updates
{
static function isMajorUpdate()
public static function isMajorUpdate()
{
return true;
}
static function getSql()
public function getMigrationQueries(Updater $updater)
{
$action = Common::prefixTable('log_action');
$duplicates = Common::prefixTable('log_action_duplicates');
@ -78,7 +78,7 @@ class Updates_1_8_4_b1 extends Updates
// grouping by name only would be case-insensitive, so we GROUP BY name,hash
// ON (action.type = 1 AND canonical.hash = action.hash) will use index (type, hash)
" INSERT INTO `$duplicates` (
SELECT
SELECT
action.idaction AS `before`,
canonical.idaction AS `after`
FROM
@ -176,11 +176,11 @@ class Updates_1_8_4_b1 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
try {
self::enableMaintenanceMode();
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
self::disableMaintenanceMode();
} catch (\Exception $e) {
self::disableMaintenanceMode();

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,19 +17,18 @@ use Piwik\Updates;
*/
class Updates_1_9_b16 extends Updates
{
static function isMajorUpdate()
public static function isMajorUpdate()
{
return true;
}
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('log_link_visit_action') . '`
CHANGE `idaction_url` `idaction_url` INT( 10 ) UNSIGNED NULL DEFAULT NULL'
=> false,
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
ADD visit_total_searches SMALLINT(5) UNSIGNED NOT NULL AFTER `visit_total_actions`'
=> 1060,
@ -46,9 +45,8 @@ class Updates_1_9_b16 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_1_9_b19 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE `' . Common::prefixTable('log_link_visit_action') . '`
@ -29,10 +29,9 @@ class Updates_1_9_b19 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('Transitions');
@ -40,4 +39,3 @@ class Updates_1_9_b19 extends Updates
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,36 +17,39 @@ use Piwik\Updates;
*/
class Updates_1_9_b9 extends Updates
{
static function isMajorUpdate()
public static function isMajorUpdate()
{
return true;
}
static function getSql()
public function getMigrationQueries(Updater $updater)
{
$logVisit = Common::prefixTable('log_visit');
$logConversion = Common::prefixTable('log_conversion');
$addColumns = "DROP `location_continent`,
ADD `location_region` CHAR(2) NULL AFTER `location_country`,
$addColumns = "ADD `location_region` CHAR(2) NULL AFTER `location_country`,
ADD `location_city` VARCHAR(255) NULL AFTER `location_region`,
ADD `location_latitude` FLOAT(10, 6) NULL AFTER `location_city`,
ADD `location_longitude` FLOAT(10, 6) NULL AFTER `location_latitude`";
$dropColumns = "DROP `location_continent`";
return array(
// add geoip columns to log_visit
"ALTER TABLE `$logVisit` $addColumns" => 1091,
"ALTER TABLE `$logVisit` $dropColumns" => 1091,
"ALTER TABLE `$logConversion` $dropColumns" => 1091,
// add geoip columns to log_visit
"ALTER TABLE `$logVisit` $addColumns" => 1060,
// add geoip columns to log_conversion
"ALTER TABLE `$logConversion` $addColumns" => 1091,
"ALTER TABLE `$logConversion` $addColumns" => 1060,
);
}
static function update()
public function doUpdate(Updater $updater)
{
try {
self::enableMaintenanceMode();
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
self::disableMaintenanceMode();
} catch (\Exception $e) {
self::disableMaintenanceMode();
@ -54,4 +57,3 @@ class Updates_1_9_b9 extends Updates
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,17 +17,17 @@ use Piwik\Updates;
*/
class Updates_1_9_1_b2 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE ' . Common::prefixTable('site') . " DROP `feedburnerName`" => 1091
);
}
static function update()
public function doUpdate(Updater $updater)
{
// manually remove ExampleFeedburner column
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
// remove ExampleFeedburner plugin
$pluginToDelete = 'ExampleFeedburner';

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,17 +10,18 @@
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_1_9_3_b10 extends Updates
{
static function isMajorUpdate()
public static function isMajorUpdate()
{
return false;
}
static function update()
public function doUpdate(Updater $updater)
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('Annotations');

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,12 +10,13 @@
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_1_9_3_b3 extends Updates
{
static function update()
public function doUpdate(Updater $updater)
{
// Insight was a temporary code name for Overlay
$pluginToDelete = 'Insight';

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_1_9_3_b8 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
// ignore existing column name error (1060)
@ -26,9 +26,9 @@ class Updates_1_9_3_b8 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
// add excluded_user_agents column to site table
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_2_0_a12 extends Updates
{
public static function getSql()
public function getMigrationQueries(Updater $updater)
{
$result = array(
'ALTER TABLE ' . Common::prefixTable('logger_message') . ' MODIFY level VARCHAR(16) NULL' => false
@ -40,9 +40,9 @@ class Updates_2_0_a12 extends Updates
return $result;
}
public static function update()
public function doUpdate(Updater $updater)
{
// change level column in logger_message table to string & remove other logging tables if empty
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -9,7 +9,6 @@
namespace Piwik\Updates;
use Piwik\Common;
use Piwik\Db;
use Piwik\Option;
use Piwik\Updater;
use Piwik\Updates;
@ -18,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_2_0_a13 extends Updates
{
public static function getSql()
public function getMigrationQueries(Updater $updater)
{
// Renaming old archived records now that the plugin is called Referrers
$sql = array();
@ -44,12 +43,12 @@ class Updates_2_0_a13 extends Updates
return $sql;
}
public static function update()
public function doUpdate(Updater $updater)
{
// delete schema version_
Option::delete('version_Referers');
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
// old plugins deleted in 2.0-a17 update file
@ -61,6 +60,5 @@ class Updates_2_0_a13 extends Updates
\Piwik\Plugin\Manager::getInstance()->activatePlugin('ScheduledReports');
} catch (\Exception $e) {
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -8,15 +8,15 @@
*/
namespace Piwik\Updates;
use Piwik\Db;
use Piwik\Filesystem;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_0_a17 extends Updates
{
public static function update()
public function doUpdate(Updater $updater)
{
$errors = array();
@ -33,10 +33,9 @@ class Updates_2_0_a17 extends Updates
if (file_exists($dir)) {
$errors[] = "Please delete this directory manually (eg. using your FTP software): $dir \n";
}
}
if(!empty($errors)) {
if (!empty($errors)) {
throw new \Exception("Warnings during the update: <br>" . implode("<br>", $errors));
}
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,7 +17,7 @@ use Piwik\Updates;
*/
class Updates_2_0_a7 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
// ignore existing column name error (1060)
@ -29,9 +29,9 @@ class Updates_2_0_a7 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
// add tag & level columns to logger_message table
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,12 +10,13 @@
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_0_b10 extends Updates
{
static function update()
public function doUpdate(Updater $updater)
{
parent::deletePluginFromConfigFile('Referers');
parent::deletePluginFromConfigFile('PDFReports');

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,12 +10,13 @@ namespace Piwik\Updates;
use Piwik\Filesystem;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_0_b13 extends Updates
{
public static function update()
public function doUpdate(Updater $updater)
{
$errors = array();
@ -33,10 +34,9 @@ class Updates_2_0_b13 extends Updates
if (file_exists($dir)) {
$errors[] = "Please delete this directory manually (eg. using your FTP software): $dir \n";
}
}
if(!empty($errors)) {
if (!empty($errors)) {
throw new \Exception("Warnings during the update: <br>" . implode("<br>", $errors));
}
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -17,12 +17,12 @@ use Piwik\Updates;
*/
class Updates_2_0_b3 extends Updates
{
static function isMajorUpdate()
public static function isMajorUpdate()
{
return true;
}
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
'ALTER TABLE ' . Common::prefixTable('log_visit')
@ -34,9 +34,9 @@ class Updates_2_0_b3 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('Events');

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -18,7 +18,7 @@ use Piwik\Updates;
*/
class Updates_2_0_b9 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
"ALTER TABLE `" . Common::prefixTable('site')
@ -26,8 +26,8 @@ class Updates_2_0_b9 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -9,16 +9,17 @@
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_0_rc1 extends Updates
{
public static function update()
public function doUpdate(Updater $updater)
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('Morpheus');
} catch(\Exception $e) {
} catch (\Exception $e) {
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -9,27 +9,26 @@
namespace Piwik\Updates;
use Piwik\Common;
use Piwik\Site;
use Piwik\Updater;
use Piwik\Updates;
use Piwik\Filesystem;
use Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker;
use Piwik\Plugins\PrivacyManager\IPAnonymizer;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_0_3_b7 extends Updates
{
static function update()
public function doUpdate(Updater $updater)
{
$errors = array();
try {
$checker = new DoNotTrackHeaderChecker();
// enable DoNotTrack check in PrivacyManager if DoNotTrack plugin was enabled
if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated('DoNotTrack')) {
DoNotTrackHeaderChecker::activate();
$checker->activate();
}
// enable IP anonymization if AnonymizeIP plugin was enabled
@ -45,8 +44,7 @@ class Updates_2_0_3_b7 extends Updates
foreach ($oldPlugins as $plugin) {
try {
\Piwik\Plugin\Manager::getInstance()->deactivatePlugin($plugin);
} catch(\Exception $e) {
} catch (\Exception $e) {
}
$dir = PIWIK_INCLUDE_PATH . "/plugins/$plugin";
@ -58,9 +56,8 @@ class Updates_2_0_3_b7 extends Updates
if (file_exists($dir)) {
$errors[] = "Please delete this directory manually (eg. using your FTP software): $dir \n";
}
}
if(!empty($errors)) {
if (!empty($errors)) {
throw new \Exception("Warnings during the update: <br>" . implode("<br>", $errors));
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -10,19 +10,19 @@
namespace Piwik\Updates;
use Piwik\Common;
use Piwik\Config;
use Piwik\Date;
use Piwik\Db;
use Piwik\Plugins\UsersManager\API as UsersManagerApi;
use Piwik\Updater;
use Piwik\UpdaterErrorException;
use Piwik\Updates;
use Piwik\Config;
/**
*/
class Updates_2_0_4_b5 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array(
// ignore existing column name error (1060)
@ -31,9 +31,9 @@ class Updates_2_0_4_b5 extends Updates
);
}
static function update()
public function doUpdate(Updater $updater)
{
Updater::updateDatabase(__FILE__, self::getSql());
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
try {
self::migrateConfigSuperUserToDb();
@ -56,7 +56,10 @@ class Updates_2_0_4_b5 extends Updates
$superUser = null;
}
if (!empty($superUser['bridge']) || empty($superUser)) {
if (!empty($superUser['bridge'])
|| empty($superUser)
|| empty($superUser['login'])
) {
// there is a super user which is not from the config but from the bridge, that means we already have
// a super user in the database
return;
@ -75,7 +78,7 @@ class Updates_2_0_4_b5 extends Updates
'superuser_access' => 1
)
);
} catch(\Exception $e) {
} catch (\Exception $e) {
echo "There was an issue, but we proceed: " . $e->getMessage();
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -9,27 +9,23 @@
namespace Piwik\Updates;
use Piwik\Common;
use Piwik\Date;
use Piwik\Db;
use Piwik\Option;
use Piwik\Plugins\UsersManager\API as UsersManagerApi;
use Piwik\Plugins\MobileMessaging\MobileMessaging;
use Piwik\Updater;
use Piwik\Config;
use Piwik\Plugins\UsersManager\API as UsersManagerApi;
use Piwik\UpdaterErrorException;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_0_4_b7 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array();
}
static function update()
public function doUpdate(Updater $updater)
{
try {
self::migrateExistingMobileMessagingOptions();

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -9,23 +9,23 @@
namespace Piwik\Updates;
use Piwik\Db;
use Piwik\Config;
use Piwik\Updates;
use Piwik\UpdaterErrorException;
use Piwik\Plugins\CoreAdminHome\CustomLogo;
use Piwik\Plugins\PrivacyManager\Config as PrivacyManagerConfig;
use Piwik\UpdaterErrorException;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_0_4_b8 extends Updates
{
static function getSql()
public function getMigrationQueries(Updater $updater)
{
return array();
}
static function update()
public function doUpdate(Updater $updater)
{
try {
$config = Config::getInstance();
@ -34,7 +34,6 @@ class Updates_2_0_4_b8 extends Updates
self::migratePrivacyManagerConfig($config, new PrivacyManagerConfig());
$config->forceSave();
} catch (\Exception $e) {
throw new UpdaterErrorException($e->getMessage());
}

View file

@ -1,27 +1,27 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Updates;
use Piwik\Db;
use Piwik\Updates;
use Piwik\Updater;
use Piwik\Date;
use Piwik\Segment;
use Piwik\ArchiveProcessor\Rules;
use Piwik\Db\BatchInsert;
use Piwik\DataAccess\ArchiveWriter;
use Piwik\Date;
use Piwik\Db\BatchInsert;
use Piwik\Db;
use Piwik\Plugins\VisitFrequency\API as VisitFrequencyApi;
use Piwik\Segment;
use Piwik\Updater;
use Piwik\Updates;
/**
*/
class Updates_2_1_1_b11 extends Updates
{
static function update()
public function doUpdate(Updater $updater)
{
$returningMetrics = array(
'nb_visits_returning',
@ -41,17 +41,14 @@ class Updates_2_1_1_b11 extends Updates
// returning visit segment
foreach ($archiveNumericTables as $table) {
// get archives w/ *._returning
$sql = "SELECT idarchive, idsite, period, date1, date2
FROM $table
WHERE name IN ('" . implode("','", $returningMetrics) . "')
GROUP BY idarchive";
$sql = "SELECT idarchive, idsite, period, date1, date2 FROM $table
WHERE name IN ('" . implode("','", $returningMetrics) . "')
GROUP BY idarchive";
$idArchivesWithReturning = Db::fetchAll($sql);
// get archives for visitssummary returning visitor segment
$sql = "SELECT idarchive, idsite, period, date1, date2
FROM $table
WHERE name = ?
GROUP BY idarchive";
$sql = "SELECT idarchive, idsite, period, date1, date2 FROM $table
WHERE name = ? GROUP BY idarchive";
$visitSummaryReturningSegmentDone = Rules::getDoneFlagArchiveContainsOnePlugin(
new Segment(VisitFrequencyApi::RETURNING_VISITOR_SEGMENT, $idSites = array()), 'VisitsSummary');
$idArchivesWithVisitReturningSegment = Db::fetchAll($sql, array($visitSummaryReturningSegmentDone));
@ -97,7 +94,7 @@ class Updates_2_1_1_b11 extends Updates
foreach ($missingIdArchives as $missingIdArchive) {
$params[] = array_values($missingIdArchive);
}
BatchInsert::tableInsertBatch($table, array_keys(reset($missingIdArchives)), $params, $throwException = false);
BatchInsert::tableInsertBatch($table, array_keys(reset($missingIdArchives)), $params, $throwException = false, $charset = 'latin1');
} catch (\Exception $ex) {
Updater::handleQueryError($ex, "<batch insert>", false, __FILE__);
}

View file

@ -0,0 +1,47 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Updater;
use Piwik\Updates;
class Updates_2_10_0_b10 extends Updates
{
public function getMigrationQueries(Updater $updater)
{
$sqls = array();
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
$archiveBlobTables = array_filter($archiveTables, function ($name) {
return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE;
});
foreach ($archiveBlobTables as $table) {
$sqls["UPDATE " . $table . " SET name = 'DevicePlugins_plugin' WHERE name = 'UserSettings_plugin'"] = false;
}
return $sqls;
}
public function doUpdate(Updater $updater)
{
$pluginManager = \Piwik\Plugin\Manager::getInstance();
try {
$pluginManager->activatePlugin('DevicePlugins');
} catch (\Exception $e) {
}
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -0,0 +1,30 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
* Update for version 2.10.0-b4.
*/
class Updates_2_10_0_b4 extends Updates
{
public function doUpdate(Updater $updater)
{
$pluginManager = \Piwik\Plugin\Manager::getInstance();
try {
$pluginManager->activatePlugin('BulkTracking');
} catch (\Exception $e) {
}
}
}

View file

@ -0,0 +1,208 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Common;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\DataTable;
use Piwik\Db;
use Piwik\Updater;
use Piwik\Updates;
use Piwik\Plugins\Dashboard\Model as DashboardModel;
/**
* This Update script will update all browser and os archives of UserSettings and DevicesDetection plugin
*
* In the future only DevicesDetection will handle browser and os archives, so we try to rename all existing archives
* of UserSettings plugin to their corresponding archive name in DevicesDetection plugin:
* - *UserSettings_browser* will now be *DevicesDetection_browserVersions*
* - *UserSettings_os* will now be *DevicesDetection_osVersions*
*
* Unlike DevicesDetection plugin, the UserSettings plugin did not store archives holding the os and browser data without
* their version number. The "version-less" reports were always generated out of the "version-containing" archives .
* For big archives (month/year) that ment that some of the data was truncated, due to the datatable entry limit.
* To avoid that data loss / inaccuracy in the future, DevicesDetection plugin will also store archives without the version.
* For data archived after DevicesDetection plugin was enabled, those archive already exist. As we are removing the
* UserSettings reports, there is a fallback in DevicesDetection API to build the report out of the datatable with versions.
*
* NOTE: Some archives might not contain "all" data.
* That might have happened directly after the day DevicesDetection plugin was enabled. For the days before, there were
* no archives calculated. So week/month/year archives will only contain data for the days, where archives were generated
* To find a date after which it is safe to use DevicesDetection archives we need to find the first day-archive that
* contains DevicesDetection data. Day archives will always contain full data, but week/month/year archives may not.
* So we need to recreate those week/month/year archives.
*/
class Updates_2_10_0_b5 extends Updates
{
public static $archiveBlobTables;
public function getMigrationQueries(Updater $updater)
{
$sqls = array('# ATTENTION: This update script will execute some more SQL queries than that below as it is necessary to rebuilt some archives #' => false);
// update scheduled reports to use new plugin
$reportsToReplace = array(
'UserSettings_getBrowserVersion' => 'DevicesDetection_getBrowserVersions',
'UserSettings_getBrowser' => 'DevicesDetection_getBrowsers',
'UserSettings_getOSFamily' => 'DevicesDetection_getOsFamilies',
'UserSettings_getOS' => 'DevicesDetection_getOsVersions',
'UserSettings_getMobileVsDesktop' => 'DevicesDetection_getType',
'UserSettings_getBrowserType' => 'DevicesDetection_getBrowserEngines',
'UserSettings_getWideScreen' => 'UserSettings_getScreenType',
);
foreach ($reportsToReplace as $old => $new) {
$sqls["UPDATE " . Common::prefixTable('report') . " SET reports = REPLACE(reports, '".$old."', '".$new."')"] = false;
}
// update dashboard to use new widgets
$oldWidgets = array(
array('module' => 'UserSettings', 'action' => 'getBrowserVersion', 'params' => array()),
array('module' => 'UserSettings', 'action' => 'getBrowser', 'params' => array()),
array('module' => 'UserSettings', 'action' => 'getOSFamily', 'params' => array()),
array('module' => 'UserSettings', 'action' => 'getOS', 'params' => array()),
array('module' => 'UserSettings', 'action' => 'getMobileVsDesktop', 'params' => array()),
array('module' => 'UserSettings', 'action' => 'getBrowserType', 'params' => array()),
array('module' => 'UserSettings', 'action' => 'getWideScreen', 'params' => array()),
);
$newWidgets = array(
array('module' => 'DevicesDetection', 'action' => 'getBrowserVersions', 'params' => array()),
array('module' => 'DevicesDetection', 'action' => 'getBrowsers', 'params' => array()),
array('module' => 'DevicesDetection', 'action' => 'getOsFamilies', 'params' => array()),
array('module' => 'DevicesDetection', 'action' => 'getOsVersions', 'params' => array()),
array('module' => 'DevicesDetection', 'action' => 'getType', 'params' => array()),
array('module' => 'DevicesDetection', 'action' => 'getBrowserEngines', 'params' => array()),
array('module' => 'UserSettings', 'action' => 'getScreenType', 'params' => array()),
);
$allDashboards = Db::get()->fetchAll(sprintf("SELECT * FROM %s", Common::prefixTable('user_dashboard')));
foreach ($allDashboards as $dashboard) {
$dashboardLayout = json_decode($dashboard['layout']);
$dashboardLayout = DashboardModel::replaceDashboardWidgets($dashboardLayout, $oldWidgets, $newWidgets);
$newLayout = json_encode($dashboardLayout);
if ($newLayout != $dashboard['layout']) {
$sqls["UPDATE " . Common::prefixTable('user_dashboard') . " SET layout = '".addslashes($newLayout)."' WHERE iddashboard = ".$dashboard['iddashboard']] = false;
}
}
return $sqls;
}
public function doUpdate(Updater $updater)
{
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
// DeviceDetection upgrade in beta1 timed out on demo #6750
$archiveBlobTables = self::getAllArchiveBlobTables();
foreach ($archiveBlobTables as $table) {
self::updateBrowserArchives($table);
self::updateOsArchives($table);
}
}
/**
* Returns all available archive blob tables
*
* @return array
*/
public static function getAllArchiveBlobTables()
{
if (empty(self::$archiveBlobTables)) {
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
self::$archiveBlobTables = array_filter($archiveTables, function ($name) {
return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE;
});
// sort tables so we have them in order of their date
rsort(self::$archiveBlobTables);
}
return (array) self::$archiveBlobTables;
}
/**
* Find the first day on which DevicesDetection archives were generated
*
* @return int Timestamp
*/
public static function getFirstDayOfArchivedDeviceDetectorData()
{
static $deviceDetectionBlobAvailableDate;
if (empty($deviceDetectionBlobAvailableDate)) {
$archiveBlobTables = self::getAllArchiveBlobTables();
$deviceDetectionBlobAvailableDate = null;
foreach ($archiveBlobTables as $table) {
// Look for all day archives and try to find that with the lowest date
$deviceDetectionBlobAvailableDate = Db::get()->fetchOne(sprintf("SELECT date1 FROM %s WHERE name = 'DevicesDetection_browserVersions' AND period = 1 ORDER BY date1 ASC LIMIT 1", $table));
if (!empty($deviceDetectionBlobAvailableDate)) {
break;
}
}
$deviceDetectionBlobAvailableDate = strtotime($deviceDetectionBlobAvailableDate);
}
return $deviceDetectionBlobAvailableDate;
}
/**
* Updates all browser archives to new structure
* @param string $table
* @throws \Exception
*/
public static function updateBrowserArchives($table)
{
// rename old UserSettings archives where no DeviceDetection archives exists
Db::exec(sprintf("UPDATE IGNORE %s SET name='DevicesDetection_browserVersions' WHERE name = 'UserSettings_browser'", $table));
/*
* check dates of remaining (non-day) archives with calculated safe date
* archives before or within that week/month/year of that date will be replaced
*/
$oldBrowserBlobs = Db::get()->fetchAll(sprintf("SELECT * FROM %s WHERE name = 'UserSettings_browser' AND `period` > 1", $table));
foreach ($oldBrowserBlobs as $blob) {
// if start date of blob is before calculated date us old usersettings archive instead of already existing DevicesDetection archive
if (strtotime($blob['date1']) < self::getFirstDayOfArchivedDeviceDetectorData()) {
Db::get()->query(sprintf("DELETE FROM %s WHERE idarchive = ? AND name = ?", $table), array($blob['idarchive'], 'DevicesDetection_browserVersions'));
Db::get()->query(sprintf("UPDATE %s SET name = ? WHERE idarchive = ? AND name = ?", $table), array('DevicesDetection_browserVersions', $blob['idarchive'], 'UserSettings_browser'));
}
}
}
public static function updateOsArchives($table)
{
Db::exec(sprintf("UPDATE IGNORE %s SET name='DevicesDetection_osVersions' WHERE name = 'UserSettings_os'", $table));
/*
* check dates of remaining (non-day) archives with calculated safe date
* archives before or within that week/month/year of that date will be replaced
*/
$oldOsBlobs = Db::get()->fetchAll(sprintf("SELECT * FROM %s WHERE name = 'UserSettings_os' AND `period` > 1", $table));
foreach ($oldOsBlobs as $blob) {
// if start date of blob is before calculated date us old usersettings archive instead of already existing DevicesDetection archive
if (strtotime($blob['date1']) < self::getFirstDayOfArchivedDeviceDetectorData()) {
Db::get()->query(sprintf("DELETE FROM %s WHERE idarchive = ? AND name = ?", $table), array($blob['idarchive'], 'DevicesDetection_osVersions'));
Db::get()->query(sprintf("UPDATE %s SET name = ? WHERE idarchive = ? AND name = ?", $table), array('DevicesDetection_osVersions', $blob['idarchive'], 'UserSettings_os'));
}
}
}
}

View file

@ -0,0 +1,41 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Updater;
use Piwik\Updates;
class Updates_2_10_0_b7 extends Updates
{
public function getMigrationQueries(Updater $updater)
{
$sqls = array();
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
$archiveBlobTables = array_filter($archiveTables, function ($name) {
return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE;
});
foreach ($archiveBlobTables as $table) {
$sqls["UPDATE " . $table . " SET name = 'Resolution_resolution' WHERE name = 'UserSettings_resolution'"] = false;
$sqls["UPDATE " . $table . " SET name = 'Resolution_configuration' WHERE name = 'UserSettings_configuration'"] = false;
}
return $sqls;
}
public function doUpdate(Updater $updater)
{
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -0,0 +1,26 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
class Updates_2_10_0_b8 extends Updates
{
public function doUpdate(Updater $updater)
{
$pluginManager = \Piwik\Plugin\Manager::getInstance();
try {
$pluginManager->activatePlugin('Resolution');
} catch (\Exception $e) {
}
}
}

View file

@ -0,0 +1,65 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Common;
use Piwik\Db;
use Piwik\Piwik;
use Piwik\Updater;
use Piwik\Updates;
use Piwik\Plugins\Dashboard\Model as DashboardModel;
/**
* Update for version 2.11.0-b2.
*/
class Updates_2_11_0_b2 extends Updates
{
public function getMigrationQueries(Updater $updater)
{
$sqls = array();
// update dashboard to use new ecommerce widgets, they were moved from goals plugin to ecommerce
$oldWidgets = array(
array('module' => 'Goals', 'action' => 'getEcommerceLog', 'params' => array()),
array('module' => 'Goals', 'action' => 'widgetGoalReport', 'params' => array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER)),
);
$newWidgets = array(
array('module' => 'Ecommerce', 'action' => 'getEcommerceLog', 'params' => array()),
array('module' => 'Ecommerce', 'action' => 'widgetGoalReport', 'params' => array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER)),
);
$allDashboards = Db::get()->fetchAll(sprintf("SELECT * FROM %s", Common::prefixTable('user_dashboard')));
foreach ($allDashboards as $dashboard) {
$dashboardLayout = json_decode($dashboard['layout']);
$dashboardLayout = DashboardModel::replaceDashboardWidgets($dashboardLayout, $oldWidgets, $newWidgets);
$newLayout = json_encode($dashboardLayout);
if ($newLayout != $dashboard['layout']) {
$sqls["UPDATE " . Common::prefixTable('user_dashboard') . " SET layout = '".addslashes($newLayout)."' WHERE iddashboard = ".$dashboard['iddashboard']] = false;
}
}
return $sqls;
}
public function doUpdate(Updater $updater)
{
$pluginManager = \Piwik\Plugin\Manager::getInstance();
try {
$pluginManager->activatePlugin('Ecommerce');
} catch (\Exception $e) {
}
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -0,0 +1,47 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Updater;
use Piwik\Updates;
class Updates_2_11_0_b4 extends Updates
{
public function getMigrationQueries(Updater $updater)
{
$sqls = array();
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
$archiveBlobTables = array_filter($archiveTables, function ($name) {
return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE;
});
foreach ($archiveBlobTables as $table) {
$sqls["UPDATE " . $table . " SET name = 'UserLanguage_language' WHERE name = 'UserSettings_language'"] = false;
}
return $sqls;
}
public function doUpdate(Updater $updater)
{
$pluginManager = \Piwik\Plugin\Manager::getInstance();
try {
$pluginManager->activatePlugin('UserLanguage');
} catch (\Exception $e) {
}
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -0,0 +1,24 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Updates;
use Piwik\Plugin\Manager;
use Piwik\Updates;
use Piwik\Updater;
class Updates_2_11_0_b5 extends Updates
{
public function doUpdate(Updater $updater)
{
try {
Manager::getInstance()->activatePlugin('Monolog');
} catch (\Exception $e) {
}
}
}

View file

@ -0,0 +1,40 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Config;
use Piwik\Development;
use Piwik\Updates;
use Piwik\Updater;
class Updates_2_11_1_b4 extends Updates
{
/**
* Here you can define any action that should be performed during the update. For instance executing SQL statements,
* renaming config entries, updating files, etc.
*/
public function doUpdate(Updater $updater)
{
if (!Development::isEnabled()) {
return;
}
$config = Config::getInstance();
$dbTests = $config->database_tests;
if ($dbTests['username'] === '@USERNAME@') {
$dbTests['username'] = 'root';
}
$config->database_tests = $dbTests;
$config->forceSave();
}
}

View file

@ -0,0 +1,26 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Updater;
use Piwik\Updates;
class Updates_2_13_0_b3 extends Updates
{
public function doUpdate(Updater $updater)
{
$pluginManager = \Piwik\Plugin\Manager::getInstance();
try {
$pluginManager->activatePlugin('Diagnostics');
} catch (\Exception $e) {
}
}
}

View file

@ -0,0 +1,43 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;
/**
* Update for version 2.13.1.
*/
class Updates_2_13_1 extends Updates
{
/**
* Here you can define one or multiple SQL statements that should be executed during the update.
* @return array
*/
public function getMigrationQueries(Updater $updater)
{
$optionTable = Common::prefixTable('option');
$removeEmptyDefaultReportsSql = "delete from `$optionTable` where option_name like '%defaultReport%' and option_value=''";
return array(
$removeEmptyDefaultReportsSql => false
);
}
/**
* Here you can define any action that should be performed during the update. For instance executing SQL statements,
* renaming config entries, updating files, etc.
*/
public function doUpdate(Updater $updater)
{
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -0,0 +1,43 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Updater;
use Piwik\Updates;
use Piwik\Plugin\Manager;
class Updates_2_14_0_b1 extends Updates
{
public function doUpdate(Updater $updater)
{
$this->uninstallPlugin('UserSettings');
}
private function uninstallPlugin($plugin)
{
$pluginManager = Manager::getInstance();
if ($pluginManager->isPluginInstalled($plugin)) {
if ($pluginManager->isPluginActivated($plugin)) {
$pluginManager->deactivatePlugin($plugin);
}
$pluginManager->unloadPlugin($plugin);
$pluginManager->uninstallPlugin($plugin);
} else {
$this->makeSurePluginIsRemovedFromFilesystem($plugin);
}
}
private function makeSurePluginIsRemovedFromFilesystem($plugin)
{
Manager::deletePluginFromFilesystem($plugin);
}
}

View file

@ -0,0 +1,43 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;
use Piwik\Db;
class Updates_2_14_0_b2 extends Updates
{
public function getMigrationQueries(Updater $updater)
{
$dbSettings = new Db\Settings();
$engine = $dbSettings->getEngine();
$table = Common::prefixTable('site_setting');
$sqlarray = array(
"DROP TABLE IF EXISTS `$table`" => false,
"CREATE TABLE `$table` (
idsite INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`setting_name` VARCHAR(255) NOT NULL,
`setting_value` LONGTEXT NOT NULL,
PRIMARY KEY(idsite, setting_name)
) ENGINE=$engine DEFAULT CHARSET=utf8" => 1050,
);
return $sqlarray;
}
public function doUpdate(Updater $updater)
{
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -0,0 +1,124 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Common;
use Piwik\DbHelper;
use Piwik\Option;
use Piwik\Plugin\Dimension\ActionDimension;
use Piwik\Plugin\Dimension\ConversionDimension;
use Piwik\Plugin\Dimension\VisitDimension;
use Piwik\Tracker\Visit;
use Piwik\Updater;
use Piwik\Updates;
/**
* Update for version 2.14.2.
*/
class Updates_2_14_2 extends Updates
{
/**
* Removes option entries for columns that are marked as installed but are actually no longer installed due to
* a bug in previous versions where the option entries were not correctly removed.
*
* @param Updater $updater
* @return array
*/
public function getMigrationQueries(Updater $updater)
{
$visitSqls = self::getSqlsThatRemoveOptionEntriesOfNotActuallyInstalledColumns(VisitDimension::INSTALLER_PREFIX, 'log_visit');
$actionSqls = self::getSqlsThatRemoveOptionEntriesOfNotActuallyInstalledColumns(ActionDimension::INSTALLER_PREFIX, 'log_link_visit_action');
$conversionSqls = self::getSqlsThatRemoveOptionEntriesOfNotActuallyInstalledColumns(ConversionDimension::INSTALLER_PREFIX, 'log_conversion');
$sqls = array();
foreach ($visitSqls as $sql) {
$sqls[$sql] = false;
}
foreach ($actionSqls as $sql) {
$sqls[$sql] = false;
}
foreach ($conversionSqls as $sql) {
$sqls[$sql] = false;
}
return $sqls;
}
private static function getSqlsThatRemoveOptionEntriesOfNotActuallyInstalledColumns($dimensionPrefix, $tableName)
{
$componentPrefix = 'version_' . $dimensionPrefix;
$notActuallyInstalledColumns = self::getNotActuallyInstalledColumnNames($componentPrefix, $tableName);
$sqls = array();
foreach ($notActuallyInstalledColumns as $column) {
$sqls[] = self::buildRemoveOptionEntrySql($componentPrefix . $column);
}
return $sqls;
}
private static function buildRemoveOptionEntrySql($optionName)
{
$tableName = Common::prefixTable('option');
return sprintf("DELETE FROM `%s` WHERE `option_name` = '%s'", $tableName, $optionName);
}
/**
* @param string $componentPrefix
* @param string $tableName
* @return array An array of columns that are marked as installed but are actually removed. There was a bug
* where option entries were not correctly removed. eg array('idvist', 'server_time', ...)
*/
private static function getNotActuallyInstalledColumnNames($componentPrefix, $tableName)
{
$installedVisitColumns = self::getMarkedAsInstalledColumns($componentPrefix);
$existingVisitColumns = self::getActuallyExistingColumns($tableName);
return array_diff($installedVisitColumns, $existingVisitColumns);
}
/**
* @param string $componentPrefix eg 'version_log_visit.'
* @return array An array of column names that are marked as installed. eg array('idvist', 'server_time', ...)
*/
private static function getMarkedAsInstalledColumns($componentPrefix)
{
$installedVisitColumns = Option::getLike($componentPrefix . '%');
$installedVisitColumns = array_keys($installedVisitColumns);
$installedVisitColumns = array_map(function ($entry) use ($componentPrefix) {
return str_replace($componentPrefix, '', $entry);
}, $installedVisitColumns);
return $installedVisitColumns;
}
/**
* @param string $tableName
* @return array An array of actually existing column names in the given table. eg array('idvist', 'server_time', ...)
*/
private static function getActuallyExistingColumns($tableName)
{
$tableName = Common::prefixTable($tableName);
return array_keys(DbHelper::getTableColumns($tableName));
}
/**
* @param Updater $updater
*/
public function doUpdate(Updater $updater)
{
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -0,0 +1,44 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Config;
use Piwik\UpdateCheck;
use Piwik\Updater;
use Piwik\Updates;
class Updates_2_15_0_b12 extends Updates
{
public function doUpdate(Updater $updater)
{
$this->migrateBetaUpgradesToReleaseChannel();
}
private function migrateBetaUpgradesToReleaseChannel()
{
$config = Config::getInstance();
$debug = $config->Debug;
if (array_key_exists('allow_upgrades_to_beta', $debug)) {
$allowUpgradesToBeta = 1 == $debug['allow_upgrades_to_beta'];
unset($debug['allow_upgrades_to_beta']);
$general = $config->General;
if ($allowUpgradesToBeta) {
$general['release_channel'] = 'latest_beta';
} else {
$general['release_channel'] = 'latest_stable';
}
$config->Debug = $debug;
$config->General = $general;
$config->forceSave();
}
}
}

View file

@ -0,0 +1,45 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Plugin\Manager;
use Piwik\Updater;
use Piwik\Updates;
class Updates_2_15_0_b16 extends Updates
{
public function doUpdate(Updater $updater)
{
$this->uninstallPlugin('LeftMenu');
$this->uninstallPlugin('ZenMode');
}
private function uninstallPlugin($plugin)
{
$pluginManager = Manager::getInstance();
if ($pluginManager->isPluginInstalled($plugin)) {
if ($pluginManager->isPluginActivated($plugin)) {
$pluginManager->deactivatePlugin($plugin);
}
$pluginManager->unloadPlugin($plugin);
$pluginManager->uninstallPlugin($plugin);
} else {
$this->makeSurePluginIsRemovedFromFilesystem($plugin);
}
}
private function makeSurePluginIsRemovedFromFilesystem($plugin)
{
Manager::deletePluginFromFilesystem($plugin);
}
}

View file

@ -0,0 +1,44 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Config;
use Piwik\Updater;
use Piwik\Updates;
/**
* Update for version 2.15.0-b17.
*/
class Updates_2_15_0_b17 extends Updates
{
/**
* Perform the incremental version update.
*
* This method should preform all updating logic. If you define queries in an overridden `getMigrationQueries()`
* method, you must call {@link Updater::executeMigrationQueries()} here.
*
* See {@link Updates} for an example.
*
* @param Updater $updater
*/
public function doUpdate(Updater $updater)
{
$this->removeDeprecatedDebugConfig('enable_measure_piwik_usage_in_idsite');
}
private function removeDeprecatedDebugConfig($name)
{
$config = Config::getInstance();
$debug = $config->Debug;
unset($debug[$name]);
$config->Debug = $debug;
$config->forceSave();
}
}

View file

@ -0,0 +1,42 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Plugin;
use Piwik\Updater;
use Piwik\Updates;
/**
* Update for version 2.15.0-b20.
*/
class Updates_2_15_0_b20 extends Updates
{
/**
* Perform the incremental version update.
*
* This method should preform all updating logic. If you define queries in an overridden `getMigrationQueries()`
* method, you must call {@link Updater::executeMigrationQueries()} here.
*
* See {@link Updates} for an example.
*
* @param Updater $updater
*/
public function doUpdate(Updater $updater)
{
$this->makeSurePluginIsRemovedFromFilesystem('ZenMode');
$this->makeSurePluginIsRemovedFromFilesystem('LeftMenu');
}
private function makeSurePluginIsRemovedFromFilesystem($plugin)
{
Plugin\Manager::deletePluginFromFilesystem($plugin);
}
}

View file

@ -0,0 +1,32 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;
class Updates_2_15_0_b3 extends Updates
{
public function getMigrationQueries(Updater $updater)
{
$updateSql = array(
'ALTER TABLE `' . Common::prefixTable('site')
. '` ADD COLUMN `exclude_unknown_urls` TINYINT(1) DEFAULT 0 AFTER `currency`' => array(1060)
);
return $updateSql;
}
public function doUpdate(Updater $updater)
{
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
}
}

View file

@ -0,0 +1,25 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Plugins\Installation\ServerFilesGenerator;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_15_0_b4 extends Updates
{
public function doUpdate(Updater $updater)
{
// added .ttf whitelisted file for apache webserver
ServerFilesGenerator::deleteHtAccessFiles();
ServerFilesGenerator::createHtAccessFiles();
}
}

View file

@ -0,0 +1,25 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Updates;
use Piwik\Updater;
use Piwik\Updates;
class Updates_2_15_0 extends Updates
{
public function doUpdate(Updater $updater)
{
$pluginManager = \Piwik\Plugin\Manager::getInstance();
try {
$pluginManager->activatePlugin('Heartbeat');
} catch (\Exception $e) {
}
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Updates;
use Piwik\Updater;
use Piwik\Updates;
class Updates_2_16_0_rc2 extends Updates
{
public function doUpdate(Updater $updater)
{
$pluginManager = \Piwik\Plugin\Manager::getInstance();
$pluginName = 'PiwikPro';
try {
if (!$pluginManager->isPluginActivated($pluginName)) {
$pluginManager->activatePlugin($pluginName);
}
} catch (\Exception $e) {
}
}
}

View file

@ -1,21 +1,20 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Updates;
use Piwik\Db;
use Piwik\Filesystem;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_2_0_b15 extends Updates
{
static function update()
public function doUpdate(Updater $updater)
{
// This was added in the beta cycle and then removed
// if the file is there, it can cause bugs (we don't have an archiver in VisitFrequency anymore)

View file

@ -0,0 +1,25 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_2_3_b6 extends Updates
{
public function doUpdate(Updater $updater)
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('ZenMode');
} catch (\Exception $e) {
}
}
}

View file

@ -0,0 +1,25 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Plugins\Installation\ServerFilesGenerator;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_3_0_rc2 extends Updates
{
public function doUpdate(Updater $updater)
{
ServerFilesGenerator::deleteHtAccessFiles();
ServerFilesGenerator::createHtAccessFiles();
}
}

View file

@ -0,0 +1,29 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
class Updates_2_4_0_b1 extends Updates
{
public function doUpdate(Updater $updater)
{
try {
\Piwik\Plugin\Manager::getInstance()->activatePlugin('Morpheus');
} catch (\Exception $e) {
}
try {
\Piwik\Plugin\Manager::getInstance()->deactivatePlugin('Zeitgeist');
self::deletePluginFromConfigFile('Zeitgeist');
} catch (\Exception $e) {
}
}
}

View file

@ -0,0 +1,27 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Plugins\Installation\ServerFilesGenerator;
use Piwik\Updates;
use Piwik\Updater;
/**
*/
class Updates_2_4_0_b2 extends Updates
{
public function doUpdate(Updater $updater)
{
ServerFilesGenerator::deleteWebConfigFiles();
ServerFilesGenerator::createWebConfigFiles();
ServerFilesGenerator::deleteHtAccessFiles();
ServerFilesGenerator::createHtAccessFiles();
}
}

View file

@ -0,0 +1,35 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Updates;
use Piwik\Updates;
use Piwik\Updater;
class Updates_2_4_0_b3 extends Updates
{
public function doUpdate(Updater $updater)
{
$pluginManager = \Piwik\Plugin\Manager::getInstance();
try {
$pluginManager->activatePlugin('LeftMenu');
} catch (\Exception $e) {
}
try {
$pluginManager->deactivatePlugin('Zeitgeist');
} catch (\Exception $e) {
}
try {
$pluginManager->uninstallPlugin('Zeitgeist');
} catch (\Exception $e) {
}
}
}

Some files were not shown because too many files have changed in this diff Show more