Automattic / Automattic/wp-memcached
Undefined index notice when stats get reset
- Dominant language
- PHP
- Stars
- 172
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
Various systems reset the stats array to an empty array, which deletes all of the keys, such as `'get'` and `'add'`. Common examples include:
* WordPress core's PHPUnit abstract testcase, in the `flush_cache` method: https://github.com/WordPress/wordpress-develop/blob/master/tests/phpunit/includes/abstract-testcase.php#L343
* WP-CLI, in the `wp_clear_object_cache` method: https://github.com/wp-cli/wp-cli/blob/5dc1c5835dcf532dd8530b83c32a2e249211df94/php/utils-wp.php#L300
This was recently fixed in the VIP WP CLI helper: https://github.com/Automattic/vip-go-mu-plugins/commit/515b71d193535b18b9b275e6c44a458c4e1ffca6
Since the property is public and we can't control for every use case, one thing we *can* do is to ensure that the increments are happening safely, rather than assuming the property exists, as is done here: https://github.com/Automattic/wp-memcached/blob/master/object-cache.php#L319
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with object-cache.php around line 319, where the stats increments currently assume keys such as 'get' and 'add' exist. Reproduce the case where the public stats property is reset to an empty array, then verify that the increments no longer emit undefined index notices and that the counters still update.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100