From ad678e39888dad23b653268d20ca11530eb2dfda Mon Sep 17 00:00:00 2001 From: Anatoliy Petrovskiy Date: Mon, 23 Jun 2014 13:51:52 +0300 Subject: [PATCH] improving acl perfomance --- app/Config/Schema/db_acl.php | 8 ++++---- lib/Cake/Model/AclNode.php | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Config/Schema/db_acl.php b/app/Config/Schema/db_acl.php index 055280f9a..290a066cd 100644 --- a/app/Config/Schema/db_acl.php +++ b/app/Config/Schema/db_acl.php @@ -58,8 +58,8 @@ class DbAclSchema extends CakeSchema { '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 @@ class DbAclSchema extends CakeSchema { '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) ) ); diff --git a/lib/Cake/Model/AclNode.php b/lib/Cake/Model/AclNode.php index de7356605..63c29f04d 100644 --- a/lib/Cake/Model/AclNode.php +++ b/lib/Cake/Model/AclNode.php @@ -90,7 +90,7 @@ class AclNode extends Model { 'order' => $db->name("{$type}.lft") . ' DESC' ); - $conditions_after_join = array(); + $conditionsAfterJoin = array(); foreach ($path as $i => $alias) { $j = $i - 1; @@ -105,9 +105,9 @@ class AclNode extends Model { ); // 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"), @@ -115,7 +115,7 @@ class AclNode extends Model { ); } - $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);