[wp-trac] [WordPress Trac] #46180: get_permalink: Ability to pass required information for better performance
WordPress Trac
noreply at wordpress.org
Mon Feb 4 09:47:46 UTC 2019
#46180: get_permalink: Ability to pass required information for better performance
-----------------------------------+-----------------------------
Reporter: alduinwf | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Permalinks | Version:
Severity: normal | Keywords:
Focuses: template, performance |
-----------------------------------+-----------------------------
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
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46180>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list