当前位置: 首页>>代码示例>>PHP>>正文


PHP maybe_convert_table_to_utf8mb4函数代码示例

本文整理汇总了PHP中maybe_convert_table_to_utf8mb4函数的典型用法代码示例。如果您正苦于以下问题:PHP maybe_convert_table_to_utf8mb4函数的具体用法?PHP maybe_convert_table_to_utf8mb4怎么用?PHP maybe_convert_table_to_utf8mb4使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了maybe_convert_table_to_utf8mb4函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_table

 /**
  * Create the table
  *
  * @access  public
  * @since   1.6
  */
 public function create_table()
 {
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     if (version_compare($this->installed_version(), $this->version, '!=')) {
         $sql = "CREATE TABLE {$this->get_table_name()} (\n\t\t\t\t  id int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t  account_id bigint(20) NOT NULL,\n\t\t\t\t  image_id varchar(256) NOT NULL,\n\t\t\t\t  image_timestamp bigint(20) NOT NULL,\n\t\t\t\t  status enum('pending','posted','ignore','posting', 'moderate') NOT NULL,\n\t\t\t\t  media_type varchar(50) NOT NULL,\n\t\t\t\t  image_url varchar(256) NOT NULL,\n\t\t\t\t  image_thumb_url varchar(256) NOT NULL,\n\t\t\t\t  video_url varchar(256) NOT NULL,\n\t\t\t\t  tags text NULL,\n\t\t\t\t  filter varchar(256) NULL,\n\t\t\t\t  link varchar(256) NULL,\n\t\t\t\t  caption text NULL,\n\t\t\t\t  caption_clean text NULL,\n\t\t\t\t  caption_clean_no_tags text NULL,\n\t\t\t\t  username text NULL,\n\t\t\t\t  user_id varchar(256) NULL,\n\t\t\t\t  user_image_url text NULL,\n\t\t\t\t  latitude varchar(256) NULL,\n\t\t\t\t  longitude varchar(256) NULL,\n\t\t\t\t  location_name text NULL,\n\t\t\t\t  location_id varchar(256) NULL,\n\t\t\t\t  comments_count bigint(20) NOT NULL,\n\t\t\t\t  comments longblob NOT NULL,\n\t\t\t\t  likes_count bigint(20) NOT NULL,\n\t\t\t\t  UNIQUE KEY (id)\n\t\t\t) DEFAULT CHARACTER SET utf8;";
         dbDelta($sql);
         global $wpdb;
         if ('utf8mb4' === $wpdb->charset && function_exists('maybe_convert_table_to_utf8mb4')) {
             maybe_convert_table_to_utf8mb4($this->get_table_name());
         }
         update_option($this->option_key, $this->version);
     }
 }
开发者ID:VizualAbstract,项目名称:Marilyn,代码行数:19,代码来源:class-images-db.php

示例2: upgrade_network

/**
 * Executes network-level upgrade routines.
 *
 * @since 3.0.0
 */
function upgrade_network()
{
    global $wp_current_db_version, $wpdb;
    // 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 {$wpdb->sitemeta} a, {$wpdb->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";
        $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_') . '%', $wpdb->esc_like('_site_transient_timeout_') . '%', $time));
    }
    // 2.8.
    if ($wp_current_db_version < 11549) {
        $wpmu_sitewide_plugins = get_site_option('wpmu_sitewide_plugins');
        $active_sitewide_plugins = get_site_option('active_sitewide_plugins');
        if ($wpmu_sitewide_plugins) {
            if (!$active_sitewide_plugins) {
                $sitewide_plugins = (array) $wpmu_sitewide_plugins;
            } else {
                $sitewide_plugins = array_merge((array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins);
            }
            update_site_option('active_sitewide_plugins', $sitewide_plugins);
        }
        delete_site_option('wpmu_sitewide_plugins');
        delete_site_option('deactivated_sitewide_plugins');
        $start = 0;
        while ($rows = $wpdb->get_results("SELECT meta_key, meta_value FROM {$wpdb->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 ($wp_current_db_version < 13576) {
        update_site_option('global_terms_enabled', '1');
    }
    // 3.3
    if ($wp_current_db_version < 19390) {
        update_site_option('initial_db_version', $wp_current_db_version);
    }
    if ($wp_current_db_version < 19470) {
        if (false === get_site_option('active_sitewide_plugins')) {
            update_site_option('active_sitewide_plugins', array());
        }
    }
    // 3.4
    if ($wp_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 = wp_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 ($wp_current_db_version < 21823) {
        update_site_option('ms_files_rewriting', '1');
    }
    // 3.5.2
    if ($wp_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 ($wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4') {
        if (!(defined('DO_NOT_UPGRADE_GLOBAL_TABLES') && DO_NOT_UPGRADE_GLOBAL_TABLES)) {
            $wpdb->query("ALTER TABLE {$wpdb->usermeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
            $wpdb->query("ALTER TABLE {$wpdb->site} DROP INDEX domain, ADD INDEX domain(domain(140),path(51))");
            $wpdb->query("ALTER TABLE {$wpdb->sitemeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
            $wpdb->query("ALTER TABLE {$wpdb->signups} DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))");
            $tables = $wpdb->tables('global');
            foreach ($tables as $table) {
                maybe_convert_table_to_utf8mb4($table);
//.........这里部分代码省略.........
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:101,代码来源:upgrade.php

示例3: upgrade

 function upgrade()
 {
     global $wpdb, $charset_collate;
     parent::upgrade();
     $this->upgrade_query("create table if not exists " . NEWSLETTER_EMAILS_TABLE . " (id int auto_increment, primary key (id)) {$charset_collate}");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column message longtext");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column message_text longtext");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column subject varchar(255) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column type varchar(50) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column created timestamp not null default current_timestamp");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column status enum('new','sending','sent','paused') not null default 'new'");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column total int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column last_id int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column sent int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column send_on int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column track tinyint not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column editor tinyint not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column sex char(1) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " change column sex sex char(1) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column query text");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column preferences text");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column options longtext");
     // Cleans up old installations
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " drop column name");
     $this->upgrade_query("drop table if exists " . $wpdb->prefix . "newsletter_work");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " convert to character set utf8");
     if ($charset_collate != 'utf8mb4') {
         require_once ABSPATH . 'wp-admin/includes/upgrade.php';
         if (function_exists('maybe_convert_table_to_utf8mb4')) {
             maybe_convert_table_to_utf8mb4(NEWSLETTER_EMAILS_TABLE);
         }
     }
     // Some setting check to avoid the common support request for mis-configurations
     $options = $this->get_options();
     if (empty($options['sender_email'])) {
         // That code was taken from WordPress
         $sitename = strtolower($_SERVER['SERVER_NAME']);
         if (substr($sitename, 0, 4) == 'www.') {
             $sitename = substr($sitename, 4);
         }
         // WordPress build an address in the same way using wordpress@...
         $options['sender_email'] = 'newsletter@' . $sitename;
         $this->save_options($options);
     }
     if (empty($options['scheduler_max']) || !is_numeric($options['scheduler_max'])) {
         $options['scheduler_max'] = 100;
         $this->save_options($options);
     }
     if (empty($options['api_key'])) {
         $options['api_key'] = self::get_token();
         $this->save_options($options);
     }
     if (empty($options['scheduler_max'])) {
         $options['scheduler_max'] = 100;
         $this->save_options($options);
     }
     wp_clear_scheduled_hook('newsletter');
     wp_schedule_event(time() + 30, 'newsletter', 'newsletter');
     wp_clear_scheduled_hook('newsletter_extension_versions');
     wp_schedule_event(time() + 30, 'newsletter_extension_versions', 'newsletter_weekly');
     add_option('newsletter_extension_versions', array(), null, 'no');
     wp_clear_scheduled_hook('newsletter_update');
     wp_clear_scheduled_hook('newsletter_check_versions');
     wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter');
     wp_mkdir_p(WP_CONTENT_DIR . '/cache/newsletter');
     //wp_clear_scheduled_hook('newsletter_updates_run');
     wp_clear_scheduled_hook('newsletter_statistics_version_check');
     wp_clear_scheduled_hook('newsletter_reports_version_check');
     wp_clear_scheduled_hook('newsletter_feed_version_check');
     wp_clear_scheduled_hook('newsletter_popup_version_check');
     return true;
 }
开发者ID:blocher,项目名称:oneholyname,代码行数:72,代码来源:plugin.php

示例4: pre_schema_upgrade

/**
 * Runs before the schema is upgraded.
 *
 * @since 2.9.0
 *
 * @global int  $wp_current_db_version
 * @global wpdb $wpdb WordPress database abstraction object.
 */
function pre_schema_upgrade()
{
    global $wp_current_db_version, $wpdb;
    // Upgrade versions prior to 2.9
    if ($wp_current_db_version < 11557) {
        // Delete duplicate options. Keep the option with the highest option_id.
        $wpdb->query("DELETE o1 FROM {$wpdb->options} AS o1 JOIN {$wpdb->options} AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id");
        // Drop the old primary key and add the new.
        $wpdb->query("ALTER TABLE {$wpdb->options} DROP PRIMARY KEY, ADD PRIMARY KEY(option_id)");
        // Drop the old option_name index. dbDelta() doesn't do the drop.
        $wpdb->query("ALTER TABLE {$wpdb->options} DROP INDEX option_name");
    }
    // Multisite schema upgrades.
    if ($wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables()) {
        // Upgrade verions prior to 3.7
        if ($wp_current_db_version < 25179) {
            // New primary key for signups.
            $wpdb->query("ALTER TABLE {$wpdb->signups} ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
            $wpdb->query("ALTER TABLE {$wpdb->signups} DROP INDEX domain");
        }
        if ($wp_current_db_version < 25448) {
            // Convert archived from enum to tinyint.
            $wpdb->query("ALTER TABLE {$wpdb->blogs} CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'");
            $wpdb->query("ALTER TABLE {$wpdb->blogs} CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0");
        }
    }
    // Upgrade versions prior to 4.2.
    if ($wp_current_db_version < 31351) {
        if (!is_multisite() && wp_should_upgrade_global_tables()) {
            $wpdb->query("ALTER TABLE {$wpdb->usermeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
        }
        $wpdb->query("ALTER TABLE {$wpdb->terms} DROP INDEX slug, ADD INDEX slug(slug(191))");
        $wpdb->query("ALTER TABLE {$wpdb->terms} DROP INDEX name, ADD INDEX name(name(191))");
        $wpdb->query("ALTER TABLE {$wpdb->commentmeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
        $wpdb->query("ALTER TABLE {$wpdb->postmeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
        $wpdb->query("ALTER TABLE {$wpdb->posts} DROP INDEX post_name, ADD INDEX post_name(post_name(191))");
    }
    // Upgrade versions prior to 4.4.
    if ($wp_current_db_version < 34978) {
        // If compatible termmeta table is found, use it, but enforce a proper index and update collation.
        if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->termmeta}'") && $wpdb->get_results("SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'")) {
            $wpdb->query("ALTER TABLE {$wpdb->termmeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
            maybe_convert_table_to_utf8mb4($wpdb->termmeta);
        }
    }
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:54,代码来源:upgrade.php

示例5: upgradeUTF

 public static function upgradeUTF()
 {
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     if (!function_exists('maybe_convert_table_to_utf8mb4')) {
         return;
     }
     // Versions before 4.2.0
     $table_name = maxUtils::get_buttons_table_name();
     $collection_table_name = maxUtils::get_collection_table_name();
     maybe_convert_table_to_utf8mb4($table_name);
     maybe_convert_table_to_utf8mb4($collection_table_name);
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:12,代码来源:installation.php

示例6: gwolle_gb_upgrade


//.........这里部分代码省略.........
                if ($user_info === FALSE) {
                    // Invalid $user_id
                    continue;
                }
                if ($user_id > 0) {
                    $user_ids[] = $user_id;
                }
            }
            $user_ids = implode(",", $user_ids);
            update_option('gwolle_gb-notifyByMail', $user_ids);
        }
    }
    if (version_compare($installed_ver, '0.9.9.2', '<')) {
        /*
         *  0.9.9.1->0.9.9.2
         *  Remove the options of Users that are subcribed to notification mails
         */
        $wpdb->query("\n\t\t\t\tDELETE\n\t\t\t\t\tFROM " . $wpdb->prefix . "options\n\t\t\t\tWHERE\n\t\t\t\t\toption_name LIKE 'gwolle_gb-notifyByMail-%'\n\t\t\t\tOR\n\t\t\t\t\toption_name LIKE 'gwolle_gb-notifyAll-%'\n\t\t\t");
    }
    if (version_compare($installed_ver, '1.0.5', '<')) {
        /*
         *  1.0.4->1.0.5
         *  Remove obsolete options
         */
        delete_option('gwolle_gb-access-level');
        delete_option('gwolle_gb-checkForImport');
        delete_option('gwolle_gb-post_ID');
        /* Alter table of logs */
        $wpdb->query("\n\t\t\tALTER TABLE {$wpdb->gwolle_gb_log}\n\t\t\t\tCHANGE log_id id int(8) NOT NULL auto_increment,\n\t\t\t\tCHANGE log_subject subject text NOT NULL,\n\t\t\t\tCHANGE log_subjectId entry_id int(5) NOT NULL,\n\t\t\t\tCHANGE log_authorId author_id int(5) NOT NULL,\n\t\t\t\tCHANGE log_date date varchar(12) NOT NULL\n\t\t\t");
    }
    if (version_compare($installed_ver, '1.0.6', '<')) {
        /*
         * 1.0.5->1.0.6
         * Alter table of entries
         */
        $wpdb->query("\n\t\t\tALTER TABLE {$wpdb->gwolle_gb_entries}\n\t\t\t\tCHANGE `entry_id` `id` INT(10) NOT NULL AUTO_INCREMENT,\n\t\t\t\tCHANGE `entry_author_name` `author_name` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,\n\t\t\t\tCHANGE `entry_authorAdminId` `author_id` INT(5) NOT NULL DEFAULT '0',\n\t\t\t\tCHANGE `entry_author_email` `author_email` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,\n\t\t\t\tCHANGE `entry_author_origin` `author_origin` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,\n\t\t\t\tCHANGE `entry_author_website` `author_website` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,\n\t\t\t\tCHANGE `entry_author_ip` `author_ip` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,\n\t\t\t\tCHANGE `entry_author_host` `author_host` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,\n\t\t\t\tCHANGE `entry_content` `content` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,\n\t\t\t\tCHANGE `entry_date` `date` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,\n\t\t\t\tCHANGE `entry_isChecked` `ischecked` TINYINT(1) NOT NULL,\n\t\t\t\tCHANGE `entry_checkedBy` `checkedby` INT(5) NOT NULL,\n\t\t\t\tCHANGE `entry_isDeleted` `istrash` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0',\n\t\t\t\tCHANGE `entry_isSpam` `isspam` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0'\n\t\t\t");
    }
    if (version_compare($installed_ver, '1.1.3', '<')) {
        /*
         * 1.1.2->1.1.3
         */
        delete_option('gwolle_gb-guestbookOnly');
        delete_option('gwolle_gb-defaultMailText');
        if (get_option('gwolle_gb-recaptcha-active', 'false') == 'true') {
            $form_setting = array('form_recaptcha_enabled' => 'true');
            $form_setting = serialize($form_setting);
            update_option('gwolle_gb-form', $form_setting);
        }
        delete_option('gwolle_gb-recaptcha-active');
    }
    if (version_compare($installed_ver, '1.3.8', '<')) {
        /*
         * 1.3.7->1.3.8
         * Call flush_rules() as a method of the $wp_rewrite object for the RSS Feed.
         */
        global $wp_rewrite;
        $wp_rewrite->flush_rules(false);
    }
    if (version_compare($installed_ver, '1.4.2', '<')) {
        /*
         * 1.4.1->1.4.2
         * Add datetime field to database and fill it from the date column.
         */
        $wpdb->query("\n\t\t\tALTER TABLE {$wpdb->gwolle_gb_entries} ADD `datetime` BIGINT(8) UNSIGNED NOT NULL AFTER `date`;\n\t\t");
        $wpdb->query("\n\t\t\tUPDATE `{$wpdb->gwolle_gb_entries}` SET `datetime` = `date`;\n\t\t");
        $wpdb->query("\n\t\t\tALTER TABLE {$wpdb->gwolle_gb_log} ADD `datetime` BIGINT(8) UNSIGNED NOT NULL AFTER `date`;\n\t\t");
        $wpdb->query("\n\t\t\tUPDATE `{$wpdb->gwolle_gb_log}` SET `datetime` = `date`;\n\t\t");
    }
    if (version_compare($installed_ver, '1.4.3', '<')) {
        /*
         * 1.4.2->1.4.3
         * Remove date field from database.
         */
        $wpdb->query("\n\t\t\tALTER TABLE {$wpdb->gwolle_gb_entries} DROP COLUMN `date`;\n\t\t");
        $wpdb->query("\n\t\t\tALTER TABLE {$wpdb->gwolle_gb_log} DROP COLUMN `date`;\n\t\t");
    }
    if (version_compare($installed_ver, '1.4.8', '<')) {
        /*
         * 1.4.7->1.4.8
         * Add admin_reply and admin_reply_uid field to database.
         */
        $wpdb->query("\n\t\t\tALTER TABLE {$wpdb->gwolle_gb_entries} ADD `admin_reply` LONGTEXT NOT NULL AFTER `isspam`;\n\t\t");
        $wpdb->query("\n\t\t\tALTER TABLE {$wpdb->gwolle_gb_entries} ADD `admin_reply_uid` INT(5) NOT NULL AFTER `admin_reply`;\n\t\t");
    }
    if (version_compare($installed_ver, '1.5.1', '<')) {
        /*
         * 1.5.0->1.5.1
         * Add book_id field to database and fill it with value '1'.
         */
        $wpdb->query("\n\t\t\tALTER TABLE {$wpdb->gwolle_gb_entries} ADD `book_id` INT(8) UNSIGNED NOT NULL default '1' AFTER `admin_reply_uid`;\n\t\t");
    }
    /* Upgrade to new shiny db collation. Since WP 4.2 */
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    if (function_exists('maybe_convert_table_to_utf8mb4')) {
        maybe_convert_table_to_utf8mb4($wpdb->gwolle_gb_entries);
        maybe_convert_table_to_utf8mb4($wpdb->gwolle_gb_log);
    }
    /* Update the plugin version option */
    update_option('gwolle_gb_version', GWOLLE_GB_VER);
}
开发者ID:RainGrid,项目名称:site,代码行数:101,代码来源:upgrade.php

示例7: upgrade

 function upgrade()
 {
     global $wpdb, $charset_collate;
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     parent::upgrade();
     $this->upgrade_query("create table if not exists " . NEWSLETTER_EMAILS_TABLE . " (id int auto_increment, primary key (id)) {$charset_collate}");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column message longtext");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column message_text longtext");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column subject varchar(255) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column type varchar(50) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column created timestamp not null default current_timestamp");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column status enum('new','sending','sent','paused') not null default 'new'");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column total int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column last_id int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column sent int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column send_on int not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column track tinyint not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column editor tinyint not null default 0");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column sex char(1) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " change column sex sex char(1) not null default ''");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column query text");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column preferences text");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column options longtext");
     // Cleans up old installations
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " drop column name");
     $this->upgrade_query("drop table if exists " . $wpdb->prefix . "newsletter_work");
     $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " convert to character set utf8");
     // WP does not manage composite primary key when it tries to upgrade a table...
     $suppress_errors = $wpdb->suppress_errors(true);
     dbDelta("CREATE TABLE " . $wpdb->prefix . "newsletter_sent (\n            email_id int(10) unsigned NOT NULL DEFAULT '0',\n            user_id int(10) unsigned NOT NULL DEFAULT '0',\n            status tinyint(1) unsigned NOT NULL DEFAULT '0',\n            open tinyint(1) unsigned NOT NULL DEFAULT '0',\n            time int(10) unsigned NOT NULL DEFAULT '0',\n            error varchar(100) NOT NULL DEFAULT '',\n\t    ip varchar(100) NOT NULL DEFAULT '',\n            PRIMARY KEY (email_id,user_id),\n            KEY user_id (user_id),\n            KEY email_id (email_id)\n          ) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
     $wpdb->suppress_errors($suppress_errors);
     if ('utf8mb4' === $wpdb->charset) {
         require_once ABSPATH . 'wp-admin/includes/upgrade.php';
         if (function_exists('maybe_convert_table_to_utf8mb4')) {
             maybe_convert_table_to_utf8mb4(NEWSLETTER_EMAILS_TABLE);
         }
     }
     // Some setting check to avoid the common support request for mis-configurations
     $options = $this->get_options();
     if (empty($options['sender_email'])) {
         // That code was taken from WordPress
         $sitename = strtolower($_SERVER['SERVER_NAME']);
         if (substr($sitename, 0, 4) == 'www.') {
             $sitename = substr($sitename, 4);
         }
         // WordPress build an address in the same way using wordpress@...
         $options['sender_email'] = 'newsletter@' . $sitename;
         $this->save_options($options);
     }
     if (empty($options['scheduler_max']) || !is_numeric($options['scheduler_max'])) {
         $options['scheduler_max'] = 100;
         $this->save_options($options);
     }
     if (empty($options['api_key'])) {
         $options['api_key'] = self::get_token();
         $this->save_options($options);
     }
     if (empty($options['scheduler_max'])) {
         $options['scheduler_max'] = 100;
         $this->save_options($options);
     }
     wp_clear_scheduled_hook('newsletter');
     wp_schedule_event(time() + 30, 'newsletter', 'newsletter');
     wp_clear_scheduled_hook('newsletter_extension_versions');
     wp_schedule_event(time() + 30, 'newsletter_extension_versions', 'newsletter_weekly');
     add_option('newsletter_extension_versions', array(), null, 'no');
     wp_clear_scheduled_hook('newsletter_update');
     wp_clear_scheduled_hook('newsletter_check_versions');
     //wp_mkdir_p(WP_CONTENT_DIR . '/extensions/newsletter');
     //wp_mkdir_p(WP_CONTENT_DIR . '/cache/newsletter');
     //wp_clear_scheduled_hook('newsletter_updates_run');
     wp_clear_scheduled_hook('newsletter_statistics_version_check');
     wp_clear_scheduled_hook('newsletter_reports_version_check');
     wp_clear_scheduled_hook('newsletter_feed_version_check');
     wp_clear_scheduled_hook('newsletter_popup_version_check');
     // If the original options has already saved once
     if (isset($options['smtp_host'])) {
         $smtp_options['enabled'] = $options['smtp_enabled'];
         $smtp_options['test_email'] = $options['smtp_test_email'];
         $smtp_options['host'] = $options['smtp_host'];
         $smtp_options['pass'] = $options['smtp_pass'];
         $smtp_options['port'] = $options['smtp_port'];
         $smtp_options['user'] = $options['smtp_user'];
         $smtp_options['secure'] = $options['smtp_secure'];
         $this->save_options($smtp_options, 'smtp');
         unset($options['smtp_enabled']);
         unset($options['smtp_test_email']);
         unset($options['smtp_pass']);
         unset($options['smtp_port']);
         unset($options['smtp_user']);
         unset($options['smtp_secure']);
         unset($options['smtp_host']);
         $this->save_options($options);
     }
     $this->init_options('smtp');
     return true;
 }
开发者ID:radikalportal,项目名称:radikalportal,代码行数:97,代码来源:plugin.php

示例8: finalize_migration

 function finalize_migration()
 {
     $this->set_post_data();
     $tables = explode(',', $this->post_data['tables']);
     $temp_prefix = $this->post_data['temp_prefix'];
     $temp_tables = array();
     foreach ($tables as $table) {
         $temp_tables[] = $temp_prefix . $table;
     }
     // Update tables to utf8mb4 if MySQL version > 5.5.3
     global $wpdb;
     if (version_compare($wpdb->db_version(), '5.5.3', '>=')) {
         require_once ABSPATH . '/wp-admin/includes/upgrade.php';
         // WordPress versions 4.2 or greater
         if (function_exists('maybe_convert_table_to_utf8mb4')) {
             foreach ($temp_tables as $table) {
                 maybe_convert_table_to_utf8mb4($table);
             }
         }
     }
     $sql = "SET FOREIGN_KEY_CHECKS=0;\n";
     $sql .= $this->get_preserved_options_queries($temp_tables);
     foreach ($temp_tables as $table) {
         $sql .= 'DROP TABLE IF EXISTS ' . $this->backquote(substr($table, strlen($temp_prefix))) . ';';
         $sql .= "\n";
         $sql .= 'RENAME TABLE ' . $this->backquote($table) . ' TO ' . $this->backquote(substr($table, strlen($temp_prefix))) . ';';
         $sql .= "\n";
     }
     $alter_table_name = $this->get_alter_table_name();
     $sql .= $this->get_alter_queries();
     $sql .= 'DROP TABLE IF EXISTS ' . $this->backquote($alter_table_name) . ";\n";
     $process_chunk_result = $this->process_chunk($sql);
     if (true !== $process_chunk_result) {
         $result = $this->end_ajax($process_chunk_result);
         return $result;
     }
     $type = isset($this->post_data['type']) ? 'push' : 'pull';
     $location = isset($this->post_data['location']) ? $this->post_data['location'] : $this->post_data['url'];
     if (!isset($this->post_data['location'])) {
         $data = array();
         $data['action'] = 'wpmdb_fire_migration_complete';
         $data['url'] = home_url();
         $data['sig'] = $this->create_signature($data, $this->post_data['key']);
         $ajax_url = trailingslashit($this->post_data['url']) . 'wp-admin/admin-ajax.php';
         $response = $this->remote_post($ajax_url, $data, __FUNCTION__);
         ob_start();
         echo esc_html($response);
         $this->display_errors();
         $maybe_errors = trim(ob_get_clean());
         if (false === empty($maybe_errors)) {
             $result = $this->end_ajax($maybe_errors);
             return $result;
         }
     }
     // flush rewrite rules to prevent 404s and other oddities
     wp_cache_flush();
     global $wp_rewrite;
     $wp_rewrite->init();
     flush_rewrite_rules(true);
     // true = hard refresh, recreates the .htaccess file
     do_action('wpmdb_migration_complete', $type, $location);
 }
开发者ID:kirstyburgoine,项目名称:DuckRaces,代码行数:62,代码来源:wpmdbpro.php

示例9: pre_schema_upgrade

/**
 * Runs before the schema is upgraded.
 *
 * @since 2.9.0
 *
 * @global int  $wp_current_db_version
 * @global wpdb $wpdb WordPress database abstraction object.
 */
function pre_schema_upgrade()
{
    global $wp_current_db_version, $wpdb;
    // Upgrade versions prior to 2.9
    if ($wp_current_db_version < 11557) {
        // Delete duplicate options. Keep the option with the highest option_id.
        $wpdb->query("DELETE o1 FROM {$wpdb->options} AS o1 JOIN {$wpdb->options} AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id");
        // Drop the old primary key and add the new.
        $wpdb->query("ALTER TABLE {$wpdb->options} DROP PRIMARY KEY, ADD PRIMARY KEY(option_id)");
        // Drop the old option_name index. dbDelta() doesn't do the drop.
        $wpdb->query("ALTER TABLE {$wpdb->options} DROP INDEX option_name");
    }
    // Upgrade versions prior to 4.2.
    if ($wp_current_db_version < 31351) {
        if (wp_should_upgrade_global_tables()) {
            $wpdb->query("ALTER TABLE {$wpdb->usermeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
        }
        $wpdb->query("ALTER TABLE {$wpdb->terms} DROP INDEX slug, ADD INDEX slug(slug(191))");
        $wpdb->query("ALTER TABLE {$wpdb->terms} DROP INDEX name, ADD INDEX name(name(191))");
        $wpdb->query("ALTER TABLE {$wpdb->commentmeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
        $wpdb->query("ALTER TABLE {$wpdb->postmeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
        $wpdb->query("ALTER TABLE {$wpdb->posts} DROP INDEX post_name, ADD INDEX post_name(post_name(191))");
    }
    // Upgrade versions prior to 4.4.
    if ($wp_current_db_version < 34978) {
        // If compatible termmeta table is found, use it, but enforce a proper index and update collation.
        if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->termmeta}'") && $wpdb->get_results("SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'")) {
            $wpdb->query("ALTER TABLE {$wpdb->termmeta} DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))");
            maybe_convert_table_to_utf8mb4($wpdb->termmeta);
        }
    }
}
开发者ID:7press,项目名称:7press,代码行数:40,代码来源:upgrade.php

示例10: update_table_collation

 /**
  * Updates Table collation to `utf8mb4`
  */
 function update_table_collation()
 {
     if (!version_compare($this->version, "1.0.8.2")) {
         return;
     }
     $migrated_version = get_option(self::MIGRATED_VERSION);
     if ($migrated_version === $this->version) {
         return;
     }
     $table = Chat::tablename('message');
     require_once ABSPATH . '/wp-admin/includes/upgrade.php';
     if (function_exists('maybe_convert_table_to_utf8mb4')) {
         maybe_convert_table_to_utf8mb4($table);
     }
     update_option(self::MIGRATED_VERSION, $this->version);
 }
开发者ID:bmounteer,项目名称:SpeakOnIt,代码行数:19,代码来源:chat.php

示例11: em_create_tickets_bookings_table

function em_create_tickets_bookings_table()
{
    global $wpdb, $user_level;
    $table_name = $wpdb->prefix . 'em_tickets_bookings';
    // Creating the events table
    $sql = "CREATE TABLE {$table_name} (\r\n\t\t  ticket_booking_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,\r\n\t\t  booking_id bigint(20) unsigned NOT NULL,\r\n\t\t  ticket_id bigint(20) unsigned NOT NULL,\r\n\t\t  ticket_booking_spaces int(6) NOT NULL,\r\n\t\t  ticket_booking_price decimal(14,4) NOT NULL,\r\n\t\t  PRIMARY KEY  (ticket_booking_id)\r\n\t\t) DEFAULT CHARSET=utf8 ;";
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    dbDelta($sql);
    em_sort_out_table_nu_keys($table_name, array('booking_id', 'ticket_id'));
    if (em_check_utf8mb4_tables()) {
        maybe_convert_table_to_utf8mb4($table_name);
    }
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:13,代码来源:em-install.php


注:本文中的maybe_convert_table_to_utf8mb4函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。