Skip to content

DB/DirectDatabaseQuery: fix false negatives when cache function names are not a function call#2615

Merged
dingo-d merged 1 commit into
WordPress:developfrom
rodrigoprimo:direct-database-query-fix-false-positive
Sep 17, 2025
Merged

DB/DirectDatabaseQuery: fix false negatives when cache function names are not a function call#2615
dingo-d merged 1 commit into
WordPress:developfrom
rodrigoprimo:direct-database-query-fix-false-positive

Conversation

@rodrigoprimo

Copy link
Copy Markdown
Contributor

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.

@jrfnl jrfnl left a comment

Copy link
Copy Markdown
Member

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