1
0

Save remote plugin source when merging remote / local data.

When installing / updating plugins, plugin data
is fetched from Spartacus first; those plugins
will habe "Spartacus" as "pluginlocation".

Later on, information about installed plugins
is fetched from cache / database, overwriting
the previously fetched data for all installed
plugins. After that, "pluginlocation" is
"local" even for plugins that live on
Spartacus if they have been installed.

So we save "pluginlocation" data to a new
"pluginsource" field before merging /
overwriting so we can detect plugins that
are available on Spartacus.

This data is present in plugins.inc.tpl
and can be used there.

Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
Thomas Hochstein
2020-03-23 22:28:43 +01:00
parent 04a3d34176
commit 8c702769e4

View File

@ -155,6 +155,7 @@ if (isset($serendipity['GET']['plugin_to_conf'])) {
$data['adminAction'] = 'addnew';
$data['type'] = $serendipity['GET']['type'];
# get plugin data from Spartacus
$foreignPlugins = $pluginstack = $errorstack = array();
serendipity_plugin_api::hook_event('backend_plugins_fetchlist', $foreignPlugins);
$pluginstack = array_merge((array)$foreignPlugins['pluginstack'], $pluginstack);
@ -173,6 +174,7 @@ if (isset($serendipity['GET']['plugin_to_conf'])) {
$foreignPlugins = array_merge($foreignPlugins, $foreignPluginsTemp);
}
# load cached / installed plugin data
$plugins = serendipity_plugin_api::get_installed_plugins();
$classes = serendipity_plugin_api::enum_plugin_classes(($serendipity['GET']['type'] === 'event'));
if ($serendipity['GET']['only_group'] == 'UPGRADE') {
@ -237,7 +239,15 @@ if (isset($serendipity['GET']['plugin_to_conf'])) {
$props['local_documentation'] = 'plugins/' . $props['pluginPath'] . '/README';
}
}
# if data for this plugin has been fetched from Spartacus:
# add location ("Spartacus") as source field to cached / installe plugin data
if (array_key_exists($class_data['true_name'], $pluginstack)) {
$props['pluginsource'] = $pluginstack[$class_data['true_name']]['pluginlocation'];
}
# save cached / installed plugin data
# (overwriting data that may have been fetched from Spartacus)
$pluginstack[$class_data['true_name']] = $props;
} else {
// False is returned if a plugin could not be instantiated