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.
Built from https://develop.svn.wordpress.org/trunk@54338


git-svn-id: http://core.svn.wordpress.org/trunk@53897 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
davidbaumwald 2022-09-27 18:57:13 +00:00
parent f99287285d
commit 888d01689d
2 changed files with 6 additions and 2 deletions

View File

@ -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'] );
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-beta2-54337';
$wp_version = '6.1-beta2-54338';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.