Index: /branches/release-38/lib/MT/Object.pm
===================================================================
--- /branches/release-38/lib/MT/Object.pm (revision 2389)
+++ /branches/release-38/lib/MT/Object.pm (revision 2390)
@@ -698,4 +698,5 @@
     if (!ref $obj) {
         $obj->remove_meta( @args ) if $obj->has_meta;
+        $obj->remove_scores( @args ) if $obj->isa('MT::Scorable');
         return $obj->driver->direct_remove($obj, @args);
     } else {
@@ -987,4 +988,5 @@
         my $meta_id = $obj->datasource . '_id';
         my $offset = 0;
+        $args ||= {};
         $args->{fetchonly} = [ 'id' ];
         $args->{join} = [ $mpkg, $meta_id ];
@@ -1005,5 +1007,36 @@
             }
         }
-    }
+        return 1;
+    }
+}
+
+sub remove_scores {
+    my $class = shift;
+    require MT::ObjectScore;
+    my ($terms, $args) = @_;
+    $args = { %$args } if $args; # copy so we can alter
+    my $offset = 0;
+    $args ||= {};
+    $args->{fetchonly} = [ 'id' ];
+    $args->{join} = [ 'MT::ObjectScore', 'object_id', {
+        object_ds => $class->datasource } ];
+    $args->{no_triggers} = 1;
+    $args->{limit} = 50;
+    while ( $offset >= 0 ) {
+        $args->{offset} = $offset;
+        if (my @list = $class->load( $terms, $args )) {
+            my @ids = map { $_->id } @list;
+            MT::ObjectScore->driver->direct_remove( 'MT::ObjectScore', {
+                object_ds => $class->datasource, 'object_id' => \@ids });
+            if ( scalar @list == 50 ) {
+                $offset += 50;
+            } else {
+                $offset = -1; # break loop
+            }
+        } else {
+            $offset = -1;
+        }
+    }
+    return 1;
 }
 
