Author: dr
Date: Wed Aug 15 10:52:23 2007
New Revision: 5918

Log:
- Fixed an issue with empty lists of nodes to which to fetch data for.

Modified:
    trunk/Tree/tests/tree_node_list_iterator.php
    trunk/TreeDatabaseTiein/src/stores/db_external.php
    trunk/TreeDatabaseTiein/tests/db_tree.php

Modified: trunk/Tree/tests/tree_node_list_iterator.php
==============================================================================
--- trunk/Tree/tests/tree_node_list_iterator.php [iso-8859-1] (original)
+++ trunk/Tree/tests/tree_node_list_iterator.php [iso-8859-1] Wed Aug 15 
10:52:23 2007
@@ -24,6 +24,16 @@
         $list = new ezcTreeNodeList;
 
         foreach ( new ezcTreeNodeListIterator( $this->tree, $list ) as $key => 
$node )
+        {
+            self::fail( "The list is not empty." );
+        }
+    }
+
+    public function testEmptyListPreFetch()
+    {
+        $list = new ezcTreeNodeList;
+
+        foreach ( new ezcTreeNodeListIterator( $this->tree, $list, true ) as 
$key => $node )
         {
             self::fail( "The list is not empty." );
         }

Modified: trunk/TreeDatabaseTiein/src/stores/db_external.php
==============================================================================
--- trunk/TreeDatabaseTiein/src/stores/db_external.php [iso-8859-1] (original)
+++ trunk/TreeDatabaseTiein/src/stores/db_external.php [iso-8859-1] Wed Aug 15 
10:52:23 2007
@@ -144,7 +144,7 @@
         $id = $node->id;
         $q->select( '*' )
           ->from( $db->quoteIdentifier( $this->table ) )
-          ->where( $q->expr->eq( $db->quoteIdentifier( $this->idField ), $id ) 
);
+          ->where( $q->expr->eq( $db->quoteIdentifier( $this->idField ), 
$q->bindValue( $id ) ) );
         $s = $q->prepare();
         $s->execute();
 
@@ -173,11 +173,14 @@
                 $nodeIdsToFetch[] = $node->id;
             }
         }
+        if ( count( $nodeIdsToFetch ) === 0 )
+        {
+            return;
+        }
 
         $db = $this->dbHandler;
         $q = $db->createSelectQuery();
 
-        $id = $node->id;
         $q->select( '*' )
           ->from( $db->quoteIdentifier( $this->table ) )
           ->where( $q->expr->in( $db->quoteIdentifier( $this->idField ), 
$nodeIdsToFetch ) );

Modified: trunk/TreeDatabaseTiein/tests/db_tree.php
==============================================================================
--- trunk/TreeDatabaseTiein/tests/db_tree.php [iso-8859-1] (original)
+++ trunk/TreeDatabaseTiein/tests/db_tree.php [iso-8859-1] Wed Aug 15 10:52:23 
2007
@@ -253,6 +253,17 @@
         $haakon = $tree->fetchNodeById( 2 );
         self::assertEquals( array( 'name' => 'Haakon', 'born' => '1983' ), 
$haakon->data );
     }
+
+    public function testNodeListIteratorEmptyList()
+    {
+        $tree = $this->setUpEmptyTestTree();
+        $list = new ezcTreeNodeList;
+
+        foreach ( new ezcTreeNodeListIterator( $tree, $list, true ) as $key => 
$node )
+        {
+            self::fail( "The list is not empty." );
+        }
+    }
 }
 
 ?>


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to