Fix bug in WordPress_Sniffs_VIP_DirectDatabaseQuerySniff #786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
WordPress.VIP.DirectDatabaseQuery
sniff allows for adding custom database query caching functions to the predefined lists of known WP core database query caching functions.The known WP core database query caching functions are contained in static variables in the
WordPress_Sniff
base class and are currently only used by theWordPress.VIP.DirectDatabaseQuery
sniff.Up to now, if custom functions were passed to this sniff, it would merge them with the lists of WP core functions and then overwrite the values of the static properties in the
WordPress_Sniff
base class.While no other sniff is using these properties, this is not much of a problem (yet), but as soon as another sniff would start using these properties, this behaviour would have the unintended side-effect of affecting the other sniff as well. Even worse, whether this side-effect would come into play might be unpredictable as it would depend on the running order of the sniffs which can change without notice.
To fix this, I have introduced three new private properties to the
WordPress.VIP.DirectDatabaseQuery
sniff which will hold the merged versions of the function lists.I've also moved the setting of these properties to a dedicated function.
Related to #614