WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 10 months ago

#31463 new defect (bug)

Avoid reaching inside the object cache object in tests

Reported by: rmccue Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:
PR Number:

Description

It'd be really fantastically great if WP_UnitTestCase::flush_cache could keep its hands off my internal properties. :)

Right now, flush_cache reaches into $wp_object_cache and messes with a bunch of internal properties:

$wp_object_cache->group_ops = array();
$wp_object_cache->stats = array();
$wp_object_cache->memcache_debug = array();
$wp_object_cache->cache = array();

If we could just not do that, that'd be greaaaat.

Attachments (1)

31463.diff (569 bytes) - added by voldemortensen 5 years ago.

Download all attachments as: .zip

Change History (6)

#1 @wonderboymusic
5 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.2

@voldemortensen
5 years ago

#3 @voldemortensen
5 years ago

  • Keywords has-patch added; needs-patch removed

I couldn't find anywhere that was actually setting these properties anyway. I don't know if I'm missing something but I don't see a purpose for these lines. The $wp_object_cache->cache = array(); seems to be redundant as that's what wp_cache_flush does.

#4 @dd32
5 years ago

@voldemortensen FWIW, those lines are included for external object caches, not the core classes. Those properties, and __remoteset are used by Memcache, but others might use something different (I don't think __remoteset is even used in a published object cache, I think it's only used by the internal wp.com one)

See https://plugins.trac.wordpress.org/browser/memcached/tags/2.0.2/object-cache.php#L189 and https://plugins.trac.wordpress.org/browser/memcached-redux/tags/0.1.3/object-cache.php#L215

I guess we'd have to add a new method/parameter to do this, and even possibly include the back-compat code here.

#5 @DrewAPicture
5 years ago

  • Milestone changed from 4.2 to Future Release

Moving off of the 4.2 milestone as this is a release-independent change.

Note: See TracTickets for help on using tickets.