/** * Executes network-level upgrade routines. * * @since 0.0.1 * * @global int $hq_current_db_version * @global hqdb $hqdb */ function upgrade_network() { global $hq_current_db_version, $hqdb; // Always. if (is_main_network()) { /* * Deletes all expired transients. The multi-table delete syntax is used * to delete the transient record from table a, and the corresponding * transient_timeout record from table b. */ $time = time(); $sql = "DELETE a, b FROM {$hqdb->sitemeta} a, {$hqdb->sitemeta} b\n\t\t\tWHERE a.meta_key LIKE %s\n\t\t\tAND a.meta_key NOT LIKE %s\n\t\t\tAND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) )\n\t\t\tAND b.meta_value < %d"; $hqdb->query($hqdb->prepare($sql, $hqdb->esc_like('_site_transient_') . '%', $hqdb->esc_like('_site_transient_timeout_') . '%', $time)); } // 2.8. if ($hq_current_db_version < 11549) { $hqmu_sitewide_plugins = get_site_option('hqmu_sitewide_plugins'); $active_sitewide_plugins = get_site_option('active_sitewide_plugins'); if ($hqmu_sitewide_plugins) { if (!$active_sitewide_plugins) { $sitewide_plugins = (array) $hqmu_sitewide_plugins; } else { $sitewide_plugins = array_merge((array) $active_sitewide_plugins, (array) $hqmu_sitewide_plugins); } update_site_option('active_sitewide_plugins', $sitewide_plugins); } delete_site_option('hqmu_sitewide_plugins'); delete_site_option('deactivated_sitewide_plugins'); $start = 0; while ($rows = $hqdb->get_results("SELECT meta_key, meta_value FROM {$hqdb->sitemeta} ORDER BY meta_id LIMIT {$start}, 20")) { foreach ($rows as $row) { $value = $row->meta_value; if (!@unserialize($value)) { $value = stripslashes($value); } if ($value !== $row->meta_value) { update_site_option($row->meta_key, $value); } } $start += 20; } } // 3.0 if ($hq_current_db_version < 13576) { update_site_option('global_terms_enabled', '1'); } // 3.3 if ($hq_current_db_version < 19390) { update_site_option('initial_db_version', $hq_current_db_version); } if ($hq_current_db_version < 19470) { if (false === get_site_option('active_sitewide_plugins')) { update_site_option('active_sitewide_plugins', array()); } } // 3.4 if ($hq_current_db_version < 20148) { // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. $allowedthemes = get_site_option('allowedthemes'); $allowed_themes = get_site_option('allowed_themes'); if (false === $allowedthemes && is_array($allowed_themes) && $allowed_themes) { $converted = array(); $themes = hq_get_themes(); foreach ($themes as $stylesheet => $theme_data) { if (isset($allowed_themes[$theme_data->get('Name')])) { $converted[$stylesheet] = true; } } update_site_option('allowedthemes', $converted); delete_site_option('allowed_themes'); } } // 3.5 if ($hq_current_db_version < 21823) { update_site_option('ms_files_rewriting', '1'); } // 3.5.2 if ($hq_current_db_version < 24448) { $illegal_names = get_site_option('illegal_names'); if (is_array($illegal_names) && count($illegal_names) === 1) { $illegal_name = reset($illegal_names); $illegal_names = explode(' ', $illegal_name); update_site_option('illegal_names', $illegal_names); } } // 4.2 if ($hq_current_db_version < 31351 && $hqdb->charset === 'utf8mb4') { if (hq_should_upgrade_global_tables()) { $hqdb->query("ALTER TABLE {$hqdb->usermeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); $hqdb->query("ALTER TABLE {$hqdb->site} DROP INDEX domain, ADD INDEX domain(domain(140),path(51))"); $hqdb->query("ALTER TABLE {$hqdb->sitemeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); $hqdb->query("ALTER TABLE {$hqdb->signups} DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))"); $tables = $hqdb->tables('global'); // sitecategories may not exist. //TODO: Goyo //if ( ! $hqdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) { unset($tables['sitecategories']); //} foreach ($tables as $table) { maybe_convert_table_to_utf8mb4($table); } } } // 4.3 if ($hq_current_db_version < 33055 && 'utf8mb4' === $hqdb->charset) { if (hq_should_upgrade_global_tables()) { $upgrade = false; $indexes = $hqdb->get_results("SHOW INDEXES FROM {$hqdb->signups}"); foreach ($indexes as $index) { if ('domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part) { $upgrade = true; break; } } if ($upgrade) { $hqdb->query("ALTER TABLE {$hqdb->signups} DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))"); } $tables = $hqdb->tables('global'); // sitecategories may not exist. //TODO: Goyo //if ( ! $hqdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) { unset($tables['sitecategories']); //} foreach ($tables as $table) { maybe_convert_table_to_utf8mb4($table); } } } }
/** * Clears the cache held by get_theme_roots() and HQ_Theme. * * @since 0.0.1 * @param bool $clear_update_cache Whether to clear the Theme updates cache */ function hq_clean_themes_cache($clear_update_cache = true) { if ($clear_update_cache) { delete_site_transient('update_themes'); } search_theme_directories(true); foreach (hq_get_themes(array('errors' => null)) as $theme) { $theme->cache_delete(); } }