Skip to content

Commit af33442

Browse files
committed
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
1 parent 2cfc68b commit af33442

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/wp-admin/includes/class-wp-community-events.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,12 @@ protected function cache_events( $events, $expiration = false ) {
353353
* on success, false on failure.
354354
*/
355355
public function get_cached_events() {
356-
$cached_response = get_site_transient( $this->get_events_transient_key( $this->user_location ) );
356+
$transient_key = $this->get_events_transient_key( $this->user_location );
357+
if ( ! $transient_key ) {
358+
return false;
359+
}
357360

361+
$cached_response = get_site_transient( $transient_key );
358362
if ( isset( $cached_response['events'] ) ) {
359363
$cached_response['events'] = $this->trim_events( $cached_response['events'] );
360364
}

0 commit comments

Comments
 (0)