Make WordPress Core

Ticket #62111: 62111-embed-cache-fix.patch

File 62111-embed-cache-fix.patch, 541 bytes (added by rahultank, 4 months ago)

Confirmed bug in embed cache logic. The issue is on line 272 where || should be &&. Problem: cache_oembed() sets usecache=false to force refresh, but the OR condition still returns cached content if cached_recently=true. Solution: Change if ( $this->usecache || $cached_recently ) to if ( $this->usecache && $cached_recently ) This ensures cache is only used when both caching is enabled AND content is fresh. When forcing refresh, usecache=false bypasses cache regardless of age.

  • src/wp-includes/class-wp-embed.php

    diff --git a/src/wp-includes/class-wp-embed.php b/src/wp-includes/class-wp-embed.php
    index 7519b0bf77..97f43c56f6 100644
    a b class WP_Embed { 
    269269
    270270                $cached_recently = ( time() - $cache_time ) < $ttl;
    271271
    272                 if ( $this->usecache || $cached_recently ) {
     272                if ( $this->usecache && $cached_recently ) {
    273273                        // Failures are cached. Serve one if we're using the cache.
    274274                        if ( '{{unknown}}' === $cache ) {
    275275                                return $this->maybe_make_link( $url );