"Fossies" - the Fresh Open Source Software Archive

Member "matomo/core/Updates/0.6-rc1.php" (3 Aug 2022, 3852 Bytes) of package /linux/www/matomo-4.11.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.


    1 <?php
    2 /**
    3  * Matomo - free/libre analytics platform
    4  *
    5  * @link https://matomo.org
    6  * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
    7  *
    8  */
    9 
   10 namespace Piwik\Updates;
   11 
   12 use Piwik\Common;
   13 use Piwik\Updater;
   14 use Piwik\Updates;
   15 use Piwik\Updater\Migration\Factory as MigrationFactory;
   16 use Piwik\Updater\Migration;
   17 
   18 /**
   19  */
   20 class Updates_0_6_rc1 extends Updates
   21 {
   22     /**
   23      * @var MigrationFactory
   24      */
   25     private $migration;
   26 
   27     public function __construct(MigrationFactory $factory)
   28     {
   29         $this->migration = $factory;
   30     }
   31 
   32     public function getMigrations(Updater $updater)
   33     {
   34         $defaultTimezone = 'UTC';
   35         $defaultCurrency = 'USD';
   36 
   37         return array(
   38             $this->migration->db->changeColumnType('user', 'date_registered', 'TIMESTAMP NULL'),
   39             $this->migration->db->changeColumnType('site', 'ts_created', 'TIMESTAMP NULL'),
   40             $this->migration->db->addColumn('site', 'timezone', 'VARCHAR( 50 ) NOT NULL', 'ts_created'),
   41             $this->migration->db->sql('UPDATE ' . Common::prefixTable('site') . ' SET `timezone` = "' . $defaultTimezone . '";', Migration\Db::ERROR_CODE_DUPLICATE_COLUMN),
   42             $this->migration->db->addColumn('site', 'currency', 'CHAR( 3 ) NOT NULL', 'timezone'),
   43             $this->migration->db->sql('UPDATE ' . Common::prefixTable('site') . ' SET `currency` = "' . $defaultCurrency . '";', Migration\Db::ERROR_CODE_DUPLICATE_COLUMN),
   44             $this->migration->db->addColumn('site', 'excluded_ips', 'TEXT NOT NULL', 'currency'),
   45             $this->migration->db->addColumn('site', 'excluded_parameters', 'VARCHAR( 255 ) NOT NULL', 'excluded_ips'),
   46             $this->migration->db->addIndex('log_visit', array('idsite', 'visit_last_action_time', 'config_md5config(8)'), 'index_idsite_datetime_config'),
   47             $this->migration->db->addIndex('log_visit', array('idsite', 'idvisit')),
   48             $this->migration->db->dropIndex('log_conversion', 'index_idsite_date'),
   49             $this->migration->db->dropColumn('log_conversion', 'visit_server_date'),
   50             $this->migration->db->addIndex('log_conversion', array('idsite', 'server_time'), 'index_idsite_datetime'),
   51         );
   52     }
   53 
   54     public function doUpdate(Updater $updater)
   55     {
   56         // first we disable the plugins and keep an array of warnings messages
   57         $pluginsToDisableMessage = array(
   58             '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' rel='noopener' href='https://github.com/matomo-org/matomo/issues/502'>Click here.</a>",
   59             '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' rel='noopener' href='https://github.com/matomo-org/matomo/issues/45'>Click here.</a>"
   60         );
   61         $disabledPlugins = array();
   62         foreach ($pluginsToDisableMessage as $pluginToDisable => $warningMessage) {
   63             if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated($pluginToDisable)) {
   64                 \Piwik\Plugin\Manager::getInstance()->deactivatePlugin($pluginToDisable);
   65                 $disabledPlugins[] = $warningMessage;
   66             }
   67         }
   68 
   69         // Run the SQL
   70         $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
   71 
   72         // Outputs warning message, pointing users to the plugin download page
   73         if (!empty($disabledPlugins)) {
   74             throw new \Exception("The following plugins were disabled during the upgrade:"
   75                 . "<ul><li>" .
   76                 implode('</li><li>', $disabledPlugins) .
   77                 "</li></ul>");
   78         }
   79     }
   80 }