Skip to content

Commit

Permalink
Extract the lowercased content for the caching functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dingo-d committed Sep 18, 2023
1 parent d6ac1b5 commit 976c1c5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions WordPress/Sniffs/DB/DirectDatabaseQuerySniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,19 @@ public function process_token( $stackPtr ) {

for ( $i = ( $scopeStart + 1 ); $i < $scopeEnd; $i++ ) {
if ( \T_STRING === $this->tokens[ $i ]['code'] ) {
$content = strtolower( $this->tokens[ $i ]['content'] );

if ( isset( $this->cacheDeleteFunctions[ strtolower( $this->tokens[ $i ]['content'] ) ] ) ) {
if ( isset( $this->cacheDeleteFunctions[ $content ] ) ) {

if ( \in_array( $method, array( 'query', 'update', 'replace', 'delete' ), true ) ) {
$cached = true;
break;
}
} elseif ( isset( $this->cacheGetFunctions[ strtolower( $this->tokens[ $i ]['content'] ) ] ) ) {
} elseif ( isset( $this->cacheGetFunctions[ $content ] ) ) {

$wp_cache_get = true;

} elseif ( isset( $this->cacheSetFunctions[ strtolower( $this->tokens[ $i ]['content'] ) ] ) ) {
} elseif ( isset( $this->cacheSetFunctions[ $content ] ) ) {

if ( $wp_cache_get ) {
$cached = true;
Expand Down

0 comments on commit 976c1c5

Please sign in to comment.