Make WordPress Core


Ignore:
Timestamp:
11/12/2020 05:53:41 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Database: Clean up the post_category column removed from DB schema for new installations in WordPress 2.8.

Its presence may conflict with WP_Post::__get(), which should generally fill the non-existent post_category property, but is not triggered if the column exists in the database.

Follow-up to [10895].

Props leogermani, davidbaumwald, hellofromTonya.
Fixes #51288.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/upgrade.php

    r49193 r49572  
    875875        }
    876876
     877        if ( $wp_current_db_version < 49572 ) {
     878                upgrade_560();
     879        }
     880
    877881        maybe_disable_link_manager();
    878882
    … …  
    22382242
    22392243/**
     2244 * Executes changes made in WordPress 5.6.0.
     2245 *
     2246 * @ignore
     2247 * @since 5.6.0
     2248 */
     2249function upgrade_560() {
     2250        global $wpdb;
     2251
     2252        // Clean up the `post_category` column removed from schema in version 2.8.0.
     2253        // Its presence may conflict with WP_Post::__get().
     2254        $post_category_exists = $wpdb->get_var( "SHOW COLUMNS FROM $wpdb->posts LIKE 'post_category'" );
     2255        if ( ! is_null( $post_category_exists ) ) {
     2256                $wpdb->query( "ALTER TABLE $wpdb->posts DROP COLUMN `post_category`" );
     2257        }
     2258}
     2259
     2260/**
    22402261 * Executes network-level upgrade routines.
    22412262 *
Note: See TracChangeset for help on using the changeset viewer.