Skip to content

Commit

Permalink
Put back defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Babker committed May 21, 2017
1 parent 341db17 commit dcc4102
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions libraries/cms/plugin/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,15 @@ public static function isEnabled($type, $plugin = null)
*/
public static function importPlugin($type, $plugin = null, $autocreate = true, JEventDispatcher $dispatcher = null)
{
static $loaded = array();
static $loaded = [];

// Check for the default args, if so we can optimise cheaply
$defaults = false;

if (is_null($plugin) && $autocreate == true && is_null($dispatcher))
{
$defaults = true;
}

// Ensure we have a dispatcher now so we can correctly track the loaded plugins
$dispatcher = $dispatcher ?: JEventDispatcher::getInstance();
Expand All @@ -158,7 +166,7 @@ public static function importPlugin($type, $plugin = null, $autocreate = true, J
$loaded[$dispatcherHash] = array();
}

if (!isset($loaded[$dispatcherHash][$type]))
if (!isset($loaded[$dispatcherHash][$type]) || !$defaults)
{
$results = null;

Expand All @@ -175,6 +183,12 @@ public static function importPlugin($type, $plugin = null, $autocreate = true, J
}
}

// Bail out early if we're not using default args
if (!$defaults)
{
return $results;
}

$loaded[$dispatcherHash][$type] = $results;
}

Expand Down

0 comments on commit dcc4102

Please sign in to comment.