Documentation

DirectDatabaseQuerySniff extends Sniff

FinalYes

Flag Database direct queries.

Tags
link
https://vip.wordpress.com/documentation/vip-go/code-review-blockers-warnings-notices/#direct-database-queries
since
0.3.0
since
0.6.0

Removed the add_unique_message() function as it is no longer needed.

since
0.11.0

This class now extends the WordPressCS native Sniff class.

since
0.13.0

Class name changed: this class is now namespaced.

since
1.0.0

This sniff has been moved from the VIP category to the DB category.

since
3.0.0

Support for the very sniff specific WPCS native ignore comment syntax has been removed.

Table of Contents

Properties

$customCacheDeleteFunctions  : array<string|int, string>
List of custom cache delete functions.
$customCacheGetFunctions  : array<string|int, string>
List of custom cache get functions.
$customCacheSetFunctions  : array<string|int, string>
List of custom cache set functions.
$addedCustomFunctions  : array<string|int, mixed>
Cache of previously added custom functions.
$cacheDeleteFunctions  : array<string|int, mixed>
A list of functions that delete data from the cache.
$cacheGetFunctions  : array<string|int, mixed>
A list of functions that get data from the cache.
$cacheSetFunctions  : array<string|int, mixed>
A list of functions that set data in the cache.
$methods  : array<string|int, array<string|int, mixed>>
The lists of $wpdb methods.
$phpcsFile  : File
The current file being sniffed.
$tokens  : array<string|int, mixed>
The list of tokens in the current file being sniffed.

Methods

process()  : int|void
Set sniff properties and hand off to child class for processing of the token.
process_token()  : int|void
Processes this test, when one of its tokens is encountered.
register()  : array<string|int, mixed>
Returns an array of tokens this test wants to listen for.
mergeFunctionLists()  : void
Merge custom functions provided via a custom ruleset with the defaults, if we haven't already.

Properties

$customCacheDeleteFunctions

List of custom cache delete functions.

public array<string|int, string> $customCacheDeleteFunctions = array()
Tags
since
0.6.0

$customCacheGetFunctions

List of custom cache get functions.

public array<string|int, string> $customCacheGetFunctions = array()
Tags
since
0.6.0

$customCacheSetFunctions

List of custom cache set functions.

public array<string|int, string> $customCacheSetFunctions = array()
Tags
since
0.6.0

$addedCustomFunctions

Cache of previously added custom functions.

protected array<string|int, mixed> $addedCustomFunctions = array('cacheget' => array(), 'cacheset' => array(), 'cachedelete' => array())

Prevents having to do the same merges over and over again.

Tags
since
0.11.0

$cacheDeleteFunctions

A list of functions that delete data from the cache.

protected array<string|int, mixed> $cacheDeleteFunctions = array('wp_cache_delete' => true, 'clean_attachment_cache' => true, 'clean_blog_cache' => true, 'clean_bookmark_cache' => true, 'clean_category_cache' => true, 'clean_comment_cache' => true, 'clean_network_cache' => true, 'clean_object_term_cache' => true, 'clean_page_cache' => true, 'clean_post_cache' => true, 'clean_term_cache' => true, 'clean_user_cache' => true)
Tags
since
0.6.0
since
0.11.0

Changed from public static to protected non-static.

since
3.0.0

Moved from the generic Sniff class to this class.

$cacheGetFunctions

A list of functions that get data from the cache.

protected array<string|int, mixed> $cacheGetFunctions = array('wp_cache_get' => true)
Tags
since
0.6.0
since
0.11.0

Changed from public static to protected non-static.

since
3.0.0

Moved from the generic Sniff class to this class.

$cacheSetFunctions

A list of functions that set data in the cache.

protected array<string|int, mixed> $cacheSetFunctions = array('wp_cache_set' => true, 'wp_cache_add' => true)
Tags
since
0.6.0
since
0.11.0

Changed from public static to protected non-static.

since
3.0.0

Moved from the generic Sniff class to this class.

$methods

The lists of $wpdb methods.

protected array<string|int, array<string|int, mixed>> $methods = array('cachable' => array('delete' => true, 'get_var' => true, 'get_col' => true, 'get_row' => true, 'get_results' => true, 'query' => true, 'replace' => true, 'update' => true), 'noncachable' => array('insert' => true))
Tags
since
0.6.0
since
0.11.0

Changed from static to non-static.

$phpcsFile

The current file being sniffed.

protected File $phpcsFile
Tags
since
0.4.0

$tokens

The list of tokens in the current file being sniffed.

protected array<string|int, mixed> $tokens
Tags
since
0.4.0

Methods

process()

Set sniff properties and hand off to child class for processing of the token.

public process(File $phpcsFile, int $stackPtr) : int|void
Parameters
$phpcsFile : File

The file being scanned.

$stackPtr : int

The position of the current token in the stack passed in $tokens.

Tags
since
0.11.0
Return values
int|void

Integer stack pointer to skip forward or void to continue normal file processing.

process_token()

Processes this test, when one of its tokens is encountered.

public process_token(int $stackPtr) : int|void
Parameters
$stackPtr : int

The position of the current token in the stack.

Return values
int|void

Integer stack pointer to skip forward or void to continue normal file processing.

register()

Returns an array of tokens this test wants to listen for.

public register() : array<string|int, mixed>
Return values
array<string|int, mixed>

mergeFunctionLists()

Merge custom functions provided via a custom ruleset with the defaults, if we haven't already.

protected mergeFunctionLists() : void
Tags
since
0.11.0

Split out from the process() method.


        
On this page

Search results