Make WordPress Core

Ticket #49654: 49654.patch

File 49654.patch, 1.2 KB (added by esoj, 4 years ago)

Made a quick patch. however untested at the moment

  • wp-admin/includes/upgrade.php

     
    23612361}
    23622362
    23632363/**
     2364 * Drops a table in the database if it does exist.
     2365 *
     2366 * This method checks for an existing table and drops it if it exist.
     2367 * It doesn't rely on MySQL's "IF NOT EXISTS" statement, but chooses
     2368 * to query all tables first and then run the SQL statement deleting the table.
     2369 *
     2370 * @since 5.5.0
     2371 *
     2372 * @global wpdb $wpdb WordPress database abstraction object.
     2373 *
     2374 * @param string $table_name Database table name to drop.
     2375 * @return bool If table already doesn't exist or was droped by function.
     2376 */
     2377function maybe_drop_table( $table_name ) {
     2378        global $wpdb;
     2379
     2380        $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );
     2381
     2382        if !( $wpdb->get_var( $query ) == $table_name ) {
     2383                return true;
     2384        }
     2385
     2386        // Did find it, so try to drop it.
     2387        $wpdb->query( 'DROP TABLE ' . $table_name );
     2388
     2389        // We cannot directly tell that whether this succeeded!
     2390        if !( $wpdb->get_var( $query ) == $table_name ) {
     2391                return true;
     2392        }
     2393        return false;
     2394}
     2395
     2396/**
    23642397 * Drops a specified index from a table.
    23652398 *
    23662399 * @since 1.0.1