From d772517fcc6d3038e93f40ecfe2c86161cd7e348 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 12 Nov 2020 17:55:11 +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. Built from https://develop.svn.wordpress.org/trunk@49572 git-svn-id: http://core.svn.wordpress.org/trunk@49310 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/upgrade.php | 21 +++++++++++++++++++++ wp-includes/version.php | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index f68ee0b9ff..3342c76b65 100644 --- a/wp-admin/includes/upgrade.php +++ b/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/wp-includes/version.php b/wp-includes/version.php index d9b2f981e0..3e184164da 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.