mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
fixes #4761, tree behavior parameter array merge logic incorrect
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7056 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
a89feed085
commit
4bafc397f9
2 changed files with 16 additions and 11 deletions
|
@ -202,7 +202,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*/
|
*/
|
||||||
function childcount(&$model, $id = null, $direct = false) {
|
function childcount(&$model, $id = null, $direct = false) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge($id, array('id' => null)));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
if ($id === null && $model->id) {
|
if ($id === null && $model->id) {
|
||||||
$id = $model->id;
|
$id = $model->id;
|
||||||
|
@ -243,7 +243,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*/
|
*/
|
||||||
function children(&$model, $id = null, $direct = false, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) {
|
function children(&$model, $id = null, $direct = false, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge($id, array('id' => null)));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
$overrideRecursive = $recursive;
|
$overrideRecursive = $recursive;
|
||||||
if ($id === null && $model->id) {
|
if ($id === null && $model->id) {
|
||||||
|
@ -289,9 +289,6 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function generatetreelist(&$model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
|
function generatetreelist(&$model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
|
||||||
if (is_array($conditions)) {
|
|
||||||
extract (array_merge($conditions, array('conditions' => null)));
|
|
||||||
}
|
|
||||||
$overrideRecursive = $recursive;
|
$overrideRecursive = $recursive;
|
||||||
extract($this->settings[$model->alias]);
|
extract($this->settings[$model->alias]);
|
||||||
if (!is_null($overrideRecursive)) {
|
if (!is_null($overrideRecursive)) {
|
||||||
|
@ -347,7 +344,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*/
|
*/
|
||||||
function getparentnode(&$model, $id = null, $fields = null, $recursive = null) {
|
function getparentnode(&$model, $id = null, $fields = null, $recursive = null) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge($id, array('id' => null)));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
$overrideRecursive = $recursive;
|
$overrideRecursive = $recursive;
|
||||||
if (empty ($id)) {
|
if (empty ($id)) {
|
||||||
|
@ -380,7 +377,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*/
|
*/
|
||||||
function getpath(&$model, $id = null, $fields = null, $recursive = null) {
|
function getpath(&$model, $id = null, $fields = null, $recursive = null) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge($id, array('id' => null)));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
$overrideRecursive = $recursive;
|
$overrideRecursive = $recursive;
|
||||||
if (empty ($id)) {
|
if (empty ($id)) {
|
||||||
|
@ -416,7 +413,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*/
|
*/
|
||||||
function movedown(&$model, $id = null, $number = 1) {
|
function movedown(&$model, $id = null, $number = 1) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge($id, array('id' => null)));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
if (!$number) {
|
if (!$number) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -470,7 +467,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*/
|
*/
|
||||||
function moveup(&$model, $id = null, $number = 1) {
|
function moveup(&$model, $id = null, $number = 1) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge($id, array('id' => null)));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
if (!$number) {
|
if (!$number) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -533,7 +530,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*/
|
*/
|
||||||
function recover(&$model, $mode = 'parent', $missingParentAction = null) {
|
function recover(&$model, $mode = 'parent', $missingParentAction = null) {
|
||||||
if (is_array($mode)) {
|
if (is_array($mode)) {
|
||||||
extract (array_merge($mode, array('mode' => 'parent')));
|
extract (array_merge(array('mode' => 'parent'), $mode));
|
||||||
}
|
}
|
||||||
extract($this->settings[$model->alias]);
|
extract($this->settings[$model->alias]);
|
||||||
$model->recursive = $recursive;
|
$model->recursive = $recursive;
|
||||||
|
@ -637,7 +634,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*/
|
*/
|
||||||
function removefromtree(&$model, $id = null, $delete = false) {
|
function removefromtree(&$model, $id = null, $delete = false) {
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
extract (array_merge($id, array('id' => null)));
|
extract (array_merge(array('id' => null), $id));
|
||||||
}
|
}
|
||||||
extract($this->settings[$model->alias]);
|
extract($this->settings[$model->alias]);
|
||||||
|
|
||||||
|
|
|
@ -958,5 +958,13 @@ class NumberTreeCase extends CakeTestCase {
|
||||||
$this->assertEqual(Set::extract('/Ad/id', $result), array(5, 6));
|
$this->assertEqual(Set::extract('/Ad/id', $result), array(5, 6));
|
||||||
$this->assertEqual(Set::extract('/Campaign/id', $result), array(2, 2));
|
$this->assertEqual(Set::extract('/Campaign/id', $result), array(2, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testArraySyntax() {
|
||||||
|
$this->NumberTree =& new NumberTree();
|
||||||
|
$this->NumberTree->initialize(3, 3);
|
||||||
|
$this->assertIdentical($this->NumberTree->childcount(2), $this->NumberTree->childcount(array('id' => 2)));
|
||||||
|
$this->assertIdentical($this->NumberTree->getparentnode(2), $this->NumberTree->getparentnode(array('id' => 2)));
|
||||||
|
$this->assertIdentical($this->NumberTree->getpath(4), $this->NumberTree->getpath(array('id' => 4)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue