[Rt-commit] r20033 - rt/3.8/trunk/lib/RT

falcone at bestpractical.com falcone at bestpractical.com
Fri Jun 19 15:21:13 EDT 2009


Author: falcone
Date: Fri Jun 19 15:21:13 2009
New Revision: 20033

Modified:
   rt/3.8/trunk/lib/RT/CustomFieldValue_Overlay.pm

Log:
Delete Categories when we delete CFVs

We used to leave orphaned Attributes after a CustomFieldValue
was deleted.  Make sure we remove cruft from the Attributes table.

Modified: rt/3.8/trunk/lib/RT/CustomFieldValue_Overlay.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/CustomFieldValue_Overlay.pm	(original)
+++ rt/3.8/trunk/lib/RT/CustomFieldValue_Overlay.pm	Fri Jun 19 15:21:13 2009
@@ -142,4 +142,35 @@
     return defined $_[1] && length $_[1];
 };
 
+=head2 DeleteCategory
+
+Deletes the category associated with this value
+Returns -1 if there is no Category
+
+=cut
+
+sub DeleteCategory {
+    my $self = shift;
+    my $attr = $self->FirstAttribute('Category') or return (-1,'No Category Set');
+    return $attr->Delete;
+}
+
+=head2 Delete
+
+Make sure we delete our Category when we're deleted
+
+=cut
+
+sub Delete {
+    my $self = shift;
+
+    my ($result, $msg) = $self->DeleteCategory;
+
+    unless ($result) {
+        return ($result, $msg);
+    }
+
+    return $self->SUPER::Delete(@_);
+}
+
 1;


More information about the Rt-commit mailing list