VIP-Coding-Standards icon indicating copy to clipboard operation
VIP-Coding-Standards copied to clipboard

Global memcached groups names

Open rebeccahum opened this issue 6 years ago • 3 comments

Bug Description

We should not allow use of global memcached cache group names, as they are being used on a global scale and things go wrong (such as user login) when they are overwritten: https://github.com/Automattic/wp-memcached

Minimal Code Snippet

wp_cache_set( 'blahblah', 'blah', 'users', 1 * MINUTE_IN_SECONDS );

Tested Against master branch?

  • [x] I have verified the issue still exists in the master branch of VIPCS.

rebeccahum avatar Oct 31 '18 21:10 rebeccahum

global memcached cache group names

Have you got a list of those @rebeccahum?

Can you give more examples of what should be flagged, and some use cases that shouldn't?

GaryJones avatar Jul 11 '20 20:07 GaryJones

In the readme.txt, the list seems to be here:

{$taxonomy}_relationships
{$meta_type}_meta
{$taxonomy}_relationships
blog-details
blog-id-cache
blog-lookup
bookmark
calendar
category
comment
counts
general
global-posts
options
plugins
post_ancestors
post_meta
posts
rss
site-lookup
site-options
site-transient
terms
themes
timeinfo
transient
user_meta
useremail
userlogins
usermeta
users
userslugs
widget

rebeccahum avatar Jul 13 '20 16:07 rebeccahum

So, new sniff, look for wp_cache_set function calls, check third arg is one of those from the list, and give an Error, severity 5.

GaryJones avatar Jul 27 '20 07:07 GaryJones

Noting that @WPprodigy is working on https://github.com/automattic/wp-cache-memcached as a replacement / update to https://github.com/automattic/wp-memcached so the global group names may change.

GaryJones avatar Aug 21 '23 17:08 GaryJones

Hmm, I'm not entirely sure we want to prevent this. There could be valid use cases for using one of the existing global groups in a safe way.

WPprodigy avatar Aug 21 '23 18:08 WPprodigy

That's fine with me. Thanks!

GaryJones avatar Aug 21 '23 20:08 GaryJones