Make WordPress Core

Opened 6 years ago

Closed 11 days ago

#46180 closed enhancement (wontfix)

get_permalink: Ability to pass required information for better performance

Reported by: alduinwf's profile alduinwf Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Permalinks Keywords:
Focuses: performance Cc:

Description

Hi,

somewhat related to this ticket:
https://core.trac.wordpress.org/ticket/46179

I have another proposal.

get_permalink accepts a post object or an ID to create a permalink. If you only pass the ID, the function will get all post information from the database and generate the permalink. However, this might not be necessary every time. Look at the use-case in 46179, when I already have loads of information. For example, when my permalink structure is /%Y/%M/%TITLE%/, I can easily get all information I need from the one query.

So my proposal is that you can not only pass an ID or a WP_Post object to get_permalink but also an array with all available information (from the database). And if the information provided is sufficient to create the permalink, then use it, otherwise fall back to get_post($id).

This won't save "much" time and not even crazy much memory but it takes off a lot of load from the database when you have to not use the API for some reason and this could be interesting in a high-load environment.

Thank you,

-alduin

Change History (2)

This ticket was mentioned in Slack in #core-performance by swissspidy. View the logs.


11 days ago

#2 @swissspidy
11 days ago

  • Focuses template removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Apologies that it took so long for someone to respond to this ticket.

Given the negligible impact this would have (especially with all the object caching etc. in place) and the limited use case, I am inclined to close this as wontfix.

Note: See TracTickets for help on using tickets.