Skip to content

Commit

Permalink
fix the cache key to properly use the dynamic post ID
Browse files Browse the repository at this point in the history
  • Loading branch information
leogermani committed Jan 18, 2024
1 parent 9c08f77 commit 4429878
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions includes/classes/DistributorPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,9 @@ protected function parse_media_blocks() {
$found = false;

// Note: changes to the cache key or group should be reflected in `includes/settings.php`
$media = wp_cache_get( 'dt_media::{$post_id}', 'dt::post', false, $found );
$cache_key = "dt_media::{$this->post->ID}";
$cache_group = 'dt::post';
$media = wp_cache_get( $cache_key, $cache_group, false, $found );

if ( ! $found ) {
// Parse blocks to determine attached media.
Expand All @@ -679,7 +681,7 @@ protected function parse_media_blocks() {
}

// Only the IDs are cached to keep the cache size down.
wp_cache_set( 'dt_media::{$post_id}', $media, 'dt::post' );
wp_cache_set( $cache_key, $media, $cache_group );
}

/*
Expand Down

0 comments on commit 4429878

Please sign in to comment.