Opened 3 years ago
Closed 2 years ago
#54864 closed enhancement (fixed)
Update the object-cache.php in phpunit fixture to support wp_cache_get_multiple
Reported by: | spacedmonkey | Owned by: | spacedmonkey |
---|---|---|---|
Milestone: | 6.2 | Priority: | normal |
Severity: | normal | Version: | 4.8 |
Component: | Build/Test Tools | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description (last modified by )
The object-cache file used in tests/phpunit/includes/object-cache.php is used in PHPUnit tests. In this file, there are references to wp_cache_get_multi
. However, these functions do not exist in core. In WordPress 5.5, the wp_cache_get_multiple
function was added. This function should be implemented in the object-cache.php file.
Change History (21)
This ticket was mentioned in PR #2648 on WordPress/wordpress-develop by petitphp.
3 years ago
#3
- Keywords has-patch has-unit-tests added; needs-patch removed
Add functions wp_cache_get_multiple
, wp_cache_add_multiple
, wp_cache_set_multiple
, wp_cache_delete_multiple
in tests/phpunit/includes/object-cache.php
Trac ticket: https://core.trac.wordpress.org/ticket/54864
tillkruss commented on PR #2648:
2 years ago
#4
@petitphp the memcached tests are failing.
tillkruss commented on PR #2648:
2 years ago
#7
I've updated the PR to fix failing tests.
LGTM, let me see if @felixarntz or @SergeyBiryukov can merge this?
SergeyBiryukov commented on PR #2648:
2 years ago
#8
Thanks for the PR! Looks good to me.
It appears that the file was originally copied in r40561 / #40619 from tollmanz/wordpress-pecl-memcached-object-cache, which is now maintained at humanmade/wordpress-pecl-memcached-object-cache and has a note on the plugin status:
Since this plugin was last updated, WordPress has introduced a variety of caching API improvements such as wp_cache_get_multiple(). This plugin has not been updated to take advantage of these new functions, because Human Made now uses Redis for our own caching backend. It should still work, but it will not be as efficient as it could be given the functionality in the latest versions of WordPress.
The file already has wp_cache_get_multi()
and wp_cache_set_multi()
, but the signatures don't exactly match the core functions:
function wp_cache_get_multi( $keys, $groups = '', &$cas_tokens = null, $flags = null ) function wp_cache_get_multiple( $keys, $group = '', $force = false ) function wp_cache_set_multi( $items, $groups = '', $expiration = 0 ) function wp_cache_set_multiple( array $data, $group = '', $expire = 0 )
So I think it makes sense to introduce the variants of these functions that WordPress core uses.
I've made a few minor adjustments for consistency:
- Placing the new functions directly after the related functions.
- Using camelCase for the method names to match other methods in the class.
- Renaming some parameters:
$data
to$items
and$expire
to$expiration
to match other functions.
#10
@
2 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 54423:
SergeyBiryukov commented on PR #2648:
2 years ago
#11
Merged in r54423.
This ticket was mentioned in PR #3548 on WordPress/wordpress-develop by @spacedmonkey.
2 years ago
#13
Trac ticket: https://core.trac.wordpress.org/ticket/54864
#14
@
2 years ago
@SergeyBiryukov I have reopenned- to full implement get_multiple, that gets multiple keys in a single memcache call.
@spacedmonkey commented on PR #3548:
2 years ago
#16
Correctly implementing this function and priming multiple in a single request, speeds up the unit tests. From 5.28 minutes to 4 minutes.
#18
@
2 years ago
- Owner changed from SergeyBiryukov to spacedmonkey
- Status changed from reopened to assigned
@SergeyBiryukov commented on PR #3548:
2 years ago
#20
This was committed in r54942.
In [52700]
wp_cache_add_multiple
,wp_cache_set_multiple
andwp_cache_delete_multiple
were added. While working on this patch, we should also add these functions as well.