Opened 14 months ago
Closed 3 months ago
#62111 closed defect (bug) (duplicate)
The cache of the embed seems weird
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Embeds | Keywords: | has-patch |
| Focuses: | Cc: |
Description
I found the cache of the embed seems weird.
Referring to https://github.com/WordPress/wordpress-develop/blob/7f4fd30dffdfe8d7d817c2cdb4ab98408f1c0add/src/wp-includes/class-wp-embed.php#L272, the cache won't be expired even if the value of $cached_recently is false because there is no place to set the $this->usecache to false except the cache_oembed function.
if ( $this->usecache || $cached_recently ) {
...
}
The goal of the cache_oembed function seems to reset all the cache to the latest value. However, when triggering the cache_oembed function, if the cache is not expired, the cache won't be force-updated.
As a result, it seems to be correct if we change the condition from || to &&. Does it make sense?
Attachments (1)
Change History (3)
This ticket was mentioned in PR #7434 on WordPress/wordpress-develop by @arthur791004.
14 months ago
#1
- Keywords has-patch added
@
3 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: Changeif ( $this->usecache || $cached_recently )toif ( $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.
Fix the cache of the embed won't be expired forever
Trac ticket: https://core.trac.wordpress.org/ticket/62111