[1/2] testbot/lib: DBIBackend::LoadItem() must not return objects from the Collection scope.

Francois Gouget fgouget at codeweavers.com
Thu Jun 12 03:14:41 CDT 2014


Such checks belong to the higher levels.
Doing them in LoadItem() interferes with Collection::Validate(), causing it to think new items are already present in the database whenever they don't have Sequence keys.
---

This should fix approving new accounts!

 testbot/lib/ObjectModel/DBIBackEnd.pm | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/testbot/lib/ObjectModel/DBIBackEnd.pm b/testbot/lib/ObjectModel/DBIBackEnd.pm
index c89fa64..06b139d 100644
--- a/testbot/lib/ObjectModel/DBIBackEnd.pm
+++ b/testbot/lib/ObjectModel/DBIBackEnd.pm
@@ -253,14 +253,24 @@ sub LoadCollection
   $Statement->finish();
 }
 
+=pod
+=over 12
+
+=item C<LoadItem()>
+
+Loads the specified Item from the database and adds it to the Collection.
+By design this method will not check if the Item is already present in the
+Collection scope. Such checks belong in the higher levels. This method will
+however put the Item in the Collection's scope.
+
+=back
+=cut
+
 sub LoadItem
 {
   my $self = shift;
   my ($Collection, $RequestedKey) = @_;
 
-  my $Item = $Collection->GetScopeItem($RequestedKey);
-  return $Item if (defined $Item);
-
   my $Fields = $self->BuildFieldList($Collection->GetPropertyDescriptors());
 
   my $Where = "";
@@ -283,7 +293,7 @@ sub LoadItem
   my $Statement = $self->GetDb()->prepare($Query);
   $Statement->execute(@Data);
 
-  $Item = undef;
+  my $Item;
   if (my $Row = $Statement->fetchrow_hashref())
   {
     $Item = $Collection->CreateItem();
-- 
2.0.0




More information about the wine-patches mailing list