Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 66ef207

Browse files
committed
Refactor cache clearing methods (AJXP_PluginService::clearPluginsCache & ConfService::clearMessageCache) and use them accordingly. Add a button in settings to clear cache (close #790)
1 parent 5cc1e08 commit 66ef207

File tree

17 files changed

+95
-15
lines changed

17 files changed

+95
-15
lines changed

core/src/core/classes/class.AJXP_PluginsService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ public function storeToPluginQueriesCache($key, $value)
187187
AJXP_Utils::saveSerialFile(AJXP_PLUGINS_QUERIES_CACHE, $test);
188188
}
189189

190+
public static function clearPluginsCache(){
191+
@unlink(AJXP_PLUGINS_CACHE_FILE);
192+
@unlink(AJXP_PLUGINS_REQUIRES_FILE);
193+
@unlink(AJXP_PLUGINS_QUERIES_CACHE);
194+
}
195+
190196
/**
191197
* Simply load a plugin class, without the whole dependencies et.all
192198
* @param string $pluginId

core/src/core/classes/class.ConfService.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,18 @@ public function getMessagesInst($forceRefresh = false)
10281028
return $this->configs["MESSAGES"];
10291029
}
10301030

1031+
/**
1032+
* Clear the messages cache
1033+
*/
1034+
public static function clearMessagesCache(){
1035+
$i18nFiles = glob(dirname(AJXP_PLUGINS_MESSAGES_FILE)."/i18n/*.ser");
1036+
if (is_array($i18nFiles)) {
1037+
foreach ($i18nFiles as $file) {
1038+
@unlink($file);
1039+
}
1040+
}
1041+
}
1042+
10311043
/**
10321044
* Get all registered extensions, from both the conf/extensions.conf.php and from the plugins
10331045
* @static

core/src/plugins/access.ajxp_conf/ajxp_confActions.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,19 @@
556556
<serverCallback methodName="switchAction"/>
557557
</processing>
558558
</action>
559+
<action name="clear_plugins_cache">
560+
<gui src="plugins" text="ajxp_conf.129" title="ajxp_conf.130">
561+
<context dir="true" recycle="true" allowedMimes="plugins_zone" selection="false" actionBar="true" actionBarGroup="get"/>
562+
</gui>
563+
<processing>
564+
<clientCallback><![CDATA[
565+
var conn = new Connexion();
566+
conn.setParameters($H({get_action:'clear_plugins_cache'}));
567+
conn.sendAsync();
568+
]]></clientCallback>
569+
<serverCallback methodName="switchAction"/>
570+
</processing>
571+
</action>
559572
</actions>
560573
<client_configs>
561574
<component_config className="InfoPanel">

core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,21 +331,25 @@ public function switchAction($action, $httpVars, $fileVars)
331331
)
332332
),
333333
"config" => array(
334+
"AJXP_MIME" => "plugins_zone",
334335
"LABEL" => $mess["ajxp_conf.109"],
335336
"ICON" => "preferences_desktop.png",
336337
"DESCRIPTION" => "Global configurations of the application core and of each plugin. Enable/disable plugins",
337338
"CHILDREN" => array(
338339
"core" => array(
340+
"AJXP_MIME" => "plugins_zone",
339341
"LABEL" => $mess["ajxp_conf.98"],
340342
"DESCRIPTION" => "Core application parameters",
341343
"ICON" => "preferences_desktop.png",
342344
"LIST" => "listPlugins"),
343345
"plugins" => array(
346+
"AJXP_MIME" => "plugins_zone",
344347
"LABEL" => $mess["ajxp_conf.99"],
345348
"DESCRIPTION" => "Enable/disable additional feature-oriented plugins, check if they are correctly working, set up global parameters of the plugins.",
346349
"ICON" => "folder_development.png",
347350
"LIST" => "listPlugins"),
348351
"core_plugins" => array(
352+
"AJXP_MIME" => "plugins_zone",
349353
"LABEL" => $mess["ajxp_conf.123"],
350354
"DESCRIPTION" => "Enable/disable core plugins (auth, conf, mail, etc), check if they are correctly working. Configuration of these plugins are generally done through the Main Options",
351355
"ICON" => "folder_development.png",
@@ -477,6 +481,17 @@ public function switchAction($action, $httpVars, $fileVars)
477481

478482
break;
479483

484+
case "clear_plugins_cache":
485+
AJXP_XMLWriter::header();
486+
// Clear plugins cache if they exist
487+
AJXP_PluginsService::clearPluginsCache();
488+
ConfService::clearMessagesCache();
489+
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.".(AJXP_SKIP_CACHE?"132":"131")], null);
490+
AJXP_XMLWriter::reloadDataNode();
491+
AJXP_XMLWriter::close();
492+
break;
493+
494+
480495
case "create_group":
481496

482497
if (isSet($httpVars["group_path"])) {
@@ -1678,9 +1693,7 @@ public function switchAction($action, $httpVars, $fileVars)
16781693
$this->parseParameters($httpVars, $options, null, true);
16791694
$confStorage = ConfService::getConfStorageImpl();
16801695
$confStorage->savePluginConfig($httpVars["plugin_id"], $options);
1681-
@unlink(AJXP_PLUGINS_CACHE_FILE);
1682-
@unlink(AJXP_PLUGINS_REQUIRES_FILE);
1683-
@unlink(AJXP_PLUGINS_MESSAGES_FILE);
1696+
AJXP_PluginsService::clearPluginsCache();
16841697
AJXP_XMLWriter::header();
16851698
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.97"], null);
16861699
AJXP_XMLWriter::close();

core/src/plugins/access.ajxp_conf/i18n/de.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,8 @@
151151
"126" => "Sind Sie sicher, dass Sie die ausgewählten Elemente löschen möchten?",
152152
"127" => "Achtung, bitte verwenden Sie keine Sonderzeichen. Benutzer würde mit Login-ID '%s' erstellt werden.",
153153
"128" => "Successfully deleted group",
154+
"129" => "Refresh plugins cache",
155+
"130" => "Clear plugins cache, can be necessary to see new plugins appear in the list.",
156+
"131" => "Plugins cache files were deleted succesfully!",
157+
"132" => "Cache cleared, but you are currently running in SKIP_CACHE mode (see bootstrap_context.php).",
154158
);

core/src/plugins/access.ajxp_conf/i18n/en.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,8 @@
149149
"126" => "Are you sure that you want to delete the selected element(s)?",
150150
"127" => "Warning, please do not use special characters, user would be created with login id '%s'",
151151
"128" => "Successfully deleted group",
152+
"129" => "Refresh plugins cache",
153+
"130" => "Clear plugins cache, can be necessary to see new plugins appear in the list.",
154+
"131" => "Plugins cache files were deleted succesfully!",
155+
"132" => "Cache cleared, but you are currently running in SKIP_CACHE mode (see bootstrap_context.php).",
152156
);

core/src/plugins/access.ajxp_conf/i18n/es.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,8 @@
149149
"126" => "Are you sure that you want to delete the selected element(s)?",
150150
"127" => "Warning, please do not use special characters, user would be created with login id '%s'",
151151
"128" => "Successfully deleted group",
152+
"129" => "Refresh plugins cache",
153+
"130" => "Clear plugins cache, can be necessary to see new plugins appear in the list.",
154+
"131" => "Plugins cache files were deleted succesfully!",
155+
"132" => "Cache cleared, but you are currently running in SKIP_CACHE mode (see bootstrap_context.php).",
152156
);

core/src/plugins/access.ajxp_conf/i18n/fi.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,9 @@
152152
"126" => "Are you sure that you want to delete the selected element(s)?",
153153
"127" => "Warning, please do not use special characters, user would be created with login id '%s'",
154154
"128" => "Successfully deleted group",
155+
"129" => "Refresh plugins cache",
156+
"130" => "Clear plugins cache, can be necessary to see new plugins appear in the list.",
157+
"131" => "Plugins cache files were deleted succesfully!",
158+
"132" => "Cache cleared, but you are currently running in SKIP_CACHE mode (see bootstrap_context.php).",
155159
/* END SENTENCE */
156160
);

core/src/plugins/access.ajxp_conf/i18n/fr.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,8 @@
149149
"126" => "Voulez-vous vraiment supprimer les éléments sélectionnés?",
150150
"127" => "Attention, veuillez ne pas utiliser de caractères spéciaux, l'utilisateur serait créé avec l'identifiant '%s'",
151151
"128" => "Le groupe a été supprimé",
152+
"129" => "Vider le cache",
153+
"130" => "Vider le cache des plugins peut être nécessaire pour voir les nouveaux plugins apparaître dans la liste.",
154+
"131" => "Le cache des plugins a été supprimé!",
155+
"132" => "Le cache des plugins a été supprimé, mais vous êtes actuellement en mode SKIP_CACHE (voir bootstrap_context.php).",
152156
);

core/src/plugins/access.ajxp_conf/i18n/hu.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,9 @@
151151
"126" => "Are you sure that you want to delete the selected element(s)?",
152152
"127" => "Warning, please do not use special characters, user would be created with login id '%s'",
153153
"128" => "Successfully deleted group",
154+
"129" => "Refresh plugins cache",
155+
"130" => "Clear plugins cache, can be necessary to see new plugins appear in the list.",
156+
"131" => "Plugins cache files were deleted succesfully!",
157+
"132" => "Cache cleared, but you are currently running in SKIP_CACHE mode (see bootstrap_context.php).",
154158
/* END SENTENCE */
155159
);

0 commit comments

Comments
 (0)