WordPress.org

Make WordPress Core

Ticket #43893: 43893.diff

File 43893.diff, 2.0 KB (added by valchovski, 15 months ago)
  • src/wp-admin/includes/upgrade.php

    diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php
    index 3b2d62da7c..da1816b96c 100644
    a b function upgrade_network() { 
    22922292/**
    22932293 * Creates a table in the database if it doesn't already exist.
    22942294 *
    2295  * This method checks for an existing database and creates a new one if it's not
     2295 * This method checks for an existing table in the database and creates a new one if it's not
    22962296 * already present. It doesn't rely on MySQL's "IF NOT EXISTS" statement, but chooses
    22972297 * to query all tables first and then run the SQL statement creating the table.
    22982298 *
  • src/wp-admin/install-helper.php

    diff --git a/src/wp-admin/install-helper.php b/src/wp-admin/install-helper.php
    index c13f302784..c42f9e68bf 100644
    a b  
    3737/** Load WordPress Bootstrap */
    3838require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
    3939
    40 if ( ! function_exists( 'maybe_create_table' ) ) :
    41         /**
    42          * Create database table, if it doesn't already exist.
    43          *
    44          * @since 1.0.0
    45          *
    46          * @global wpdb $wpdb WordPress database abstraction object.
    47          *
    48          * @param string $table_name Database table name.
    49          * @param string $create_ddl Create database table SQL.
    50          * @return bool False on error, true if already exists or success.
    51          */
    52         function maybe_create_table( $table_name, $create_ddl ) {
    53                 global $wpdb;
    54                 foreach ( $wpdb->get_col( 'SHOW TABLES', 0 ) as $table ) {
    55                         if ( $table == $table_name ) {
    56                                 return true;
    57                         }
    58                 }
    59                 // Didn't find it, so try to create it.
    60                 $wpdb->query( $create_ddl );
    61 
    62                 // We cannot directly tell that whether this succeeded!
    63                 foreach ( $wpdb->get_col( 'SHOW TABLES', 0 ) as $table ) {
    64                         if ( $table == $table_name ) {
    65                                 return true;
    66                         }
    67                 }
    68                 return false;
    69         }
    70 endif;
    71 
    7240if ( ! function_exists( 'maybe_add_column' ) ) :
    7341        /**
    7442         * Add column to database table, if column doesn't already exist in table.