Make WordPress Core

Changeset 54338


Ignore:
Timestamp:
09/27/2022 06:55:49 PM (2 years ago)
Author:
davidbaumwald
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-community-events.php

    r54133 r54338  
    354354     */
    355355    public function get_cached_events() {
    356         $cached_response = get_site_transient( $this->get_events_transient_key( $this->user_location ) );
    357 
     356        $transient_key = $this->get_events_transient_key( $this->user_location );
     357        if ( ! $transient_key ) {
     358            return false;
     359        }
     360
     361        $cached_response = get_site_transient( $transient_key );
    358362        if ( isset( $cached_response['events'] ) ) {
    359363            $cached_response['events'] = $this->trim_events( $cached_response['events'] );
Note: See TracChangeset for help on using the changeset viewer.