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.
Built from https://develop.svn.wordpress.org/trunk@49572


git-svn-id: http://core.svn.wordpress.org/trunk@49310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-11-12 17:55:11 +00:00
parent 250d0660b2
commit d772517fcc
2 changed files with 23 additions and 2 deletions

View File

@ -874,6 +874,10 @@ function upgrade_all() {
upgrade_550();
}
if ( $wp_current_db_version < 49572 ) {
upgrade_560();
}
maybe_disable_link_manager();
maybe_disable_automattic_widgets();
@ -2236,6 +2240,23 @@ function upgrade_550() {
}
}
/**
* Executes changes made in WordPress 5.6.0.
*
* @ignore
* @since 5.6.0
*/
function upgrade_560() {
global $wpdb;
// Clean up the `post_category` column removed from schema in version 2.8.0.
// Its presence may conflict with WP_Post::__get().
$post_category_exists = $wpdb->get_var( "SHOW COLUMNS FROM $wpdb->posts LIKE 'post_category'" );
if ( ! is_null( $post_category_exists ) ) {
$wpdb->query( "ALTER TABLE $wpdb->posts DROP COLUMN `post_category`" );
}
}
/**
* Executes network-level upgrade routines.
*

View File

@ -13,14 +13,14 @@
*
* @global string $wp_version
*/
$wp_version = '5.6-beta3-49571';
$wp_version = '5.6-beta3-49572';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
*
* @global int $wp_db_version
*/
$wp_db_version = 49534;
$wp_db_version = 49572;
/**
* Holds the TinyMCE version.