Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review all direct database queries #50

Closed
jrfnl opened this issue Aug 1, 2019 · 0 comments · Fixed by #105
Closed

Review all direct database queries #50

jrfnl opened this issue Aug 1, 2019 · 0 comments · Fixed by #105

Comments

@jrfnl
Copy link
Contributor

jrfnl commented Aug 1, 2019

There three queries used within the Comment Hacks plugin which:
a) make direct database calls instead of using any of the various DB call abstraction functions offered by WP.
b) are not caching the results

Recommended reading for potential refactoring:

If after careful reviewing it is determined for any of these queries that they really REALLY are ok the way they are and should not be cached or changed to use a WP DB abstractions, that particular query can be whitelisted using the following flags:

  • // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
  • // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching
  • or for both: // phpcs:ignore WordPress.DB.DirectDatabaseQuery

Issue details

FILE: admin\class-comment-parent.php
----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------
 76 | WARNING | Usage of a direct database call is discouraged.
 76 | WARNING | Direct database call without caching detected. Consider using wp_cache_get() /
    |         | wp_cache_set() or wp_cache_delete().
----------------------------------------------------------------------------------------------------


FILE: inc\class-clean-emails.php
----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------
 214 | WARNING | Usage of a direct database call is discouraged.
 214 | WARNING | Direct database call without caching detected. Consider using wp_cache_get() /
     |         | wp_cache_set() or wp_cache_delete().
----------------------------------------------------------------------------------------------------


FILE: inc\class-comment-email-links.php
----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------
 55 | WARNING | Usage of a direct database call is discouraged.
 55 | WARNING | Direct database call without caching detected. Consider using wp_cache_get() /
    |         | wp_cache_set() or wp_cache_delete().
----------------------------------------------------------------------------------------------------

To retrieve an up-to-date list, run the following from the repo root:

phpcs -p . --standard=WordPress --sniffs=WordPress.DB.DirectDatabaseQuery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant