"Fossies" - the Fresh Open Source Software Archive

Member "matomo/core/Updates/1.7.2-rc7.php" (3 Aug 2022, 1816 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\Db;
   14 use Piwik\Updater;
   15 use Piwik\Updates;
   16 use Piwik\Updater\Migration\Factory as MigrationFactory;
   17 
   18 /**
   19  */
   20 class Updates_1_7_2_rc7 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->addColumn('user_dashboard', 'name', 'VARCHAR( 100 ) NULL DEFAULT NULL', 'iddashboard')
   36         );
   37     }
   38 
   39     public function doUpdate(Updater $updater)
   40     {
   41         try {
   42             $migrations = array();
   43 
   44             $table = Common::prefixTable('user_dashboard');
   45             $dashboards = Db::fetchAll('SELECT iddashboard, login, layout FROM `' . $table . '`');
   46 
   47             $updateQuery = 'UPDATE `' . $table . '` SET layout = ? WHERE iddashboard = ? AND login = ?';
   48 
   49             foreach ($dashboards as $dashboard) {
   50                 $idDashboard = $dashboard['iddashboard'];
   51                 $login = $dashboard['login'];
   52                 $layout = $dashboard['layout'];
   53                 $layout = html_entity_decode($layout, ENT_COMPAT | ENT_HTML401, 'UTF-8');
   54                 $layout = str_replace("\\\"", "\"", $layout);
   55 
   56                 $migrations[] = $this->migration->db->boundSql($updateQuery, array($layout, $idDashboard, $login));
   57             }
   58 
   59             $updater->executeMigrations(__FILE__, $migrations);
   60             $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
   61         } catch (\Exception $e) {
   62         }
   63     }
   64 }