Commit 0223b172 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixed TODO in class_objects.inc to cache parsed filters and avoid parsing them several times

parent 0c9de786
......@@ -233,7 +233,7 @@ class listing
'image' => $i['icon'],
'category' => $i['aclCategory'],
'class' => $i['mainTab'],
'filter' => ldapFilter::parse($i['filter']),
'filter' => objects::getFilterObject($type),
'nameAttr' => $i['nameAttr'],
);
}
......
......@@ -247,12 +247,27 @@ class objects
static function isOfType ($attrs, $type)
{
//TODO : cache ldapFilter objects?
$infos = static::infos($type);
$filter = ldapFilter::parse($infos['filter']);
$filter = static::getFilterObject($type);
return $filter($attrs);
}
/* This method allows to cache parsed filter in filterObject key in objectTypes */
static function getFilterObject ($type)
{
global $config;
if (!isset($config->data['OBJECTS'][strtoupper($type)])) {
throw new NonExistingObjectTypeException('Non-existing type "'.$type.'"');
}
$infos =& $config->data['OBJECTS'][strtoupper($type)];
if (!isset($infos['filterObject'])) {
$infos['filterObject'] = ldapFilter::parse($infos['filter']);
}
return $infos['filterObject'];
}
static function types ()
{
global $config;
......
......@@ -299,13 +299,14 @@ class simpleManagement
$i['icon'] = '';
}
$filterObject = objects::getFilterObject($object);
$this->headpage->objectTypes[$object] =
array(
'label' => $i['name'],
'category' => $i['aclCategory'],
'class' => $i['mainTab'],
'image' => $i['icon'],
'filter' => ldapFilter::parse($i['filter']),
'filter' => $filterObject,
'nameAttr' => $i['nameAttr'],
);
if (!$this->skipTemplates) {
......@@ -320,7 +321,7 @@ class simpleManagement
'&',
array(
new ldapFilterLeaf('objectClass', '=', 'fdTemplate'),
fdTemplateFilter(ldapFilter::parse($i['filter'])),
fdTemplateFilter($filterObject),
)
),
'nameAttr' => $i['nameAttr'],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment