#51288 closed defect (bug) (fixed)
Drop deprecated database column upon upgrade
Reported by: | leogermani | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Database | Keywords: | has-patch has-dev-note |
Focuses: | Cc: |
Description (last modified by )
I just stumbled upon some issues with (very) old blogs that still have the post_category column in the posts table.
After this column was removed 11 years ago in [10895] / #9435, we never handled their removals on db upgrades.
This is an issue because we have a magic getter in WP_Post class that will fill the non existent post_category property. However, if the column exists in the database, the magic getter isn't triggered and we get 0 every time. So I think we can consider this a bug.
Link to the magic getter -> https://github.com/WordPress/wordpress-develop/blob/master/src/wp-includes/class-wp-post.php#L311
Change History (13)
This ticket was mentioned in PR #526 on WordPress/wordpress-develop by leogermani.
4 years ago
#1
- Keywords has-patch added; needs-patch removed
This ticket was mentioned in Slack in #core-php by leogermani. View the logs.
4 years ago
#3
@
4 years ago
Test Instructions:
Alter your local database and add a post_category
column to the wp_posts
table.
Apply this patch.
Reload admin.
- you should get a notice to Upgrade the DB
- Click Upgrade
- Check your database and verify the column was dropped.
Second test: Test if no errors are triggered if column not present.
Restore your current db version to force a new upgrade:
wp option set db_version 51287
- Visit the dashboard again
- You should see the Upgrade notice
- Upgrade
- Make sure there were no errors or warnings
#5
@
4 years ago
- Milestone changed from Awaiting Review to 5.6
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
#6
@
4 years ago
Tested the most recent patch with the instructions in comment #3 and it works as expected.
This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.
4 years ago
#8
@
4 years ago
- Keywords needs-refresh added
Per scrub today, this ticket needs a refresh and update to the DB version.
#11
@
4 years ago
- Keywords needs-dev-note added
Let's mention this in the miscellaneous developer note.
hellofromtonya commented on PR #526:
4 years ago
#12
Merged in changeset https://core.trac.wordpress.org/changeset/49572
Adds an upgrade routine to drop the
post_category
column from thewp_posts
table.This column was dropped 11 years ago from the schema but never handled by an upgrade routine. Its presence may conflict with the magic getter in
WP_Post
class that populates the contents if you try to directly access thepost_category
object attribute.Trac ticket: https://core.trac.wordpress.org/ticket/51288