From 5f5c04d46b42cc03d44f0221f8492e58406909e7 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 12 Nov 2020 17:53:41 +0000 Subject: [PATCH] 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 --- src/wp-admin/includes/upgrade.php | 21 +++++++++++++++++++++ src/wp-includes/version.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index f68ee0b9ff..3342c76b65 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -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. * diff --git a/src/wp-includes/version.php b/src/wp-includes/version.php index 8927add0f4..ae03cf28ec 100644 --- a/src/wp-includes/version.php +++ b/src/wp-includes/version.php @@ -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.