update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
|
|
@ -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,51 +9,102 @@
|
|||
namespace Piwik;
|
||||
|
||||
/**
|
||||
* Abstract class for update scripts
|
||||
* Base class for update scripts.
|
||||
*
|
||||
* Update scripts perform version updates for Piwik core or individual plugins. They can run
|
||||
* SQL queries and/or PHP code to update an environment to a newer version.
|
||||
*
|
||||
* To create a new update script, create a class that extends `Updates`. Name the class and file
|
||||
* after the version, eg, `class Updates_3_0_0` and `3.0.0.php`. Override the {@link getMigrationQueries()}
|
||||
* method if you need to run SQL queries. Override the {@link doUpdate()} method to do other types
|
||||
* of updating, eg, to activate/deactivate plugins or create files.
|
||||
*
|
||||
* If you define SQL queries in {@link getMigrationQueries()}, you have to call {@link Updater::executeMigrationQueries()},
|
||||
* eg:
|
||||
*
|
||||
* public function doUpdate(Updater $updater)
|
||||
* {
|
||||
* $updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries());
|
||||
* }
|
||||
*
|
||||
* @example core/Updates/0.4.2.php
|
||||
*/
|
||||
abstract class Updates
|
||||
{
|
||||
/**
|
||||
* Return SQL to be executed in this update
|
||||
*
|
||||
* @return array(
|
||||
* 'ALTER .... ' => '1234', // if the query fails, it will be ignored if the error code is 1234
|
||||
* 'ALTER .... ' => false, // if an error occurs, the update will stop and fail
|
||||
* // and user will have to manually run the query
|
||||
* )
|
||||
* @deprecated since v2.12.0 use getMigrationQueries() instead
|
||||
*/
|
||||
static function getSql()
|
||||
public static function getSql()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Incremental version update
|
||||
* @deprecated since v2.12.0 use doUpdate() instead
|
||||
*/
|
||||
static function update()
|
||||
public static function update()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return SQL to be executed in this update.
|
||||
*
|
||||
* SQL queries should be defined here, instead of in `doUpdate()`, since this method is used
|
||||
* in the `core:update` command when displaying the queries an update will run. If you execute
|
||||
* queries directly in `doUpdate()`, they won't be displayed to the user.
|
||||
*
|
||||
* @param Updater $updater
|
||||
* @return array ```
|
||||
* array(
|
||||
* 'ALTER .... ' => '1234', // if the query fails, it will be ignored if the error code is 1234
|
||||
* 'ALTER .... ' => false, // if an error occurs, the update will stop and fail
|
||||
* // and user will have to manually run the query
|
||||
* )
|
||||
* ```
|
||||
* @api
|
||||
*/
|
||||
public function getMigrationQueries(Updater $updater)
|
||||
{
|
||||
return static::getSql();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @api
|
||||
*/
|
||||
public function doUpdate(Updater $updater)
|
||||
{
|
||||
static::update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell the updater that this is a major update.
|
||||
* Leads to a more visible notice.
|
||||
*
|
||||
* NOTE to release manager: Remember to mention in the Changelog
|
||||
* that this update contains major DB upgrades and will take some time!
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
static function isMajorUpdate()
|
||||
public static function isMajorUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to enable maintenance mode during large updates
|
||||
* Enables maintenance mode. Should be used for updates where Piwik will be unavailable
|
||||
* for a large amount of time.
|
||||
*/
|
||||
static function enableMaintenanceMode()
|
||||
public static function enableMaintenanceMode()
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$config->init();
|
||||
|
||||
$tracker = $config->Tracker;
|
||||
$tracker['record_statistics'] = 0;
|
||||
|
|
@ -67,12 +118,11 @@ abstract class Updates
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper method to disable maintenance mode after large updates
|
||||
* Helper method to disable maintenance mode after large updates.
|
||||
*/
|
||||
static function disableMaintenanceMode()
|
||||
public static function disableMaintenanceMode()
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$config->init();
|
||||
|
||||
$tracker = $config->Tracker;
|
||||
$tracker['record_statistics'] = 1;
|
||||
|
|
@ -88,7 +138,6 @@ abstract class Updates
|
|||
public static function deletePluginFromConfigFile($pluginToDelete)
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$config->init();
|
||||
if (isset($config->Plugins['Plugins'])) {
|
||||
$plugins = $config->Plugins['Plugins'];
|
||||
if (($key = array_search($pluginToDelete, $plugins)) !== false) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue