From 07282da9671de8fb2601e9e641decb2655439ad8 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 01 Jan 2026 23:20:54 +0000
Subject: [PATCH] =FeedRoutes.php: fixed the extractTaxonomies method
---
inc/managers/CacheManager.php | 61 ++++++++++++++++++++++++++----
1 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/inc/managers/CacheManager.php b/inc/managers/CacheManager.php
index 8612385..2583431 100644
--- a/inc/managers/CacheManager.php
+++ b/inc/managers/CacheManager.php
@@ -306,7 +306,14 @@
$key = $this->normalizeKey($key);
$cache_key = $this->buildKey($key);
- return wp_cache_get($cache_key, $group);
+ $value = wp_cache_get($cache_key, $group);
+
+ // Fallback to transient if no external object cache
+ if ($value === false && !wp_using_ext_object_cache()) {
+ $value = get_transient($group . '_' . $cache_key);
+ }
+
+ return $value;
}
/**
@@ -324,12 +331,18 @@
$key = $this->normalizeKey($key);
$cache_key = $this->buildKey($key);
- // Update timestamp when setting new data
self::updateTimestamp($this->group);
- return wp_cache_set($cache_key, $value, $group, $ttl);
- }
+ // Try object cache first
+ $result = wp_cache_set($cache_key, $value, $group, $ttl);
+ // If no external object cache, also store in transient for persistence
+ if (!wp_using_ext_object_cache()) {
+ set_transient($group . '_' . $cache_key, $value, $ttl);
+ }
+
+ return $result;
+ }
/**
* Delete a cached value
* @param string|array $key The key to look up (auto-generates key from array of key=>values)
@@ -342,9 +355,17 @@
$key = $this->normalizeKey($key);
$cache_key = $this->buildKey($key);
- return wp_cache_delete($cache_key, $group);
+ $result = wp_cache_delete($cache_key, $group);
+
+ // Also delete transient if no external object cache
+ if (!wp_using_ext_object_cache()) {
+ delete_transient($group . '_' . $cache_key);
+ }
+
+ return $result;
}
+
/**
* Clear all cache for this group
* @return bool
@@ -354,16 +375,40 @@
try {
if (function_exists('wp_cache_flush_group')) {
wp_cache_flush_group($this->group);
- self::updateTimestamp($this->group);
- return true;
}
- return false;
+
+ // Clear transients for this group if no external object cache
+ if (!wp_using_ext_object_cache()) {
+ $this->clearGroupTransients();
+ }
+
+ self::updateTimestamp($this->group);
+ return true;
} catch (\Exception $e) {
return false;
}
}
/**
+ * Clear all transients for this cache group
+ */
+ private function clearGroupTransients(): void
+ {
+ global $wpdb;
+
+ $pattern = '_transient_' . $this->group . '_' . $this->prefix . '%';
+ $timeout_pattern = '_transient_timeout_' . $this->group . '_' . $this->prefix . '%';
+
+ $wpdb->query(
+ $wpdb->prepare(
+ "DELETE FROM $wpdb->options WHERE option_name LIKE %s OR option_name LIKE %s",
+ $pattern,
+ $timeout_pattern
+ )
+ );
+ }
+
+ /**
* Helper to generateKey from array if applicable
* @param string|array $key
* @return string
--
Gitblit v1.10.0