Skip to content

Commit

Permalink
Merge #10795 into 3.7.x. Fixes #10795
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed Aug 18, 2016
2 parents bdd641a + 7b06aec commit 3d744c0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
42 changes: 23 additions & 19 deletions libraries/cms/plugin/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,27 +290,31 @@ protected static function load()
return static::$plugins;
}

$user = JFactory::getUser();
$cache = JFactory::getCache('com_plugins', '');
$levels = implode(',', JFactory::getUser()->getAuthorisedViewLevels());

$levels = implode(',', $user->getAuthorisedViewLevels());
/** @var JCacheControllerCallback $cache */
$cache = JFactory::getCache('com_plugins', 'callback');

if (!(static::$plugins = $cache->get($levels)))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('folder AS type, element AS name, params')
->from('#__extensions')
->where('enabled = 1')
->where('type =' . $db->quote('plugin'))
->where('state IN (0,1)')
->where('access IN (' . $levels . ')')
->order('ordering');

static::$plugins = $db->setQuery($query)->loadObjectList();

$cache->store(static::$plugins, $levels);
}
static::$plugins = $cache->get(
function () use ($levels)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select(array($db->quoteName('folder', 'type'), $db->quoteName('element', 'name'), $db->quoteName('params')))
->from('#__extensions')
->where('enabled = 1')
->where('type = ' . $db->quote('plugin'))
->where('state IN (0,1)')
->where('access IN (' . $levels . ')')
->order('ordering');
$db->setQuery($query);

return $db->loadObjectList();
},
array(),
md5($levels),
false
);

return static::$plugins;
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/joomla/cache/controller/callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function call()
public function get($callback, $args = array(), $id = false, $wrkarounds = false, $woptions = array())
{
// Normalize callback
if (is_array($callback))
if (is_array($callback) || is_callable($callback))
{
// We have a standard php callback array -- do nothing
}
Expand Down Expand Up @@ -139,7 +139,7 @@ public function get($callback, $args = array(), $id = false, $wrkarounds = false
if (method_exists($document, 'getHeadData'))
{
$coptions['headerbefore'] = $document->getHeadData();
}
}
}
else
{
Expand Down

0 comments on commit 3d744c0

Please sign in to comment.