Make WordPress Core

Opened 10 months ago

Closed 8 months ago

Last modified 8 weeks ago

#63014 closed enhancement (fixed)

Enhance `_wp_after_delete_font_family()` performance using the `fields` argument in `get_children()`.

Reported by: dilipbheda's profile dilipbheda Owned by: flixos90's profile flixos90
Milestone: 6.9 Priority: low
Severity: normal Version:
Component: Query Keywords: has-patch
Focuses: performance Cc:

Description

The _wp_after_delete_font_family() function can be optimized by leveraging the fields argument in the get_children() function. Currently, the function retrieves unnecessary data, which affects performance.

Since we use only the ID field in the wp_delete_post() function from the get_children() object, adding the fields argument will limit the query to fetch only the required IDs, improving both performance and efficiency.

Change History (4)

This ticket was mentioned in PR #8407 on WordPress/wordpress-develop by @dilipbheda.


10 months ago
#1

#2 @flixos90
8 months ago

  • Milestone changed from Awaiting Review to 6.9
  • Owner set to flixos90
  • Priority changed from normal to low
  • Status changed from new to reviewing
  • Type changed from defect (bug) to enhancement

@dilipbheda Thanks for raising this, the change makes sense to me.

I wasn't sure at first because wp_delete_post() looks up the post object anyway before deleting, so I thought looking it up in the query would be good to warm the caches.

But turns out that wp_delete_post() will always make a database request for it regardless of caches, so the extra query before to warm the caches is indeed pointless.

It's probably not going to have a notable impact on performance, but should be straightforward and low-risk enough to move forward.

Changing this to an enhancement, since it's a performance improvement, not a bug fix.

#3 @flixos90
8 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 60203:

Query: Avoid unnecessary database query when deleting a font family.

Querying only the font face IDs is sufficient when deleting a font family. There is no need to warm the caches with the full objects, since wp_delete_post() will always make a direct database query to get the object anyway.

Props dilipbheda.
Fixes #63014.

This ticket was mentioned in Slack in #core by westonruter. View the logs.


8 weeks ago

Note: See TracTickets for help on using tickets.