3.2 KiB
3.2 KiB
Maple GDPR Cookies - FIXED VERSION v4.0.1
🔧 Critical Fix Applied
Issue Fixed:
Fatal Error: Call to undefined function wp_cache_delete_group()
Root Cause:
The function wp_cache_delete_group() does not exist in WordPress core. This was causing a fatal error during plugin activation at line 273.
Solution Implemented:
Completely rewrote the mgc_clear_all_caches() function (lines 145-190) to use proper WordPress cache functions:
- wp_cache_flush() - Clears all WordPress object cache
- delete_transient() - Removes plugin-specific transients
- wp_cache_delete() - Deletes specific cache keys
- Database query - Cleans up orphaned transient entries
- Action hooks - Allows other plugins to integrate
What Changed:
BEFORE (Lines 145-150 - BROKEN):
function mgc_clear_all_caches() {
wp_cache_delete_group('maple-gdpr-cookies'); // ❌ Doesn't exist
delete_transient('mgc_settings');
}
AFTER (Lines 145-190 - FIXED):
function mgc_clear_all_caches() {
// Method 1: Clear WordPress object cache
if (function_exists('wp_cache_flush')) {
wp_cache_flush();
}
// Method 2: Clear plugin-specific transients
global $wpdb;
$transients = $wpdb->get_col(
"SELECT option_name FROM $wpdb->options
WHERE option_name LIKE '_transient_mgc_%'"
);
foreach ($transients as $transient) {
$transient_key = str_replace('_transient_', '', $transient);
delete_transient($transient_key);
}
// Method 3: Clear specific plugin caches
$cache_keys = array('mgc_settings', 'mgc_stats', 'mgc_consent_logs');
foreach ($cache_keys as $key) {
wp_cache_delete($key, 'maple-gdpr-cookies');
delete_transient($key);
}
// Method 4: WooCommerce compatibility
if (function_exists('wc_delete_shop_order_transients')) {
wc_delete_shop_order_transients();
}
// Method 5: Extensibility hook
do_action('mgc_clear_caches');
}
✅ Benefits of the Fix:
- Works Everywhere - Compatible with all WordPress installations
- No Fatal Errors - Uses only existing WordPress functions
- Comprehensive - Clears all types of caches (object, transient, database)
- Plugin Compatibility - Includes WooCommerce integration
- Extensible - Developers can hook into cache clearing
🚀 Installation:
- Deactivate the old version (if active)
- Delete the old plugin folder
- Upload this fixed version
- Activate the plugin
The plugin will now activate successfully without fatal errors!
📋 Version History:
- v4.0.1 (Oct 24, 2025) - CRITICAL FIX: Replaced wp_cache_delete_group() with proper cache functions
- v4.0.0 - Original version with cache bug
🔒 No Other Changes:
All other functionality remains identical:
- GDPR compliance features ✅
- Security measures ✅
- WooCommerce/LearnDash compatibility ✅
- Consent logging ✅
- Cookie management ✅
📞 Support:
If you encounter any issues with this fix, please check:
- WordPress version 5.0+ ✅
- PHP version 7.2+ ✅
- MySQL version 5.5.3+ ✅
This is a critical hotfix that resolves the activation fatal error while maintaining all plugin functionality.