executeMigrations() public method

Execute multiple migration queries from a single Update file.
public executeMigrations ( string $file, Migration[] $migrations )
$file string The path to the Updates file.
$migrations Piwik\Updater\Migration[] An array of migrations
Beispiel #1
0
 public function doUpdate(Updater $updater)
 {
     try {
         $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     } catch (\Exception $e) {
     }
 }
Beispiel #2
0
 public function doUpdate(Updater $updater)
 {
     $salt = Common::generateUniqId();
     $config = Config::getInstance();
     $superuser = $config->superuser;
     if (!isset($superuser['salt'])) {
         try {
             if (is_writable(Config::getLocalConfigPath())) {
                 $superuser['salt'] = $salt;
                 $config->superuser = $superuser;
                 $config->forceSave();
             } else {
                 throw new \Exception('mandatory update failed');
             }
         } catch (\Exception $e) {
             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>");
         }
     }
     $plugins = $config->Plugins;
     if (!in_array('MultiSites', $plugins)) {
         try {
             if (is_writable(Config::getLocalConfigPath())) {
                 $plugins[] = 'MultiSites';
                 $config->Plugins = $plugins;
                 $config->forceSave();
             } else {
                 throw new \Exception('optional update failed');
             }
         } catch (\Exception $e) {
             throw new \Exception("You can now enable the new MultiSites plugin in the Plugins screen in the Piwik admin!");
         }
     }
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
 }
Beispiel #3
0
 public function doUpdate(Updater $updater)
 {
     // delete schema version_
     Option::delete('version_Referers');
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     // old plugins deleted in 2.0-a17 update file
 }
Beispiel #4
0
 public function doUpdate(Updater $updater)
 {
     // manually remove ExampleFeedburner column
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     // remove ExampleFeedburner plugin
     $pluginToDelete = 'ExampleFeedburner';
     self::deletePluginFromConfigFile($pluginToDelete);
 }
Beispiel #5
0
 public function doUpdate(Updater $updater)
 {
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     try {
         \Piwik\Plugin\Manager::getInstance()->activatePlugin('Events');
     } catch (\Exception $e) {
     }
 }
Beispiel #6
0
 public function doUpdate(Updater $updater)
 {
     $pluginManager = \Piwik\Plugin\Manager::getInstance();
     try {
         $pluginManager->activatePlugin('UserLanguage');
     } catch (\Exception $e) {
     }
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
 }
Beispiel #7
0
 public function doUpdate(Updater $updater)
 {
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     try {
         self::migrateConfigSuperUserToDb();
     } catch (\Exception $e) {
         throw new UpdaterErrorException($e->getMessage());
     }
 }
Beispiel #8
0
 public function doUpdate(Updater $updater)
 {
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     // DeviceDetection upgrade in beta1 timed out on demo #6750
     $archiveBlobTables = self::getAllArchiveBlobTables();
     foreach ($archiveBlobTables as $table) {
         self::updateBrowserArchives($table);
         self::updateOsArchives($table);
     }
 }
Beispiel #9
0
 public function doUpdate(Updater $updater)
 {
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     $obsoleteDirectories = array('/plugins/AdminHome', '/plugins/Home', '/plugins/PluginsAdmin');
     foreach ($obsoleteDirectories as $dir) {
         if (file_exists(PIWIK_INCLUDE_PATH . $dir)) {
             Filesystem::unlinkRecursive(PIWIK_INCLUDE_PATH . $dir, true);
         }
     }
 }
Beispiel #10
0
 public function doUpdate(Updater $updater)
 {
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     $this->migratePluginEmailUpdateSetting();
     // added .woff and woff2 whitelisted file for apache webserver
     ServerFilesGenerator::deleteHtAccessFiles();
     ServerFilesGenerator::createHtAccessFiles();
     // Renamed plugin ExampleRssWidget -> RssWidget
     \Piwik\Plugin\Manager::getInstance()->activatePlugin('RssWidget');
     \Piwik\Plugin\Manager::getInstance()->deactivatePlugin('ExampleRssWidget');
 }
Beispiel #11
0
 public function doUpdate(Updater $updater)
 {
     try {
         $migrations = array();
         $table = Common::prefixTable('user_dashboard');
         $dashboards = Db::fetchAll('SELECT iddashboard, login, layout FROM `' . $table . '`');
         $updateQuery = 'UPDATE `' . $table . '` SET layout = ? WHERE iddashboard = ? AND login = ?';
         foreach ($dashboards as $dashboard) {
             $idDashboard = $dashboard['iddashboard'];
             $login = $dashboard['login'];
             $layout = $dashboard['layout'];
             $layout = html_entity_decode($layout);
             $layout = str_replace("\\\"", "\"", $layout);
             $migrations[] = $this->migration->db->boundSql($updateQuery, array($layout, $idDashboard, $login));
         }
         $updater->executeMigrations(__FILE__, $migrations);
         $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     } catch (\Exception $e) {
     }
 }
Beispiel #12
0
 public function doUpdate(Updater $updater)
 {
     try {
         self::enableMaintenanceMode();
         $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
         self::disableMaintenanceMode();
     } catch (\Exception $e) {
         self::disableMaintenanceMode();
         throw $e;
     }
 }
Beispiel #13
0
 public function doUpdate(Updater $updater)
 {
     $config = Config::getInstance();
     $dbInfos = $config->database;
     if (!isset($dbInfos['schema'])) {
         try {
             if (is_writable(Config::getLocalConfigPath())) {
                 $config->database = $dbInfos;
                 $config->forceSave();
             } else {
                 throw new \Exception('mandatory update failed');
             }
         } catch (\Exception $e) {
         }
     }
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
 }
Beispiel #14
0
 public function doUpdate(Updater $updater)
 {
     // first we disable the plugins and keep an array of warnings messages
     $pluginsToDisableMessage = array('GeoIP' => "GeoIP plugin was disabled, because it is not compatible with the new Piwik 1.2. \nYou can download the latest version of the plugin, compatible with Piwik 1.2.\n<a target='_blank' href='?module=Proxy&action=redirect&url=https://github.com/piwik/piwik/issues/45'>Click here.</a>", 'EntryPage' => "EntryPage plugin is not compatible with this version of Piwik, it was disabled.");
     $disabledPlugins = array();
     foreach ($pluginsToDisableMessage as $pluginToDisable => $warningMessage) {
         if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated($pluginToDisable)) {
             \Piwik\Plugin\Manager::getInstance()->deactivatePlugin($pluginToDisable);
             $disabledPlugins[] = $warningMessage;
         }
     }
     // Run the SQL
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     // Outputs warning message, pointing users to the plugin download page
     if (!empty($disabledPlugins)) {
         throw new \Exception("The following plugins were disabled during the upgrade:" . "<ul><li>" . implode('</li><li>', $disabledPlugins) . "</li></ul>");
     }
 }
Beispiel #15
0
 public function doUpdate(Updater $updater)
 {
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     if (!\Piwik\Plugin\Manager::getInstance()->isPluginLoaded('ScheduledReports')) {
         return;
     }
     try {
         // Common::prefixTable('pdf') has been heavily refactored to be more generic
         // The following actions are taken in this update script :
         // - create the new generic report table Common::prefixTable('report')
         // - migrate previous reports, if any, from Common::prefixTable('pdf') to Common::prefixTable('report')
         // - delete Common::prefixTable('pdf')
         $reports = Db::fetchAll('SELECT * FROM `' . Common::prefixTable('pdf') . '`');
         foreach ($reports as $report) {
             $idreport = $report['idreport'];
             $idsite = $report['idsite'];
             $login = $report['login'];
             $description = $report['description'];
             $period = $report['period'];
             $format = $report['format'];
             $display_format = $report['display_format'];
             $email_me = $report['email_me'];
             $additional_emails = $report['additional_emails'];
             $reports = $report['reports'];
             $ts_created = $report['ts_created'];
             $ts_last_sent = $report['ts_last_sent'];
             $deleted = $report['deleted'];
             $parameters = array();
             if (!is_null($additional_emails)) {
                 $parameters[ScheduledReports::ADDITIONAL_EMAILS_PARAMETER] = preg_split('/,/', $additional_emails);
             }
             $parameters[ScheduledReports::EMAIL_ME_PARAMETER] = is_null($email_me) ? ScheduledReports::EMAIL_ME_PARAMETER_DEFAULT_VALUE : (bool) $email_me;
             $parameters[ScheduledReports::DISPLAY_FORMAT_PARAMETER] = $display_format;
             Db::query('INSERT INTO `' . Common::prefixTable('report') . '` SET
                 idreport = ?, idsite = ?, login = ?, description = ?, period = ?,
                 type = ?, format = ?, reports = ?, parameters = ?, ts_created = ?,
                 ts_last_sent = ?, deleted = ?', array($idreport, $idsite, $login, $description, is_null($period) ? ScheduledReports::DEFAULT_PERIOD : $period, ScheduledReports::EMAIL_TYPE, is_null($format) ? ScheduledReports::DEFAULT_REPORT_FORMAT : $format, json_encode(preg_split('/,/', $reports)), json_encode($parameters), $ts_created, $ts_last_sent, $deleted));
         }
         $updater->executeMigration(__FILE__, $this->migration->db->dropTable('pdf'));
     } catch (\Exception $e) {
     }
 }
Beispiel #16
0
 public function doUpdate(Updater $updater)
 {
     // add tag & level columns to logger_message table
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
 }
Beispiel #17
0
 public function doUpdate(Updater $updater)
 {
     if (SettingsServer::isTimezoneSupportEnabled()) {
         $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     }
 }
Beispiel #18
0
 public function doUpdate(Updater $updater)
 {
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     self::updateIPAnonymizationSettings();
 }
Beispiel #19
0
 public function doUpdate(Updater $updater)
 {
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
 }
Beispiel #20
0
 public function doUpdate(Updater $updater)
 {
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
     $updater->executeMigrations(__FILE__, $this->getUserPasswordMigrations([]));
     ServerFilesGenerator::createFilesForSecurity();
 }
Beispiel #21
0
 public function doUpdate(Updater $updater)
 {
     // add excluded_user_agents column to site table
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
 }
Beispiel #22
0
 public function doUpdate(Updater $updater)
 {
     // change level column in logger_message table to string & remove other logging tables if empty
     $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
 }