Skip to content

Commit

Permalink
Optimizing JComponentHelper::getComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackwar committed Nov 16, 2014
1 parent 069de6c commit 94f3fbe
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions libraries/cms/component/helper.php
Expand Up @@ -48,14 +48,21 @@ public static function getComponent($option, $strict = false)
{
$result = new stdClass;
$result->enabled = $strict ? false : true;
$result->params = new Registry;
$result->params = new JRegistry;
}
}
else
{
$result = static::$components[$option];
}

if (is_string($result->params))
{
$temp = new JRegistry;
$temp->loadString(static::$components[$option]->params);
static::$components[$option]->params = $temp;
}

return $result;
}

Expand Down Expand Up @@ -406,15 +413,14 @@ protected static function load($option)
$query = $db->getQuery(true)
->select('extension_id AS id, element AS "option", params, enabled')
->from('#__extensions')
->where($db->quoteName('type') . ' = ' . $db->quote('component'))
->where($db->quoteName('element') . ' = ' . $db->quote($option));
->where($db->quoteName('type') . ' = ' . $db->quote('component'));
$db->setQuery($query);

$cache = JFactory::getCache('_system', 'callback');

try
{
static::$components[$option] = $cache->get(array($db, 'loadObject'), null, $option, false);
static::$components = $cache->get(array($db, 'loadObjectList'), array('option'), $option, false);
}
catch (RuntimeException $e)
{
Expand All @@ -433,14 +439,6 @@ protected static function load($option)
return false;
}

// Convert the params to an object.
if (is_string(static::$components[$option]->params))
{
$temp = new Registry;
$temp->loadString(static::$components[$option]->params);
static::$components[$option]->params = $temp;
}

return true;
}
}

0 comments on commit 94f3fbe

Please sign in to comment.