WordPress.org

Make WordPress Core

Opened 8 days ago

Last modified 19 hours ago

#48014 accepted defect (bug)

Multiple _encloseme entries in postmeta table when disabling pings

Reported by: rebasaurus Owned by: whyisjake
Milestone: 5.3 Priority: normal
Severity: normal Version: trunk
Component: Pings/Trackbacks Keywords: has-patch needs-unit-tests
Focuses: performance Cc:

Description

When we disable pings, this can lead to potentially hundreds of thousands rows accumulating with the _encloseme key on the postmeta table (as it is fired on every publish_post hook: https://github.com/WordPress/WordPress/blob/71cf332e6569f0ac2f263ce9b2168644942f5534/wp-includes/post.php#L6580) and therefore, cause performance issues on simple meta queries that are normally run on pageload:

SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (x) ORDER BY meta_id ASC

This is because the cleanup function do_all_pings() does not run anymore on the do_pings hook: https://github.com/WordPress/WordPress/blob/1e925a5ae3faccad31c48c810af3954d01a60f0e/wp-includes/comment.php#L2626

Attachments (1)

48014.diff (569 bytes) - added by rebasaurus 8 days ago.
We can utilize the 4th parameter of add_post_meta() to prevent duplicate entries.

Download all attachments as: .zip

Change History (7)

@rebasaurus
8 days ago

We can utilize the 4th parameter of add_post_meta() to prevent duplicate entries.

#1 @whyisjake
8 days ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to whyisjake
  • Status changed from new to accepted

#2 @whyisjake
8 days ago

  • Keywords has-patch added
  • Version changed from 5.2.3 to trunk

#3 @whyisjake
7 days ago

  • Keywords needs-unit-tests added

#4 @whyisjake
7 days ago

@rebasaurus,

Thanks for contributing this issue, and the associated patch. To get this included in 5.3, we should look at adding some unit tests, and maybe a cleanup routine during the upgrade.

#5 @whyisjake
7 days ago

Chatting with @jorbin, cleanup could be part of the upgrade routine or maybe a standalone plugin.

#6 @whyisjake
19 hours ago

  • Type changed from enhancement to defect (bug)
Note: See TracTickets for help on using tickets.