Make WordPress Core

Opened 6 years ago

#46180 new enhancement

get_permalink: Ability to pass required information for better performance

Reported by: alduinwf's profile alduinwf Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Permalinks Keywords:
Focuses: template, 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 (0)

Note: See TracTickets for help on using tickets.