Make WordPress Core

Changeset 52311


Ignore:
Timestamp:
12/03/2021 11:34:55 AM (2 years ago)
Author:
audrasjb
Message:

REST API: Use global transients for URL details endpoint.

Follow-up to [51973].

Props peterwilsoncc, costdev.
Fixes #54499.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php

    r52008 r52311  
    452452     */
    453453    private function get_cache( $key ) {
    454         return get_transient( $key );
     454        return get_site_transient( $key );
    455455    }
    456456
     
    479479        $cache_expiration = apply_filters( 'rest_url_details_cache_expiration', $ttl );
    480480
    481         return set_transient( $key, $data, $cache_expiration );
     481        return set_site_transient( $key, $data, $cache_expiration );
    482482    }
    483483
  • trunk/tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php

    r51973 r52311  
    9494
    9595        // Disables usage of cache during major of tests.
    96         add_filter( 'pre_transient_' . $this->get_transient_name(), '__return_null' );
     96        add_filter( 'pre_site_transient_' . $this->get_transient_name(), '__return_null' );
    9797    }
    9898
     
    342342    public function test_will_return_from_cache_if_populated() {
    343343        $transient_name = $this->get_transient_name();
    344         remove_filter( "pre_transient_{$transient_name}", '__return_null' );
     344        remove_filter( "pre_site_transient_{$transient_name}", '__return_null' );
    345345
    346346        // Force cache to return a known value as the remote URL http response body.
    347347        add_filter(
    348             "pre_transient_{$transient_name}",
     348            "pre_site_transient_{$transient_name}",
    349349            static function() {
    350350                return '<html><head><title>This value from cache.</title></head><body></body></html>';
Note: See TracChangeset for help on using the changeset viewer.