"Fossies" - the Fresh Open Source Software Archive

Member "matomo/core/Updates/0.9.1.php" (3 Aug 2022, 1781 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\SettingsServer;
   14 use Piwik\Updater;
   15 use Piwik\Updates;
   16 use Piwik\Updater\Migration\Factory as MigrationFactory;
   17 
   18 /**
   19  */
   20 class Updates_0_9_1 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         if (!SettingsServer::isTimezoneSupportEnabled()) {
   35             return array();
   36         }
   37         // @see http://bugs.php.net/46111
   38         $timezones = timezone_identifiers_list();
   39         $brokenTZ = array();
   40 
   41         foreach ($timezones as $timezone) {
   42             $testDate = "2008-08-19 13:00:00 " . $timezone;
   43 
   44             if (!strtotime($testDate)) {
   45                 $brokenTZ[] = $timezone;
   46             }
   47         }
   48         $timezoneList = '"' . implode('","', $brokenTZ) . '"';
   49 
   50         return array(
   51             $this->migration->db->sql(
   52                 'UPDATE ' . Common::prefixTable('site') . '
   53                  SET timezone = "UTC" WHERE timezone IN (' . $timezoneList . ')'),
   54 
   55             $this->migration->db->sql(
   56                 'UPDATE `' . Common::prefixTable('option') . '`
   57                  SET option_value = "UTC" WHERE option_name = "SitesManager_DefaultTimezone" AND option_value IN (' . $timezoneList . ')'),
   58         );
   59     }
   60 
   61     public function doUpdate(Updater $updater)
   62     {
   63         if (SettingsServer::isTimezoneSupportEnabled()) {
   64             $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
   65         }
   66     }
   67 }