Skip to content

Direct database calls without caching in db-optimize.php #128

Description

@CoachBirgit

Description

Line 84 makes a direct $wpdb call without using the WordPress object cache. The Plugin Checker flags this because repeated calls to the same query waste database resources.

Action needed

Wrap the query result with wp_cache_get() / wp_cache_set(), or add an inline PHPCS ignore comment with a justification if caching doesn't make sense for this operation (database optimization results change every time, so caching may be inappropriate here).

// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Optimization results are not cacheable.

PHPCS rules

  • WordPress.DB.DirectDatabaseQuery.DirectQuery (WARNING)
  • WordPress.DB.DirectDatabaseQuery.NoCaching (WARNING)

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions