From 5a22aa0502b6b51616b230d39399ccd83f744bc1 Mon Sep 17 00:00:00 2001 From: Zosterops lateralis <110761737+zosterops-lateralis@users.noreply.github.com> Date: Sun, 7 Aug 2022 10:16:57 +0200 Subject: [PATCH] Calendar widget: Cache contents using user ID as well Even when `read_private_events` isn't set for the current user, using only this key for caching might write the current user's private events into the cache for other users. The `_priv` key in the `$args` array then becomes useless and can be removed entirely. --- classes/class-eo-calendar-widget.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/classes/class-eo-calendar-widget.php b/classes/class-eo-calendar-widget.php index f2b6e085..7f0eeb01 100644 --- a/classes/class-eo-calendar-widget.php +++ b/classes/class-eo-calendar-widget.php @@ -198,10 +198,7 @@ static function generate_output( $month, $args = array() ) { $today = new DateTime( 'now', eo_get_blog_timezone() ); - //Ensure a different cache key for those who can and cannot see private blogs - $args['_priv'] = current_user_can( 'read_private_events' ) ? '_priv' : false; - - $key = $month->format( 'YM' ) . serialize( $args ) . get_locale() . $today->format( 'Y-m-d' ); + $key = $month->format( 'YM' ) . serialize( $args ) . get_locale() . $today->format( 'Y-m-d' ) . get_current_user_id(); $calendar = get_transient( 'eo_widget_calendar' ); if ( ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) && $calendar && is_array( $calendar ) && isset( $calendar[$key] ) ) { return $calendar[$key];