We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using a transient for caching a direct database call is not deemed acceptable but I believe it should be:
When using an external object cache, get_transient() is short-circuited to use wp_cache_get().
get_transient()
wp_cache_get()
When not using an external object cache, it falls back to use get_option() (after ensuring that all options were loaded). And then get_option() either uses a hash lookup in all options, or wp_cache_get().
get_option()
Thanks @apermo for the pointer and encouragement to file this!
The issue happens when running this command:
./vendor/bin/phpcs -s --standard=WordPress transient.php
... over a file containing this code:
if ( ! get_transient( 'time' ) ) { $wpdb->get_var( 'SELECT current_time()' ); }
WordPress.DB.DirectDatabaseQuery.NoCaching
dev-develop 29488fe
develop
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug Description
Using a transient for caching a direct database call is not deemed acceptable but I believe it should be:
When using an external object cache,
get_transient()
is short-circuited to usewp_cache_get()
.When not using an external object cache, it falls back to use
get_option()
(after ensuring that all options were loaded). And thenget_option()
either uses a hash lookup in all options, orwp_cache_get()
.Thanks @apermo for the pointer and encouragement to file this!
Minimal Code Snippet
The issue happens when running this command:
... over a file containing this code:
Error Code
WordPress.DB.DirectDatabaseQuery.NoCaching
Environment
dev-develop 29488fe
)Tested Against
develop
Branch?develop
branch of WordPressCS.The text was updated successfully, but these errors were encountered: