[event_spartacus] Don't cache wrong plugin list.

Declaring $pluginlist as static will cache the
database query results and always return the same
list of plugins - no matter which type is queried
(sidebar or event).

This cache must be busted if another type of
plugins is queried.

Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
Thomas Hochstein 2019-08-10 22:02:36 +02:00
parent 5abbf1c32a
commit ae3f768bb7
2 changed files with 14 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2.37.6:
-------
* Fix wrong caching of plugin lists regardless of type.
2.37.5:
-------
* Fix missing reset to default after dropping netmirror.

View File

@ -27,7 +27,7 @@ class serendipity_event_spartacus extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_SPARTACUS_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '2.37.5');
$propbag->add('version', '2.37.6');
$propbag->add('requirements', array(
'serendipity' => '1.6',
));
@ -711,6 +711,13 @@ class serendipity_event_spartacus extends serendipity_event
{
global $serendipity;
static $pluginlist = null;
static $cachedtype = null;
if (isset($cachedtype) && $cachedtype != $type) {
// bust cache if called with other type
$pluginlist = null;
$cachedtype = $type;
}
if ($pluginlist === null) {
$pluginlist = array();
@ -736,6 +743,8 @@ class serendipity_event_spartacus extends serendipity_event
}
}
}
// save type of cached pluginlist
$cachedtype = $type;
return $pluginlist;
}