Automattic / Automattic/wp-memcached

$found parameter to wp_cache_get() is incorrect when object is in local cache in a non-persistent group

Open
#61 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
172
Forks
52
PR merge metrics
No merged PRs in 30d

Description

On the back of #40 & #43 that changed the behaviour of the `$found` parameter to reflect the status of the data in memcache, however, it breaks a different-but-similar case: non-persistent groups.

For example:
```
wp> wp_cache_add_non_persistent_groups( [ 'example' ] );
NULL

wp> wp_cache_set( 'example', 'example', 'example' );
bool(true)

wp> wp_cache_get( 'example', 'example', false, $found );
string(7) "example"

wp> $found
bool(false)
```

In this case, the value was never going to exist within memcache and it was found in the cache, so I would argue that `$found` should be true in this case.

I personally ran into this with Cavalcade, where it relies upon the `$found` parameter working with non-persistent groups: https://github.com/humanmade/Cavalcade/blob/master/inc/class-job.php#L366-L368

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing wp_cache_get(), wp_cache_set(), and wp_cache_add_non_persistent_groups() for non-persistent groups, comparing the local-cache path with the memcache status handling described in the issue. Done means the reproduced example reports $found as true and a regression test covers this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
memcached, php, wordpress
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.