From af33442c3a1c2f8c42c5c27c26d7188a6dc29244 Mon Sep 17 00:00:00 2001 From: David Baumwald Date: Tue, 27 Sep 2022 18:55:49 +0000 Subject: [PATCH] Administration: Guard against `false` transient key in `get_cached_events()`. Inside `WP_Community_Events::get_cached_events()`, `WP_Community_Events::get_events_transient_key()` is used to retrieve the transient key name, based on the user's location. However, the transient key can potentially return `false`, resulting in a call to `get_site_transient()` with the `$key` being `false`. This change first attempts to evaluate and guard against a `false` return from `WP_Community_Events::get_events_transient_key()`. The result is an early `false` return from `WP_Community_Events::get_cached_events()`. Props malthert, rafiahmedd, audrasjb, costdev. Fixes #55888. git-svn-id: https://develop.svn.wordpress.org/trunk@54338 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-community-events.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-community-events.php b/src/wp-admin/includes/class-wp-community-events.php index 1a09bec848..09557c86a4 100644 --- a/src/wp-admin/includes/class-wp-community-events.php +++ b/src/wp-admin/includes/class-wp-community-events.php @@ -353,8 +353,12 @@ class WP_Community_Events { * on success, false on failure. */ public function get_cached_events() { - $cached_response = get_site_transient( $this->get_events_transient_key( $this->user_location ) ); + $transient_key = $this->get_events_transient_key( $this->user_location ); + if ( ! $transient_key ) { + return false; + } + $cached_response = get_site_transient( $transient_key ); if ( isset( $cached_response['events'] ) ) { $cached_response['events'] = $this->trim_events( $cached_response['events'] ); }