Skip to content

Conversation

@rodrigoprimo
Copy link
Collaborator

Description

Before, the sniff was checking if the content of a T_STRING token matched one of the names of the expected cache functions without checking if it was actually a function call. This could lead to some false negatives that are addressed in this commit.

As suggested by Juliette, I'm including a test to document that method names that match the cache function names are deliberately not flagged by this sniff, as they will be most likely valid custom cache functions.

Suggested changelog entry

Fixed: WordPress.DB.DirectDatabaseQuery: prevents false negatives when cache function names are not a function call.

… are not a function call

Before, the sniff was checking if the content of a `T_STRING` token matched one of the names of the expected cache functions without checking if it was actually a function call. This could lead to some false negatives that are addressed in this commit.

As suggested by Juliette, I'm including a test to document that method names that match the cache function names are deliberately not flagged by this sniff as they will be most likely valid custom cache functions.
Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks @rodrigoprimo !

@jrfnl jrfnl added this to the 3.3.0 milestone Sep 16, 2025
@dingo-d dingo-d merged commit 2e98985 into WordPress:develop Sep 17, 2025
29 checks passed
@rodrigoprimo rodrigoprimo deleted the direct-database-query-fix-false-positive branch September 18, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants