Skip to content
Permalink
Browse files

improving acl perfomance

  • Loading branch information...
Anatoliy Petrovskiy
Anatoliy Petrovskiy committed Jun 23, 2014
1 parent bb15271 commit ad678e39888dad23b653268d20ca11530eb2dfda
Showing with 9 additions and 9 deletions.
  1. +4 −4 app/Config/Schema/db_acl.php
  2. +5 −5 lib/Cake/Model/AclNode.php
@@ -58,8 +58,8 @@ public function after($event = array()) {
'rght' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1),
'idx_acos_lft_rght' => array('column' => array('lft', 'rght'),'unique' => 0),
'idx_acos_alias' => array('column' => 'alias','unique' => 0)
'idx_acos_lft_rght' => array('column' => array('lft', 'rght'), 'unique' => 0),
'idx_acos_alias' => array('column' => 'alias', 'unique' => 0)
)
);
@@ -76,8 +76,8 @@ public function after($event = array()) {
'rght' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10),
'indexes' => array(
'PRIMARY' => array('column' => 'id','unique' => 1),
'idx_aros_lft_rght' => array('column' => array('lft', 'rght'),'unique' => 0),
'idx_aros_alias' => array('column' => 'alias','unique' => 0)
'idx_aros_lft_rght' => array('column' => array('lft', 'rght'), 'unique' => 0),
'idx_aros_alias' => array('column' => 'alias', 'unique' => 0)
)
);
@@ -90,7 +90,7 @@ public function node($ref = null) {
'order' => $db->name("{$type}.lft") . ' DESC'
);
$conditions_after_join = array();
$conditionsAfterJoin = array();
foreach ($path as $i => $alias) {
$j = $i - 1;
@@ -105,17 +105,17 @@ public function node($ref = null) {
);
// it will be better if this conditions will performs after join operation
$conditions_after_join[] = $db->name("{$type}{$j}.id") . ' = ' . $db->name("{$type}{$i}.parent_id");
$conditions_after_join[] = $db->name("{$type}{$i}.rght") . ' < ' . $db->name("{$type}{$j}.rght");
$conditions_after_join[] = $db->name("{$type}{$i}.lft") . ' > ' . $db->name("{$type}{$j}.lft");
$conditionsAfterJoin[] = $db->name("{$type}{$j}.id") . ' = ' . $db->name("{$type}{$i}.parent_id");
$conditionsAfterJoin[] = $db->name("{$type}{$i}.rght") . ' < ' . $db->name("{$type}{$j}.rght");
$conditionsAfterJoin[] = $db->name("{$type}{$i}.lft") . ' > ' . $db->name("{$type}{$j}.lft");
$queryData['conditions'] = array('or' => array(
$db->name("{$type}.lft") . ' <= ' . $db->name("{$type}0.lft") . ' AND ' . $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght"),
$db->name("{$type}.lft") . ' <= ' . $db->name("{$type}{$i}.lft") . ' AND ' . $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}{$i}.rght"))
);
}
$queryData['conditions'] = array_merge($queryData['conditions'], $conditions_after_join);
$queryData['conditions'] = array_merge($queryData['conditions'], $conditionsAfterJoin);
$result = $db->read($this, $queryData, -1);
$path = array_values($path);

0 comments on commit ad678e3

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.