#56386 closed enhancement (fixed)
Remove `@access private` from cache priming functions.
Reported by: | peterwilsoncc | Owned by: | peterwilsoncc |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Cache API | Keywords: | good-first-bug has-patch needs-dev-note |
Focuses: | performance | Cc: |
Description
WordPress includes and makes heavy use of several functions for priming object caches. These functions reduce the number of database calls by querying the database for these objects in bulk.
With the benefit of hindsight, I can't see why these functions are marked private. Furthermore, I think plugins should be actively encouraged to use them..
I suggest the @access private
delegation be removed from the following functions:
_prime_post_caches()
_prime_term_caches()
_prime_comment_caches()
_prime_network_caches()
_prime_site_caches()
_get_non_cached_ids()
Change History (11)
#2
@
2 years ago
A precedent I found in [46602] for #48251 retained the underscore prefix while removing the private delegation.
In the previous ticket, the functions in question appeared 13249 times in the plugin repo. In this case the functions in question appear 237 times in the plugin plugin repo. The most frequently used being post priming in some 5M+ installed plugins.
I can be convinced either way but worry deprecating the functions would create a lot of noise in logs to avoid a precedent that has already been set.
#3
@
2 years ago
Good point, if we haven't dropped the underscore from _doing_it_wrong()
, _deprecated_function()
, seems OK to keep it here too.
I suppose we could also introduce non-underscored aliases like prime_post_caches()
or wp_prime_post_caches()
, but I'm not sure if there's a strong reason for that at this time, so keeping the current names would be my preference.
This ticket was mentioned in PR #3134 on WordPress/wordpress-develop by robinwpdeveloper.
2 years ago
#4
- Keywords has-patch added; needs-patch removed
Removed @access private from below functions (as per ticket description):
_prime_post_caches()
_prime_term_caches()
_prime_comment_caches()
_prime_network_caches()
_prime_site_caches()
_get_non_cached_ids()
Trac ticket: 56386
robinwpdeveloper commented on PR #3134:
2 years ago
#5
@costdev Changes are pushed as per suggestion
#6
@
2 years ago
- Milestone changed from Awaiting Review to 6.1
- Owner set to peterwilsoncc
- Status changed from new to assigned
The PR got enough approval.
Assign to Peter for final review.
#7
@
2 years ago
Agreed that there's no strong reason for deprecating, and that it would potentially cause a lot of noise needlessly. If this was something that was done more often and we documented this practice more openly, I'd feel a bit stronger towards renaming/deprecating for consistency.
Keeping the names as is sounds good 👍🏼
peterwilsoncc commented on PR #3134:
2 years ago
#9
Merged in https://core.trac.wordpress.org/changeset/53944 / 541b4eb6462c8f48e235590a9be79ebc4954f66e
I can't find it in the handbook at the moment, but I believe the idea with the preceding
_
underscore was for developers to easily know when a function should be considered private.If we're removing
@access private
from these, would it make sense to deprecate the current functions in favor ofprime_post_caches()
,prime_term_caches()
, etc.?