Skip to content

Check properties in Utils\wp_clear_object_cache#4615

Merged
schlessera merged 3 commits intomasterfrom
update-wp_clear_object_cache
Jan 23, 2018
Merged

Check properties in Utils\wp_clear_object_cache#4615
schlessera merged 3 commits intomasterfrom
update-wp_clear_object_cache

Conversation

@gitlost
Copy link
Copy Markdown
Contributor

@gitlost gitlost commented Jan 15, 2018

Noticed on doing wp-cli/media-command#62 PR that Utils\wp_clear_object_cache() was setting some non-defined properties on the WP_Object_Cache object.

The code appears to be Memcached and Memcached Redux plugin specific according to https://core.trac.wordpress.org/ticket/31463. See also WP_UnitTestCase::flush_cache() in core test suite https://github.com/WordPress/wordpress-develop/blob/4.9.1/tests/phpunit/includes/testcase.php#L321.

So this PR updates the wp_clear_object_cache() to use the standard wp_cache_flush() function, keeping the other stuff for BC but checking first and using method_exists() on __remoteset check.

@gitlost
Copy link
Copy Markdown
Contributor Author

gitlost commented Jan 16, 2018

Might as well do this I think in spite of #4617 in case it's being used externally.

@gitlost gitlost added this to the 1.5.0 milestone Jan 16, 2018
@gitlost gitlost requested a review from a team January 16, 2018 14:11
@schlessera
Copy link
Copy Markdown
Member

I'm opposed to this change.

While the "hack" we had included to keep memory usage in check was trying to isolate the flushing to local memory only, calling wp_cache_flush() will ensure that we also invalidate the entire persistent remote cache, without any obvious reason.

The contents of the remote cache have nothing to do with WP-CLI memory usage, and just flushing it for not reason is irresponsible when dealing with larger sites.

@gitlost
Copy link
Copy Markdown
Contributor Author

gitlost commented Jan 16, 2018

Oh okay, so just remove the call to wp_cache_flush() and keep the checks on the properties?

@schlessera schlessera merged commit e444087 into master Jan 23, 2018
@schlessera schlessera deleted the update-wp_clear_object_cache branch January 23, 2018 17:04
@danielbachhuber danielbachhuber changed the title Use wp_cache_flush in Utils\wp_clear_object_cache & check props. Check properties in Utils\wp_clear_object_cache Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants