diff --git a/cake/libs/controller/components/dbacl/db_acl.php b/cake/libs/controller/components/dbacl/db_acl.php index 3f99ea924..1d791d05c 100644 --- a/cake/libs/controller/components/dbacl/db_acl.php +++ b/cake/libs/controller/components/dbacl/db_acl.php @@ -270,11 +270,11 @@ class DB_ACL extends AclBase { } return array( - 'aro' => $obj['Aro']['id'], - 'aco' => $obj['Aco']['id'], + 'aro' => Set::extract($obj, 'Aro.0.Aro.id'), + 'aco' => Set::extract($obj, 'Aco.0.Aco.id'), 'link' => $Link->findAll(array( - 'Permission.aro_id' => $obj['Aro']['id'], - 'Permission.aco_id' => $obj['Aco']['id'] + 'Permission.aro_id' => Set::extract($obj, 'Aro.0.Aro.id'), + 'Permission.aco_id' => Set::extract($obj, 'Aco.0.Aco.id') )) ); } diff --git a/cake/libs/controller/components/dbacl/models/aclnode.php b/cake/libs/controller/components/dbacl/models/aclnode.php index 634551e6d..0a4cd8ec2 100644 --- a/cake/libs/controller/components/dbacl/models/aclnode.php +++ b/cake/libs/controller/components/dbacl/models/aclnode.php @@ -121,6 +121,7 @@ class AclNode extends AppModel { $result = $this->query("{$query} " . $db->conditions($ref) ." ORDER BY {$type}.lft DESC"); if (!$result) { + pr($this->trace()); trigger_error("AclNode::node() - Couldn't find {$type} node identified by \"" . print_r($ref, true) . "\"", E_USER_WARNING); } } diff --git a/cake/libs/model/behaviors/acl.php b/cake/libs/model/behaviors/acl.php index d686d8afc..04631f226 100644 --- a/cake/libs/model/behaviors/acl.php +++ b/cake/libs/model/behaviors/acl.php @@ -95,7 +95,12 @@ class AclBehavior extends ModelBehavior { function afterSave(&$model, $created) { if ($created) { $type = $this->__typeMaps[low($this->settings[$model->name]['type'])]; - $parent = $this->node($model, $model->parentNode()); + $parent = $model->parentNode(); + if (!empty($parent)) { + $parent = $this->node($model, $parent); + } else { + $parent = null; + } $model->{$type}->create(); $model->{$type}->save(array( diff --git a/cake/libs/model/behaviors/tree.php b/cake/libs/model/behaviors/tree.php index 379dd6324..60296edf9 100644 --- a/cake/libs/model/behaviors/tree.php +++ b/cake/libs/model/behaviors/tree.php @@ -61,6 +61,9 @@ class TreeBehavior extends ModelBehavior { */ function setparent(&$model, $parent_id = null) { extract($this->settings[$model->name]); + if ($parent_id == $model->field($parent)) { + return true; + } list($node) = array_values($model->find(array($model->escapeField() => $model->id), array($model->primaryKey, $parent, $left, $right), null, -1)); list($edge) = array_values($model->find(null, "MAX({$right}) AS {$right}", null, -1)); $edge = ife(empty($edge[$right]), 0, $edge[$right]); // Is the tree empty? diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 318121fe0..4198c135b 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -154,12 +154,14 @@ class DboMysql extends DboSource { if (empty($tables)) { $result = $this->query('SHOW TABLES'); $key1 = $key2 = null; - foreach ($result as $item) { - if (empty($key1)) { - $key1 = key($item); - $key2 = key($item[$key1]); + if ($result) { + foreach ($result as $item) { + if (empty($key1)) { + $key1 = key($item); + $key2 = key($item[$key1]); + } + $tables[] = $item[$key1][$key2]; } - $tables[] = $item[$key1][$key2]; } }