WordPress.org

Make WordPress Core

Opened 14 months ago

Last modified 14 months ago

#38132 new feature request

Remove orphaned postmeta

Reported by: lukecavanagh Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Options, Meta APIs Keywords:
Focuses: Cc:

Description

It seems like a feature to remove orphaned postmeta on a site should be something that is built into core.

I know you can remove orphaned postmeta by MySQL query or plugin, but this does seem like something that should be built into core.

WooCommerce has a similar function to removed expired session data from the options table built into core.

Change History (4)

#1 @jorbin
14 months ago

@lukecavanagh Can you clarify what you mean by 'orphaned' post meta. Do you mean post meta that is not registered by register_meta? Do you mean no longer used post meta? Do you post meta related to posts that have been deleted? Something completely different?

#2 follow-up: @lukecavanagh
14 months ago

@jorbin

This is more postmeta that is no longer being used, as well as post meta that was not removed when posts where deleted. But that post meta is still being stored in the postmeta db table.

#3 @SergeyBiryukov
14 months ago

  • Component changed from General to Options, Meta APIs

#4 in reply to: ↑ 2 @SergeyBiryukov
14 months ago

Replying to lukecavanagh:

This is more postmeta that is no longer being used

Is there a reliable way to determine that it's no longer being used?

as well as post meta that was not removed when posts where deleted.

wp_delete_post() does remove the associated post meta. If someone is deleting posts via direct SQL queries instead of using the WordPress API, seems like they should be responsible for cleaning up post meta as well.

Note: See TracTickets for help on using tickets.