Skip to content

Conversation

rodrigoprimo
Copy link
Collaborator

Description

Before this change, the sniff was not properly differentiating between fully qualified calls to global WP cache functions and namespaced calls to non-WP functions with the same name as the WP functions.

In other words, the sniff was correctly identifying \wp_cache_get() as a WP cache function, but it was incorrectly identifying MyNamespace\wp_cache_get() as a WP cache function as well. This PR fixes this issue.

Suggested changelog entry

Fixed: WordPress.DB.DirectDatabaseQuery: handling of calls to namespaced non-global functions with the same name as WP cache functions.

…ctions

Before this change, the sniff was not properly differentiating between fully qualified calls to global WP cache functions and namespaced calls to non-WP functions with the same name as the WP functions.

In other words, the sniff was correctly identifying `\wp_cache_get()` as a WP cache function, but it was incorrectly identifying `MyNamespace\wp_cache_get()` as a WP cache function. This commit fixes this issue.
@jrfnl
Copy link
Member

jrfnl commented Sep 18, 2025

Hmm... so as per #2615:

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.

... we are ignoring method calls if they mirror the WP native functions, but now this PR will start flagging namespaced function calls which mirror the WP native functions ?

That sounds very inconsistent to me.

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.

2 participants