Skip to content

Commit

Permalink
added: widget cache now store cache per language
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalsem committed Oct 1, 2024
1 parent 50a6ba6 commit e0eea24
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions classes/ColdTrick/WidgetManager/Widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ public static function getContentFromCache(\Elgg\Event $event): ?array {
return null;
}

$cached_data = elgg_load_system_cache("widget_cache_{$widget->guid}");
$current_language = elgg_get_current_language();
$cached_data = elgg_load_system_cache("widget_cache_{$widget->guid}_{$current_language}");
if (empty($cached_data)) {
return null;
}
Expand Down Expand Up @@ -187,7 +188,8 @@ public static function saveContentInCache(\Elgg\Event $event): void {
return;
}

elgg_save_system_cache("widget_cache_{$widget->guid}", $event->getValue());
$current_language = elgg_get_current_language();
elgg_save_system_cache("widget_cache_{$widget->guid}_{$current_language}", $event->getValue());
}

/**
Expand All @@ -207,7 +209,10 @@ public static function clearWidgetCacheOnUpdate(\Elgg\Event $event): void {
return;
}

elgg_delete_system_cache("widget_cache_{$widget->guid}");
$languages = elgg()->translator->getAllowedLanguages();
foreach ($languages as $language) {
elgg_delete_system_cache("widget_cache_{$widget->guid}_{$language}");
}
}

/**
Expand Down

0 comments on commit e0eea24

Please sign in to comment.