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.

git-svn-id: https://develop.svn.wordpress.org/trunk@49572 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-11-12 17:53:41 +00:00
parent 9befeb00cc
commit 5f5c04d46b
2 changed files with 22 additions and 1 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

@@ -20,7 +20,7 @@ $wp_version = '5.6-beta3-49486-src';
*
* @global int $wp_db_version
*/
$wp_db_version = 49534;
$wp_db_version = 49572;
/**
* Holds the TinyMCE version.