Skip to content

Commit

Permalink
fix(shows): feed cache issue
Browse files Browse the repository at this point in the history
  • Loading branch information
eteubert committed Feb 10, 2022
1 parent eba1167 commit fb43d40
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/feeds/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,24 @@ function override_feed_entry($hook, $podcast, $feed, $format)
{
add_action($hook, function () use ($podcast, $feed, $format) {
global $post;
global $wp_query;

$cache_key = 'feed_item_'.$feed->slug.'_'.$post->ID;

// if this is a show feed, add the show slug to the cache key
if ($wp_query->tax_query->queries) {
$q = $wp_query->tax_query->queries[0];
if ($q['taxonomy'] == 'shows') {
$terms = $q['terms'];
$slug = $terms[0];
if ($slug) {
$cache_key .= '_'.$slug;
}
}
}

$cache = \Podlove\Cache\TemplateCache::get_instance();
echo $cache->cache_for('feed_item_'.$feed->slug.'_'.$post->ID, function () use ($podcast, $feed, $format, $post) {
echo $cache->cache_for($cache_key, function () use ($podcast, $feed, $format, $post) {
$xml = '';

$episode = Model\Episode::find_one_by_post_id($post->ID);
Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ This product includes GeoLite2 data created by MaxMind, available from http://ww

== Changelog ==

= 2022-02-10 =

- fix: feed cache issue when using the "Shows" module

= 2022-02-08 =

- REST API V2! (https://github.com/podlove/podlove-publisher/pull/1248)
Expand Down

0 comments on commit fb43d40

Please sign in to comment.