"Fossies" - the Fresh Open Source Software Archive

Member "matomo/core/Updates/0.5.4.php" (3 Aug 2022, 2234 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.

    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\Config;
   14 use Piwik\Updater;
   15 use Piwik\Updates;
   16 use Piwik\Updater\Migration\Factory as MigrationFactory;
   17 
   18 /**
   19  */
   20 class Updates_0_5_4 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         return array(
   35             $this->migration->db->changeColumnType('log_action', 'name', 'TEXT'),
   36         );
   37     }
   38 
   39     public function doUpdate(Updater $updater)
   40     {
   41         $salt = Common::generateUniqId();
   42         $config = Config::getInstance();
   43         $superuser = $config->superuser;
   44         if (!isset($superuser['salt'])) {
   45             try {
   46                 if (is_writable(Config::getLocalConfigPath())) {
   47                     $superuser['salt'] = $salt;
   48                     $config->superuser = $superuser;
   49                     $config->forceSave();
   50                 } else {
   51                     throw new \Exception('mandatory update failed');
   52                 }
   53             } catch (\Exception $e) {
   54                 throw new \Piwik\UpdaterErrorException("Please edit your config/config.ini.php file and add below <code>[superuser]</code> the following line: <br /><code>salt = $salt</code>");
   55             }
   56         }
   57 
   58         $plugins = $config->Plugins;
   59         if (!in_array('MultiSites', $plugins)) {
   60             try {
   61                 if (is_writable(Config::getLocalConfigPath())) {
   62                     $plugins[] = 'MultiSites';
   63                     $config->Plugins = $plugins;
   64                     $config->forceSave();
   65                 } else {
   66                     throw new \Exception('optional update failed');
   67                 }
   68             } catch (\Exception $e) {
   69                 throw new \Exception("You can now enable the new MultiSites plugin in the Plugins screen in the Matomo admin!");
   70             }
   71         }
   72 
   73         $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
   74     }
   75 }