mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-14 01:24:27 +00:00
Cache: Use wp_cache_*_multiple() in core functions.
Implement the `wp_cache_add_multiple`, `wp_cache_set_multiple` and `wp_cache_delete_multiple` in a number of core functions after they were introduced in [52700] Props: spacedmonkey, adamsilverstein, flixos90, mitogh. Fixes: #55029. git-svn-id: https://develop.svn.wordpress.org/trunk@52707 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1883,9 +1883,11 @@ function wp_transition_comment_status( $new_status, $old_status, $comment ) {
|
||||
*/
|
||||
function _clear_modified_cache_on_transition_comment_status( $new_status, $old_status ) {
|
||||
if ( 'approved' === $new_status || 'approved' === $old_status ) {
|
||||
$data = array();
|
||||
foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
|
||||
wp_cache_delete( "lastcommentmodified:$timezone", 'timeinfo' );
|
||||
$data[] = "lastcommentmodified:$timezone";
|
||||
}
|
||||
wp_cache_delete_multiple( $data, 'timeinfo' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2045,9 +2047,11 @@ function wp_insert_comment( $commentdata ) {
|
||||
if ( 1 == $comment_approved ) {
|
||||
wp_update_comment_count( $comment_post_ID );
|
||||
|
||||
$data = array();
|
||||
foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
|
||||
wp_cache_delete( "lastcommentmodified:$timezone", 'timeinfo' );
|
||||
$data[] = "lastcommentmodified:$timezone";
|
||||
}
|
||||
wp_cache_delete_multiple( $data, 'timeinfo' );
|
||||
}
|
||||
|
||||
clean_comment_cache( $id );
|
||||
@@ -3220,9 +3224,9 @@ function xmlrpc_pingback_error( $ixr_error ) {
|
||||
* @param int|array $ids Comment ID or an array of comment IDs to remove from cache.
|
||||
*/
|
||||
function clean_comment_cache( $ids ) {
|
||||
foreach ( (array) $ids as $id ) {
|
||||
wp_cache_delete( $id, 'comment' );
|
||||
|
||||
$comment_ids = (array) $ids;
|
||||
wp_cache_delete_multiple( $comment_ids, 'comment' );
|
||||
foreach ( $comment_ids as $id ) {
|
||||
/**
|
||||
* Fires immediately after a comment has been removed from the object cache.
|
||||
*
|
||||
@@ -3250,9 +3254,11 @@ function clean_comment_cache( $ids ) {
|
||||
* @param bool $update_meta_cache Whether to update commentmeta cache. Default true.
|
||||
*/
|
||||
function update_comment_cache( $comments, $update_meta_cache = true ) {
|
||||
$data = array();
|
||||
foreach ( (array) $comments as $comment ) {
|
||||
wp_cache_add( $comment->comment_ID, $comment, 'comment' );
|
||||
$data[ $comment->comment_ID ] = $comment;
|
||||
}
|
||||
wp_cache_add_multiple( $data, 'comment' );
|
||||
|
||||
if ( $update_meta_cache ) {
|
||||
// Avoid `wp_list_pluck()` in case `$comments` is passed by reference.
|
||||
|
||||
Reference in New Issue
Block a user