aboutsummaryrefslogtreecommitdiff
path: root/srcs/wordpress/wp-admin/includes/upgrade.php
diff options
context:
space:
mode:
Diffstat (limited to 'srcs/wordpress/wp-admin/includes/upgrade.php')
-rw-r--r--srcs/wordpress/wp-admin/includes/upgrade.php3379
1 files changed, 0 insertions, 3379 deletions
diff --git a/srcs/wordpress/wp-admin/includes/upgrade.php b/srcs/wordpress/wp-admin/includes/upgrade.php
deleted file mode 100644
index 3b2d62d..0000000
--- a/srcs/wordpress/wp-admin/includes/upgrade.php
+++ /dev/null
@@ -1,3379 +0,0 @@
-<?php
-/**
- * WordPress Upgrade API
- *
- * Most of the functions are pluggable and can be overwritten.
- *
- * @package WordPress
- * @subpackage Administration
- */
-
-/** Include user installation customization script. */
-if ( file_exists( WP_CONTENT_DIR . '/install.php' ) ) {
- require( WP_CONTENT_DIR . '/install.php' );
-}
-
-/** WordPress Administration API */
-require_once( ABSPATH . 'wp-admin/includes/admin.php' );
-
-/** WordPress Schema API */
-require_once( ABSPATH . 'wp-admin/includes/schema.php' );
-
-if ( ! function_exists( 'wp_install' ) ) :
- /**
- * Installs the site.
- *
- * Runs the required functions to set up and populate the database,
- * including primary admin user and initial options.
- *
- * @since 2.1.0
- *
- * @param string $blog_title Site title.
- * @param string $user_name User's username.
- * @param string $user_email User's email.
- * @param bool $public Whether site is public.
- * @param string $deprecated Optional. Not used.
- * @param string $user_password Optional. User's chosen password. Default empty (random password).
- * @param string $language Optional. Language chosen. Default empty.
- * @return array Array keys 'url', 'user_id', 'password', and 'password_message'.
- */
- function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) {
- if ( ! empty( $deprecated ) ) {
- _deprecated_argument( __FUNCTION__, '2.6.0' );
- }
-
- wp_check_mysql_version();
- wp_cache_flush();
- make_db_current_silent();
- populate_options();
- populate_roles();
-
- update_option( 'blogname', $blog_title );
- update_option( 'admin_email', $user_email );
- update_option( 'blog_public', $public );
-
- // Freshness of site - in the future, this could get more specific about actions taken, perhaps.
- update_option( 'fresh_site', 1 );
-
- if ( $language ) {
- update_option( 'WPLANG', $language );
- }
-
- $guessurl = wp_guess_url();
-
- update_option( 'siteurl', $guessurl );
-
- // If not a public site, don't ping.
- if ( ! $public ) {
- update_option( 'default_pingback_flag', 0 );
- }
-
- /*
- * Create default user. If the user already exists, the user tables are
- * being shared among sites. Just set the role in that case.
- */
- $user_id = username_exists( $user_name );
- $user_password = trim( $user_password );
- $email_password = false;
- if ( ! $user_id && empty( $user_password ) ) {
- $user_password = wp_generate_password( 12, false );
- $message = __( '<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.' );
- $user_id = wp_create_user( $user_name, $user_password, $user_email );
- update_user_option( $user_id, 'default_password_nag', true, true );
- $email_password = true;
- } elseif ( ! $user_id ) {
- // Password has been provided
- $message = '<em>' . __( 'Your chosen password.' ) . '</em>';
- $user_id = wp_create_user( $user_name, $user_password, $user_email );
- } else {
- $message = __( 'User already exists. Password inherited.' );
- }
-
- $user = new WP_User( $user_id );
- $user->set_role( 'administrator' );
-
- wp_install_defaults( $user_id );
-
- wp_install_maybe_enable_pretty_permalinks();
-
- flush_rewrite_rules();
-
- wp_new_blog_notification( $blog_title, $guessurl, $user_id, ( $email_password ? $user_password : __( 'The password you chose during installation.' ) ) );
-
- wp_cache_flush();
-
- /**
- * Fires after a site is fully installed.
- *
- * @since 3.9.0
- *
- * @param WP_User $user The site owner.
- */
- do_action( 'wp_install', $user );
-
- return array(
- 'url' => $guessurl,
- 'user_id' => $user_id,
- 'password' => $user_password,
- 'password_message' => $message,
- );
- }
-endif;
-
-if ( ! function_exists( 'wp_install_defaults' ) ) :
- /**
- * Creates the initial content for a newly-installed site.
- *
- * Adds the default "Uncategorized" category, the first post (with comment),
- * first page, and default widgets for default theme for the current version.
- *
- * @since 2.1.0
- *
- * @global wpdb $wpdb WordPress database abstraction object.
- * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
- * @global string $table_prefix
- *
- * @param int $user_id User ID.
- */
- function wp_install_defaults( $user_id ) {
- global $wpdb, $wp_rewrite, $table_prefix;
-
- // Default category
- $cat_name = __( 'Uncategorized' );
- /* translators: Default category slug. */
- $cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug' ) );
-
- if ( global_terms_enabled() ) {
- $cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
- if ( $cat_id == null ) {
- $wpdb->insert(
- $wpdb->sitecategories,
- array(
- 'cat_ID' => 0,
- 'cat_name' => $cat_name,
- 'category_nicename' => $cat_slug,
- 'last_updated' => current_time( 'mysql', true ),
- )
- );
- $cat_id = $wpdb->insert_id;
- }
- update_option( 'default_category', $cat_id );
- } else {
- $cat_id = 1;
- }
-
- $wpdb->insert(
- $wpdb->terms,
- array(
- 'term_id' => $cat_id,
- 'name' => $cat_name,
- 'slug' => $cat_slug,
- 'term_group' => 0,
- )
- );
- $wpdb->insert(
- $wpdb->term_taxonomy,
- array(
- 'term_id' => $cat_id,
- 'taxonomy' => 'category',
- 'description' => '',
- 'parent' => 0,
- 'count' => 1,
- )
- );
- $cat_tt_id = $wpdb->insert_id;
-
- // First post
- $now = current_time( 'mysql' );
- $now_gmt = current_time( 'mysql', 1 );
- $first_post_guid = get_option( 'home' ) . '/?p=1';
-
- if ( is_multisite() ) {
- $first_post = get_site_option( 'first_post' );
-
- if ( ! $first_post ) {
- $first_post = "<!-- wp:paragraph -->\n<p>" .
- /* translators: First post content. %s: Site link. */
- __( 'Welcome to %s. This is your first post. Edit or delete it, then start writing!' ) .
- "</p>\n<!-- /wp:paragraph -->";
- }
-
- $first_post = sprintf(
- $first_post,
- sprintf( '<a href="%s">%s</a>', esc_url( network_home_url() ), get_network()->site_name )
- );
-
- // Back-compat for pre-4.4
- $first_post = str_replace( 'SITE_URL', esc_url( network_home_url() ), $first_post );
- $first_post = str_replace( 'SITE_NAME', get_network()->site_name, $first_post );
- } else {
- $first_post = "<!-- wp:paragraph -->\n<p>" .
- /* translators: First post content. %s: Site link. */
- __( 'Welcome to WordPress. This is your first post. Edit or delete it, then start writing!' ) .
- "</p>\n<!-- /wp:paragraph -->";
- }
-
- $wpdb->insert(
- $wpdb->posts,
- array(
- 'post_author' => $user_id,
- 'post_date' => $now,
- 'post_date_gmt' => $now_gmt,
- 'post_content' => $first_post,
- 'post_excerpt' => '',
- 'post_title' => __( 'Hello world!' ),
- /* translators: Default post slug. */
- 'post_name' => sanitize_title( _x( 'hello-world', 'Default post slug' ) ),
- 'post_modified' => $now,
- 'post_modified_gmt' => $now_gmt,
- 'guid' => $first_post_guid,
- 'comment_count' => 1,
- 'to_ping' => '',
- 'pinged' => '',
- 'post_content_filtered' => '',
- )
- );
- $wpdb->insert(
- $wpdb->term_relationships,
- array(
- 'term_taxonomy_id' => $cat_tt_id,
- 'object_id' => 1,
- )
- );
-
- // Default comment
- if ( is_multisite() ) {
- $first_comment_author = get_site_option( 'first_comment_author' );
- $first_comment_email = get_site_option( 'first_comment_email' );
- $first_comment_url = get_site_option( 'first_comment_url', network_home_url() );
- $first_comment = get_site_option( 'first_comment' );
- }
-
- $first_comment_author = ! empty( $first_comment_author ) ? $first_comment_author : __( 'A WordPress Commenter' );
- $first_comment_email = ! empty( $first_comment_email ) ? $first_comment_email : 'wapuu@wordpress.example';
- $first_comment_url = ! empty( $first_comment_url ) ? $first_comment_url : 'https://wordpress.org/';
- $first_comment = ! empty( $first_comment ) ? $first_comment : __(
- 'Hi, this is a comment.
-To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
-Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.'
- );
- $wpdb->insert(
- $wpdb->comments,
- array(
- 'comment_post_ID' => 1,
- 'comment_author' => $first_comment_author,
- 'comment_author_email' => $first_comment_email,
- 'comment_author_url' => $first_comment_url,
- 'comment_date' => $now,
- 'comment_date_gmt' => $now_gmt,
- 'comment_content' => $first_comment,
- )
- );
-
- // First Page
- if ( is_multisite() ) {
- $first_page = get_site_option( 'first_page' );
- }
-
- if ( empty( $first_page ) ) {
- $first_page = "<!-- wp:paragraph -->\n<p>";
- /* translators: First page content. */
- $first_page .= __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:" );
- $first_page .= "</p>\n<!-- /wp:paragraph -->\n\n";
-
- $first_page .= "<!-- wp:quote -->\n<blockquote class=\"wp-block-quote\"><p>";
- /* translators: First page content. */
- $first_page .= __( "Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)" );
- $first_page .= "</p></blockquote>\n<!-- /wp:quote -->\n\n";
-
- $first_page .= "<!-- wp:paragraph -->\n<p>";
- /* translators: First page content. */
- $first_page .= __( '...or something like this:' );
- $first_page .= "</p>\n<!-- /wp:paragraph -->\n\n";
-
- $first_page .= "<!-- wp:quote -->\n<blockquote class=\"wp-block-quote\"><p>";
- /* translators: First page content. */
- $first_page .= __( 'The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.' );
- $first_page .= "</p></blockquote>\n<!-- /wp:quote -->\n\n";
-
- $first_page .= "<!-- wp:paragraph -->\n<p>";
- $first_page .= sprintf(
- /* translators: First page content. %s: Site admin URL. */
- __( 'As a new WordPress user, you should go to <a href="%s">your dashboard</a> to delete this page and create new pages for your content. Have fun!' ),
- admin_url()
- );
- $first_page .= "</p>\n<!-- /wp:paragraph -->";
- }
-
- $first_post_guid = get_option( 'home' ) . '/?page_id=2';
- $wpdb->insert(
- $wpdb->posts,
- array(
- 'post_author' => $user_id,
- 'post_date' => $now,
- 'post_date_gmt' => $now_gmt,
- 'post_content' => $first_page,
- 'post_excerpt' => '',
- 'comment_status' => 'closed',
- 'post_title' => __( 'Sample Page' ),
- /* translators: Default page slug. */
- 'post_name' => __( 'sample-page' ),
- 'post_modified' => $now,
- 'post_modified_gmt' => $now_gmt,
- 'guid' => $first_post_guid,
- 'post_type' => 'page',
- 'to_ping' => '',
- 'pinged' => '',
- 'post_content_filtered' => '',
- )
- );
- $wpdb->insert(
- $wpdb->postmeta,
- array(
- 'post_id' => 2,
- 'meta_key' => '_wp_page_template',
- 'meta_value' => 'default',
- )
- );
-
- // Privacy Policy page
- if ( is_multisite() ) {
- // Disable by default unless the suggested content is provided.
- $privacy_policy_content = get_site_option( 'default_privacy_policy_content' );
- } else {
- if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
- include_once( ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php' );
- }
-
- $privacy_policy_content = WP_Privacy_Policy_Content::get_default_content();
- }
-
- if ( ! empty( $privacy_policy_content ) ) {
- $privacy_policy_guid = get_option( 'home' ) . '/?page_id=3';
-
- $wpdb->insert(
- $wpdb->posts,
- array(
- 'post_author' => $user_id,
- 'post_date' => $now,
- 'post_date_gmt' => $now_gmt,
- 'post_content' => $privacy_policy_content,
- 'post_excerpt' => '',
- 'comment_status' => 'closed',
- 'post_title' => __( 'Privacy Policy' ),
- /* translators: Privacy Policy page slug. */
- 'post_name' => __( 'privacy-policy' ),
- 'post_modified' => $now,
- 'post_modified_gmt' => $now_gmt,
- 'guid' => $privacy_policy_guid,
- 'post_type' => 'page',
- 'post_status' => 'draft',
- 'to_ping' => '',
- 'pinged' => '',
- 'post_content_filtered' => '',
- )
- );
- $wpdb->insert(
- $wpdb->postmeta,
- array(
- 'post_id' => 3,
- 'meta_key' => '_wp_page_template',
- 'meta_value' => 'default',
- )
- );
- update_option( 'wp_page_for_privacy_policy', 3 );
- }
-
- // Set up default widgets for default theme.
- update_option(
- 'widget_search',
- array(
- 2 => array( 'title' => '' ),
- '_multiwidget' => 1,
- )
- );
- update_option(
- 'widget_recent-posts',
- array(
- 2 => array(
- 'title' => '',
- 'number' => 5,
- ),
- '_multiwidget' => 1,
- )
- );
- update_option(
- 'widget_recent-comments',
- array(
- 2 => array(
- 'title' => '',
- 'number' => 5,
- ),
- '_multiwidget' => 1,
- )
- );
- update_option(
- 'widget_archives',
- array(
- 2 => array(
- 'title' => '',
- 'count' => 0,
- 'dropdown' => 0,
- ),
- '_multiwidget' => 1,
- )
- );
- update_option(
- 'widget_categories',
- array(
- 2 => array(
- 'title' => '',
- 'count' => 0,
- 'hierarchical' => 0,
- 'dropdown' => 0,
- ),
- '_multiwidget' => 1,
- )
- );
- update_option(
- 'widget_meta',
- array(
- 2 => array( 'title' => '' ),
- '_multiwidget' => 1,
- )
- );
- update_option(
- 'sidebars_widgets',
- array(
- 'wp_inactive_widgets' => array(),
- 'sidebar-1' => array(
- 0 => 'search-2',
- 1 => 'recent-posts-2',
- 2 => 'recent-comments-2',
- ),
- 'sidebar-2' => array(
- 0 => 'archives-2',
- 1 => 'categories-2',
- 2 => 'meta-2',
- ),
- 'array_version' => 3,
- )
- );
- if ( ! is_multisite() ) {
- update_user_meta( $user_id, 'show_welcome_panel', 1 );
- } elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) {
- update_user_meta( $user_id, 'show_welcome_panel', 2 );
- }
-
- if ( is_multisite() ) {
- // Flush rules to pick up the new page.
- $wp_rewrite->init();
- $wp_rewrite->flush_rules();
-
- $user = new WP_User( $user_id );
- $wpdb->update( $wpdb->options, array( 'option_value' => $user->user_email ), array( 'option_name' => 'admin_email' ) );
-
- // Remove all perms except for the login user.
- $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'user_level' ) );
- $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities' ) );
-
- // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
- if ( ! is_super_admin( $user_id ) && $user_id != 1 ) {
- $wpdb->delete(
- $wpdb->usermeta,
- array(
- 'user_id' => $user_id,
- 'meta_key' => $wpdb->base_prefix . '1_capabilities',
- )
- );
- }
- }
- }
-endif;
-
-/**
- * Maybe enable pretty permalinks on installation.
- *
- * If after enabling pretty permalinks don't work, fallback to query-string permalinks.
- *
- * @since 4.2.0
- *
- * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
- *
- * @return bool Whether pretty permalinks are enabled. False otherwise.
- */
-function wp_install_maybe_enable_pretty_permalinks() {
- global $wp_rewrite;
-
- // Bail if a permalink structure is already enabled.
- if ( get_option( 'permalink_structure' ) ) {
- return true;
- }
-
- /*
- * The Permalink structures to attempt.
- *
- * The first is designed for mod_rewrite or nginx rewriting.
- *
- * The second is PATHINFO-based permalinks for web server configurations
- * without a true rewrite module enabled.
- */
- $permalink_structures = array(
- '/%year%/%monthnum%/%day%/%postname%/',
- '/index.php/%year%/%monthnum%/%day%/%postname%/',
- );
-
- foreach ( (array) $permalink_structures as $permalink_structure ) {
- $wp_rewrite->set_permalink_structure( $permalink_structure );
-
- /*
- * Flush rules with the hard option to force refresh of the web-server's
- * rewrite config file (e.g. .htaccess or web.config).
- */
- $wp_rewrite->flush_rules( true );
-
- $test_url = '';
-
- // Test against a real WordPress Post
- $first_post = get_page_by_path( sanitize_title( _x( 'hello-world', 'Default post slug' ) ), OBJECT, 'post' );
- if ( $first_post ) {
- $test_url = get_permalink( $first_post->ID );
- }
-
- /*
- * Send a request to the site, and check whether
- * the 'x-pingback' header is returned as expected.
- *
- * Uses wp_remote_get() instead of wp_remote_head() because web servers
- * can block head requests.
- */
- $response = wp_remote_get( $test_url, array( 'timeout' => 5 ) );
- $x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' );
- $pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo( 'pingback_url' );
-
- if ( $pretty_permalinks ) {
- return true;
- }
- }
-
- /*
- * If it makes it this far, pretty permalinks failed.
- * Fallback to query-string permalinks.
- */
- $wp_rewrite->set_permalink_structure( '' );
- $wp_rewrite->flush_rules( true );
-
- return false;
-}
-
-if ( ! function_exists( 'wp_new_blog_notification' ) ) :
- /**
- * Notifies the site admin that the setup is complete.
- *
- * Sends an email with wp_mail to the new administrator that the site setup is complete,
- * and provides them with a record of their login credentials.
- *
- * @since 2.1.0
- *
- * @param string $blog_title Site title.
- * @param string $blog_url Site url.
- * @param int $user_id User ID.
- * @param string $password User's Password.
- */
- function wp_new_blog_notification( $blog_title, $blog_url, $user_id, $password ) {
- $user = new WP_User( $user_id );
- $email = $user->user_email;
- $name = $user->user_login;
- $login_url = wp_login_url();
-
- $message = sprintf(
- /* translators: New site notification email. 1: New site URL, 2: User login, 3: User password or password reset link, 4: Login URL. */
- __(
- 'Your new WordPress site has been successfully set up at:
-
-%1$s
-
-You can log in to the administrator account with the following information:
-
-Username: %2$s
-Password: %3$s
-Log in here: %4$s
-
-We hope you enjoy your new site. Thanks!
-
---The WordPress Team
-https://wordpress.org/
-'
- ),
- $blog_url,
- $name,
- $password,
- $login_url
- );
-
- wp_mail( $email, __( 'New WordPress Site' ), $message );
- }
-endif;
-
-if ( ! function_exists( 'wp_upgrade' ) ) :
- /**
- * Runs WordPress Upgrade functions.
- *
- * Upgrades the database if needed during a site update.
- *
- * @since 2.1.0
- *
- * @global int $wp_current_db_version The old (current) database version.
- * @global int $wp_db_version The new database version.
- * @global wpdb $wpdb WordPress database abstraction object.
- */
- function wp_upgrade() {
- global $wp_current_db_version, $wp_db_version, $wpdb;
-
- $wp_current_db_version = __get_option( 'db_version' );
-
- // We are up to date. Nothing to do.
- if ( $wp_db_version == $wp_current_db_version ) {
- return;
- }
-
- if ( ! is_blog_installed() ) {
- return;
- }
-
- wp_check_mysql_version();
- wp_cache_flush();
- pre_schema_upgrade();
- make_db_current_silent();
- upgrade_all();
- if ( is_multisite() && is_main_site() ) {
- upgrade_network();
- }
- wp_cache_flush();
-
- if ( is_multisite() ) {
- update_site_meta( get_current_blog_id(), 'db_version', $wp_db_version );
- update_site_meta( get_current_blog_id(), 'db_last_updated', microtime() );
- }
-
- /**
- * Fires after a site is fully upgraded.
- *
- * @since 3.9.0
- *
- * @param int $wp_db_version The new $wp_db_version.
- * @param int $wp_current_db_version The old (current) $wp_db_version.
- */
- do_action( 'wp_upgrade', $wp_db_version, $wp_current_db_version );
- }
-endif;
-
-/**
- * Functions to be called in installation and upgrade scripts.
- *
- * Contains conditional checks to determine which upgrade scripts to run,
- * based on database version and WP version being updated-to.
- *
- * @ignore
- * @since 1.0.1
- *
- * @global int $wp_current_db_version The old (current) database version.
- * @global int $wp_db_version The new database version.
- */
-function upgrade_all() {
- global $wp_current_db_version, $wp_db_version;
- $wp_current_db_version = __get_option( 'db_version' );
-
- // We are up to date. Nothing to do.
- if ( $wp_db_version == $wp_current_db_version ) {
- return;
- }
-
- // If the version is not set in the DB, try to guess the version.
- if ( empty( $wp_current_db_version ) ) {
- $wp_current_db_version = 0;
-
- // If the template option exists, we have 1.5.
- $template = __get_option( 'template' );
- if ( ! empty( $template ) ) {
- $wp_current_db_version = 2541;
- }
- }
-
- if ( $wp_current_db_version < 6039 ) {
- upgrade_230_options_table();
- }
-
- populate_options();
-
- if ( $wp_current_db_version < 2541 ) {
- upgrade_100();
- upgrade_101();
- upgrade_110();
- upgrade_130();
- }
-
- if ( $wp_current_db_version < 3308 ) {
- upgrade_160();
- }
-
- if ( $wp_current_db_version < 4772 ) {
- upgrade_210();
- }
-
- if ( $wp_current_db_version < 4351 ) {
- upgrade_old_slugs();
- }
-
- if ( $wp_current_db_version < 5539 ) {
- upgrade_230();
- }
-
- if ( $wp_current_db_version < 6124 ) {
- upgrade_230_old_tables();
- }
-
- if ( $wp_current_db_version < 7499 ) {
- upgrade_250();
- }
-
- if ( $wp_current_db_version < 7935 ) {
- upgrade_252();
- }
-
- if ( $wp_current_db_version < 8201 ) {
- upgrade_260();
- }
-
- if ( $wp_current_db_version < 8989 ) {
- upgrade_270();
- }
-
- if ( $wp_current_db_version < 10360 ) {
- upgrade_280();
- }
-
- if ( $wp_current_db_version < 11958 ) {
- upgrade_290();
- }
-
- if ( $wp_current_db_version < 15260 ) {
- upgrade_300();
- }
-
- if ( $wp_current_db_version < 19389 ) {
- upgrade_330();
- }
-
- if ( $wp_current_db_version < 20080 ) {
- upgrade_340();
- }
-
- if ( $wp_current_db_version < 22422 ) {
- upgrade_350();
- }
-
- if ( $wp_current_db_version < 25824 ) {
- upgrade_370();
- }
-
- if ( $wp_current_db_version < 26148 ) {
- upgrade_372();
- }
-
- if ( $wp_current_db_version < 26691 ) {
- upgrade_380();
- }
-
- if ( $wp_current_db_version < 29630 ) {
- upgrade_400();
- }
-
- if ( $wp_current_db_version < 33055 ) {
- upgrade_430();
- }
-
- if ( $wp_current_db_version < 33056 ) {
- upgrade_431();
- }
-
- if ( $wp_current_db_version < 35700 ) {
- upgrade_440();
- }
-
- if ( $wp_current_db_version < 36686 ) {
- upgrade_450();
- }
-
- if ( $wp_current_db_version < 37965 ) {
- upgrade_460();
- }
-
- if ( $wp_current_db_version < 44719 ) {
- upgrade_510();
- }
-
- if ( $wp_current_db_version < 45744 ) {
- upgrade_530();
- }
-
- maybe_disable_link_manager();
-
- maybe_disable_automattic_widgets();
-
- update_option( 'db_version', $wp_db_version );
- update_option( 'db_upgraded', true );
-}
-
-/**
- * Execute changes made in WordPress 1.0.
- *
- * @ignore
- * @since 1.0.0
- *
- * @global wpdb $wpdb WordPress database abstraction object.
- */
-function upgrade_100() {
- global $wpdb;
-
- // Get the title and ID of every post, post_name to check if it already has a value
- $posts = $wpdb->get_results( "SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''" );
- if ( $posts ) {
- foreach ( $posts as $post ) {
- if ( '' == $post->post_name ) {
- $newtitle = sanitize_title( $post->post_title );
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID ) );
- }
- }
- }
-
- $categories = $wpdb->get_results( "SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories" );
- foreach ( $categories as $category ) {
- if ( '' == $category->category_nicename ) {
- $newtitle = sanitize_title( $category->cat_name );
- $wpdb->update( $wpdb->categories, array( 'category_nicename' => $newtitle ), array( 'cat_ID' => $category->cat_ID ) );
- }
- }
-
- $sql = "UPDATE $wpdb->options
- SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
- WHERE option_name LIKE %s
- AND option_value LIKE %s";
- $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( 'links_rating_image' ) . '%', $wpdb->esc_like( 'wp-links/links-images/' ) . '%' ) );
-
- $done_ids = $wpdb->get_results( "SELECT DISTINCT post_id FROM $wpdb->post2cat" );
- if ( $done_ids ) :
- $done_posts = array();
- foreach ( $done_ids as $done_id ) :
- $done_posts[] = $done_id->post_id;
- endforeach;
- $catwhere = ' AND ID NOT IN (' . implode( ',', $done_posts ) . ')';
- else :
- $catwhere = '';
- endif;
-
- $allposts = $wpdb->get_results( "SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere" );
- if ( $allposts ) :
- foreach ( $allposts as $post ) {
- // Check to see if it's already been imported
- $cat = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category ) );
- if ( ! $cat && 0 != $post->post_category ) { // If there's no result
- $wpdb->insert(
- $wpdb->post2cat,
- array(
- 'post_id' => $post->ID,
- 'category_id' => $post->post_category,
- )
- );
- }
- }
- endif;
-}
-
-/**
- * Execute changes made in WordPress 1.0.1.
- *
- * @ignore
- * @since 1.0.1
- *
- * @global wpdb $wpdb WordPress database abstraction object.
- */
-function upgrade_101() {
- global $wpdb;
-
- // Clean up indices, add a few
- add_clean_index( $wpdb->posts, 'post_name' );
- add_clean_index( $wpdb->posts, 'post_status' );
- add_clean_index( $wpdb->categories, 'category_nicename' );
- add_clean_index( $wpdb->comments, 'comment_approved' );
- add_clean_index( $wpdb->comments, 'comment_post_ID' );
- add_clean_index( $wpdb->links, 'link_category' );
- add_clean_index( $wpdb->links, 'link_visible' );
-}
-
-/**
- * Execute changes made in WordPress 1.2.
- *
- * @ignore
- * @since 1.2.0
- *
- * @global wpdb $wpdb WordPress database abstraction object.
- */
-function upgrade_110() {
- global $wpdb;
-
- // Set user_nicename.
- $users = $wpdb->get_results( "SELECT ID, user_nickname, user_nicename FROM $wpdb->users" );
- foreach ( $users as $user ) {
- if ( '' == $user->user_nicename ) {
- $newname = sanitize_title( $user->user_nickname );
- $wpdb->update( $wpdb->users, array( 'user_nicename' => $newname ), array( 'ID' => $user->ID ) );
- }
- }
-
- $users = $wpdb->get_results( "SELECT ID, user_pass from $wpdb->users" );
- foreach ( $users as $row ) {
- if ( ! preg_match( '/^[A-Fa-f0-9]{32}$/', $row->user_pass ) ) {
- $wpdb->update( $wpdb->users, array( 'user_pass' => md5( $row->user_pass ) ), array( 'ID' => $row->ID ) );
- }
- }
-
- // Get the GMT offset, we'll use that later on
- $all_options = get_alloptions_110();
-
- $time_difference = $all_options->time_difference;
-
- $server_time = time() + gmdate( 'Z' );
- $weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS;
- $gmt_time = time();
-
- $diff_gmt_server = ( $gmt_time - $server_time ) / HOUR_IN_SECONDS;
- $diff_weblogger_server = ( $weblogger_time - $server_time ) / HOUR_IN_SECONDS;
- $diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server;
- $gmt_offset = -$diff_gmt_weblogger;
-
- // Add a gmt_offset option, with value $gmt_offset
- add_option( 'gmt_offset', $gmt_offset );
-
- // Check if we already set the GMT fields (if we did, then
- // MAX(post_date_gmt) can't be '0000-00-00 00:00:00'
- // <michel_v> I just slapped myself silly for not thinking about it earlier
- $got_gmt_fields = ! ( $wpdb->get_var( "SELECT MAX(post_date_gmt) FROM $wpdb->posts" ) == '0000-00-00 00:00:00' );
-
- if ( ! $got_gmt_fields ) {
-
- // Add or subtract time to all dates, to get GMT dates
- $add_hours = intval( $diff_gmt_weblogger );
- $add_minutes = intval( 60 * ( $diff_gmt_weblogger - $add_hours ) );
- $wpdb->query( "UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" );
- $wpdb->query( "UPDATE $wpdb->posts SET post_modified = post_date" );
- $wpdb->query( "UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'" );
- $wpdb->query( "UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" );
- $wpdb->query( "UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" );
- }
-
-}
-
-/**
- * Execute changes made in WordPress 1.5.
- *
- * @ignore
- * @since 1.5.0
- *
- * @global wpdb $wpdb WordPress database abstraction object.
- */
-function upgrade_130() {
- global $wpdb;
-
- // Remove extraneous backslashes.
- $posts = $wpdb->get_results( "SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts" );
- if ( $posts ) {
- foreach ( $posts as $post ) {
- $post_content = addslashes( deslash( $post->post_content ) );
- $post_title = addslashes( deslash( $post->post_title ) );
- $post_excerpt = addslashes( deslash( $post->post_excerpt ) );
- if ( empty( $post->guid ) ) {
- $guid = get_permalink( $post->ID );
- } else {
- $guid = $post->guid;
- }
-
- $wpdb->update( $wpdb->posts, compact( 'post_title', 'post_content', 'post_excerpt', 'guid' ), array( 'ID' => $post->ID ) );
-
- }
- }
-
- // Remove extraneous backslashes.
- $comments = $wpdb->get_results( "SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments" );
- if ( $comments ) {
- foreach ( $comments as $comment ) {
- $comment_content = deslash( $comment->comment_content );
- $comment_author = deslash( $comment->comment_author );
-
- $wpdb->update( $wpdb->comments, compact( 'comment_content', 'comment_author' ), array( 'comment_ID' => $comment->comment_ID ) );
- }
- }
-
- // Remove extraneous backslashes.
- $links = $wpdb->get_results( "SELECT link_id, link_name, link_description FROM $wpdb->links" );
- if ( $links ) {
- foreach ( $links as $link ) {
- $link_name = deslash( $link->link_name );
- $link_description = deslash( $link->link_description );
-
- $wpdb->update( $wpdb->links, compact( 'link_name', 'link_description' ), array( 'link_id' => $link->link_id ) );
- }
- }
-
- $active_plugins = __get_option( 'active_plugins' );
-
- /*
- * If plugins are not stored in an array, they're stored in the old
- * newline separated format. Convert to new format.
- */
- if ( ! is_array( $active_plugins ) ) {
- $active_plugins = explode( "\n", trim( $active_plugins ) );
- update_option( 'active_plugins', $active_plugins );
- }
-
- // Obsolete tables
- $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues' );
- $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes' );
- $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups' );
- $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options' );
-
- // Update comments table to use comment_type
- $wpdb->query( "UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'" );
- $wpdb->query( "UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'" );
-
- // Some versions have multiple duplicate option_name rows with the same values
- $options = $wpdb->get_results( "SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name" );
- foreach ( $options as $option ) {
- if ( 1 != $option->dupes ) { // Could this be done in the query?
- $limit = $option->dupes - 1;
- $dupe_ids = $wpdb->get_col( $wpdb->prepare( "SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit ) );
- if ( $dupe_ids ) {
- $dupe_ids = join( ',', $dupe_ids );
- $wpdb->query( "DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)" );
- }
- }
- }
-
- make_site_theme();
-}
-
-/**
- * Execute changes made in WordPress 2.0.
- *
- * @ignore
- * @since 2.0.0
- *
- * @global wpdb $wpdb WordPress database abstraction object.
<