cvs: pear /DB_NestedSet NestedSet.php /DB_NestedSet/tests/NestedSet query.php
| From: | Daniel Khan | Date: | Tue, 25 Oct 2005 23:16:21 +0000 |
| Subject: | cvs: pear /DB_NestedSet NestedSet.php /DB_NestedSet/tests/NestedSet query.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-35862@lists.php.net to get a copy of this message | ||
datenpunk Tue Oct 25 19:16:21 2005 EDT
Modified files:
/pear/DB_NestedSet NestedSet.php
/pear/DB_NestedSet/tests/NestedSet query.php
Log:
Fixed Bug #4702 Fatal error in NestedSet.php:1856 (prordersorting with secondray sort on in object
mode)
Expanded tests to catch this bug
http://cvs.php.net/diff.php/pear/DB_NestedSet/NestedSet.php?r1=1.87&r2=1.88&ty=u
Index: pear/DB_NestedSet/NestedSet.php
diff -u pear/DB_NestedSet/NestedSet.php:1.87 pear/DB_NestedSet/NestedSet.php:1.88
--- pear/DB_NestedSet/NestedSet.php:1.87 Tue Oct 25 18:09:32 2005
+++ pear/DB_NestedSet/NestedSet.php Tue Oct 25 19:16:19 2005
@@ -15,7 +15,7 @@
// | Authors: Daniel Khan <dk@webcluster.at> |
// | Jason Rust <jason@rustyparts.com> |
// +----------------------------------------------------------------------+
-// $Id: NestedSet.php,v 1.87 2005/10/25 22:09:32 datenpunk Exp $
+// $Id: NestedSet.php,v 1.88 2005/10/25 23:16:19 datenpunk Exp $
// CREDITS:
// --------
// - Thanks to Kristian Koehntopp for publishing an explanation of the Nested Set
@@ -50,7 +50,7 @@
*
* @author Daniel Khan <dk@webcluster.at>
* @package DB_NestedSet
-* @version $Revision: 1.87 $
+* @version $Revision: 1.88 $
* @access public
*/
// }}}
@@ -1856,7 +1856,12 @@
$retArray = array();
foreach($nodeSet AS $nodeID=>$node) {
- $deepArray[$node['parent']][$nodeID] = $node;
+ if(is_object($node)) {
+ $parent = $node->parent;
+ } else {
+ $parent = $node['parent'];
+ }
+ $deepArray[$parent][$nodeID] = $node;
}
$reset = true;
@@ -2090,7 +2095,7 @@
'majorversion' => $this->_majorversion,
'minorversion' => $this->_minorversion,
'version' => sprintf('%s.%s', $this->_majorversion,
$this->_minorversion),
- 'revision' => str_replace('$', '', '$Revision: 1.87
$')
+ 'revision' => str_replace('$', '', '$Revision: 1.88
$')
);
}
// }}}
@@ -2474,7 +2479,7 @@
* Generic class for node objects
*
* @autor Daniel Khan <dk@webcluster.at>;
-* @version $Revision: 1.87 $
+* @version $Revision: 1.88 $
* @package DB_NestedSet
* @access private
*/
http://cvs.php.net/diff.php/pear/DB_NestedSet/tests/NestedSet/query.php?r1=1.7&r2=1.8&ty=u
Index: pear/DB_NestedSet/tests/NestedSet/query.php
diff -u pear/DB_NestedSet/tests/NestedSet/query.php:1.7
pear/DB_NestedSet/tests/NestedSet/query.php:1.8
--- pear/DB_NestedSet/tests/NestedSet/query.php:1.7 Tue Oct 25 18:09:41 2005
+++ pear/DB_NestedSet/tests/NestedSet/query.php Tue Oct 25 19:16:21 2005
@@ -5,7 +5,7 @@
*
* @author Daniel Khan <dk@webcluster.at>
* @package DB_NestedSetTest
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
* @access public
*/
@@ -261,11 +261,27 @@
// Create a new tree
$relationTree = $this->_createSubNode($rnc, $depth, $npl);
$allnodes = $this->_NeSe->getAllNodes(true);
+
+ $test_nid = false;
foreach($relationTree AS $nid => $relations) {
$subbranch = $this->_NeSe->getSubBranch($nid, true, true, $this->addSQL);
+ if($subbranch && !$test_nid) {
+ $test_nid = $nid;
+ }
$exp_subbranch = $this->_traverseChildRelations($relationTree, $nid, true, true);
$this->assertEquals($subbranch, $exp_subbranch, 'Differs from relation
traversal result.');
}
+
+ $this->_NeSe->setSortMode(NESE_SORT_PREORDER);
+ $this->_NeSe->secondarySort = 'STRNA';
+ $res1 = $this->_NeSe->getSubBranch($test_nid, true, true, $this->addSQL);
+ $testnode1 = current($res1);
+
+ $res2 = $this->_NeSe->getSubBranch($test_nid, false, true, $this->addSQL);
+ $testnode2 = current($res2);
+
+ $this->assertEquals($testnode1['id'], $testnode2->id, 'Array content
differs from object');
+
return true;
}