@@ -409,9 +409,7 @@ public function childrenQuery($node = null, $direct = false, $sortByField = null
409
409
*/
410
410
public function children ($ node = null , $ direct = false , $ sortByField = null , $ direction = 'ASC ' , $ includeNode = false )
411
411
{
412
- $ q = $ this ->childrenQuery ($ node , $ direct , $ sortByField , $ direction , $ includeNode );
413
-
414
- return $ q ->getResult ();
412
+ return $ this ->childrenQuery ($ node , $ direct , $ sortByField , $ direction , $ includeNode )->getResult ();
415
413
}
416
414
417
415
public function getChildrenQueryBuilder ($ node = null , $ direct = false , $ sortByField = null , $ direction = 'ASC ' , $ includeNode = false )
@@ -802,7 +800,7 @@ public function removeFromTree($node)
802
800
803
801
$ qb ->andWhere ($ qb ->expr ()->eq ('node. ' .$ config ['parent ' ], ':pid ' ));
804
802
$ qb ->setParameter ('pid ' , $ nodeId );
805
- $ nodes = $ qb ->getQuery ()->getArrayResult ( );
803
+ $ nodes = $ qb ->getQuery ()->toIterable ([], Query:: HYDRATE_ARRAY );
806
804
807
805
// go through each of the node's children
808
806
foreach ($ nodes as $ newRoot ) {
@@ -1235,13 +1233,17 @@ private function verifyTree(array &$errors, ?object $root = null): void
1235
1233
$ qb ->andWhere ($ qb ->expr ()->eq ('node. ' .$ config ['root ' ], ':rid ' ));
1236
1234
$ qb ->setParameter ('rid ' , $ rootId );
1237
1235
}
1238
- $ nodes = $ qb ->getQuery ()->getArrayResult ();
1239
- if ([] !== $ nodes ) {
1240
- foreach ($ nodes as $ node ) {
1241
- $ errors [] = "node [ {$ node [$ identifier ]}] has missing parent " .($ root ? ' on tree root: ' .$ rootId : '' );
1242
- }
1243
1236
1244
- return ; // loading broken relation can cause infinite loop
1237
+ $ areMissingParents = false ;
1238
+
1239
+ foreach ($ qb ->getQuery ()->toIterable ([], Query::HYDRATE_ARRAY ) as $ node ) {
1240
+ $ areMissingParents = true ;
1241
+ $ errors [] = "node [ {$ node [$ identifier ]}] has missing parent " .($ root ? ' on tree root: ' .$ rootId : '' );
1242
+ }
1243
+
1244
+ // loading broken relation can cause infinite loop
1245
+ if ($ areMissingParents ) {
1246
+ return ;
1245
1247
}
1246
1248
1247
1249
// check for nodes that have a right value lower than the left
@@ -1272,9 +1274,8 @@ private function verifyTree(array &$errors, ?object $root = null): void
1272
1274
$ qb ->andWhere ($ qb ->expr ()->eq ('node. ' .$ config ['root ' ], ':rid ' ));
1273
1275
$ qb ->setParameter ('rid ' , $ rootId );
1274
1276
}
1275
- $ nodes = $ qb ->getQuery ()->getResult (Query::HYDRATE_OBJECT );
1276
1277
1277
- foreach ($ nodes as $ node ) {
1278
+ foreach ($ qb -> getQuery ()-> toIterable () as $ node ) {
1278
1279
$ right = $ meta ->getReflectionProperty ($ config ['right ' ])->getValue ($ node );
1279
1280
$ left = $ meta ->getReflectionProperty ($ config ['left ' ])->getValue ($ node );
1280
1281
$ id = $ meta ->getReflectionProperty ($ identifier )->getValue ($ node );
0 commit comments