-
Notifications
You must be signed in to change notification settings - Fork 55
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
Undefined index notice when stats get reset #50
Comments
I submitted a PR with a light-touch fix in #51. There is still a potential issue here, in that cache hits and cache misses are assigned by reference to sub-elements in that array: https://github.com/Automattic/wp-memcached/blob/master/object-cache.php#L655-L656 A more robust solution could use magic |
I'm wondering if a better method wouldn't be to just have Core/WP-CLI unset the global and call Perhaps another option is to suggest a |
I agree that the issue should be fixed more holistically, both in other libraries that use this plugin, as well as more gracefully within the plugin itself. However, the fact that the stats array can be reset because it's a public property justifies some look-before-you-leap code within this plugin as well. |
Various systems reset the stats array to an empty array, which deletes all of the keys, such as
'get'
and'add'
. Common examples include:flush_cache
method: https://github.com/WordPress/wordpress-develop/blob/master/tests/phpunit/includes/abstract-testcase.php#L343wp_clear_object_cache
method: https://github.com/wp-cli/wp-cli/blob/5dc1c5835dcf532dd8530b83c32a2e249211df94/php/utils-wp.php#L300This was recently fixed in the VIP WP CLI helper: Automattic/vip-go-mu-plugins@515b71d
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
The text was updated successfully, but these errors were encountered: