updateDatabase() public static method

Performs database update(s)
Deprecation:
public static updateDatabase ( string $file, array $sqlarray )
$file string Update script filename
$sqlarray array An array of SQL queries to be executed
示例#1
0
 public static function update()
 {
     $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::updateDatabase(__FILE__, self::getSql());
 }
示例#2
0
 static function update()
 {
     try {
         Updater::updateDatabase(__FILE__, self::getSql());
     } catch (\Exception $e) {
     }
 }
示例#3
0
 static function update()
 {
     // manually remove ExampleFeedburner column
     Updater::updateDatabase(__FILE__, self::getSql());
     // remove ExampleFeedburner plugin
     $pluginToDelete = 'ExampleFeedburner';
     self::deletePluginFromConfigFile($pluginToDelete);
 }
示例#4
0
 static function update()
 {
     Updater::updateDatabase(__FILE__, self::getSql());
     try {
         \Piwik\Plugin\Manager::getInstance()->activatePlugin('Events');
     } catch (\Exception $e) {
     }
 }
示例#5
0
 static function update()
 {
     $pluginManager = \Piwik\Plugin\Manager::getInstance();
     try {
         $pluginManager->activatePlugin('UserLanguage');
     } catch (\Exception $e) {
     }
     Updater::updateDatabase(__FILE__, self::getSql());
 }
示例#6
0
 public static function update()
 {
     Updater::updateDatabase(__FILE__, self::getSql());
     self::updateIPAnonymizationSettings();
     try {
         Manager::getInstance()->activatePlugin('TestRunner');
     } catch (\Exception $e) {
     }
 }
示例#7
0
 static function update()
 {
     Updater::updateDatabase(__FILE__, self::getSql());
     try {
         self::migrateConfigSuperUserToDb();
     } catch (\Exception $e) {
         throw new UpdaterErrorException($e->getMessage());
     }
 }
示例#8
0
 static function update()
 {
     Updater::updateDatabase(__FILE__, self::getSql());
     $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);
         }
     }
 }
示例#9
0
 public static function update()
 {
     Updater::updateDatabase(__FILE__, self::getSql());
     // DeviceDetection upgrade in beta1 timed out on demo #6750
     $archiveBlobTables = self::getAllArchiveBlobTables();
     foreach ($archiveBlobTables as $table) {
         self::updateBrowserArchives($table);
         self::updateOsArchives($table);
     }
 }
示例#10
0
 static function update()
 {
     try {
         self::enableMaintenanceMode();
         Updater::updateDatabase(__FILE__, self::getSql());
         self::disableMaintenanceMode();
     } catch (\Exception $e) {
         self::disableMaintenanceMode();
         throw $e;
     }
 }
示例#11
0
 public static function update()
 {
     // delete schema version_
     Option::delete('version_Referers');
     Updater::updateDatabase(__FILE__, self::getSql());
     // old plugins deleted in 2.0-a17 update file
     try {
         \Piwik\Plugin\Manager::getInstance()->activatePlugin('Referrers');
     } catch (\Exception $e) {
     }
     try {
         \Piwik\Plugin\Manager::getInstance()->activatePlugin('ScheduledReports');
     } catch (\Exception $e) {
     }
 }
示例#12
0
 static function update()
 {
     try {
         $dashboards = Db::fetchAll('SELECT * FROM `' . Common::prefixTable('user_dashboard') . '`');
         foreach ($dashboards as $dashboard) {
             $idDashboard = $dashboard['iddashboard'];
             $login = $dashboard['login'];
             $layout = $dashboard['layout'];
             $layout = html_entity_decode($layout);
             $layout = str_replace("\\\"", "\"", $layout);
             Db::query('UPDATE `' . Common::prefixTable('user_dashboard') . '` SET layout = ? WHERE iddashboard = ? AND login = ?', array($layout, $idDashboard, $login));
         }
         Updater::updateDatabase(__FILE__, self::getSql());
     } catch (\Exception $e) {
     }
 }
示例#13
0
 public static function update()
 {
     $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::updateDatabase(__FILE__, self::getSql());
 }
示例#14
0
 static function update()
 {
     // first we disable the plugins and keep an array of warnings messages
     $pluginsToDisableMessage = array('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' href='?module=Proxy&action=redirect&url=https://github.com/piwik/piwik/issues/502'>Click here.</a>", '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' href='?module=Proxy&action=redirect&url=https://github.com/piwik/piwik/issues/45'>Click here.</a>");
     $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::updateDatabase(__FILE__, self::getSql());
     // 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>");
     }
 }
示例#15
0
 static function update()
 {
     $config = Config::getInstance();
     $dbInfos = $config->database;
     if (!isset($dbInfos['schema'])) {
         try {
             if (is_writable(Config::getLocalConfigPath())) {
                 $dbInfos['schema'] = 'Myisam';
                 $config->database = $dbInfos;
                 $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>[database]</code> the following line: <br /><code>schema = Myisam</code>");
         }
     }
     Updater::updateDatabase(__FILE__, self::getSql());
 }
示例#16
0
    static function update()
    {
        Updater::updateDatabase(__FILE__, self::getSql());
        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));
            }
            Db::query('DROP TABLE `' . Common::prefixTable('pdf') . '`');
        } catch (\Exception $e) {
        }
    }
示例#17
0
 static function update()
 {
     // add tag & level columns to logger_message table
     Updater::updateDatabase(__FILE__, self::getSql());
 }
示例#18
0
 static function update()
 {
     // add excluded_user_agents column to site table
     Updater::updateDatabase(__FILE__, self::getSql());
 }
示例#19
0
 public static function update()
 {
     if (SettingsServer::isTimezoneSupportEnabled()) {
         Updater::updateDatabase(__FILE__, self::getSql());
     }
 }
示例#20
0
 static function update()
 {
     Updater::updateDatabase(__FILE__, self::getSql());
 }
示例#21
0
 public static function update()
 {
     // change level column in logger_message table to string & remove other logging tables if empty
     Updater::updateDatabase(__FILE__, self::getSql());
 }