[Rt-commit] rt branch, 4.2/self-merge-error, created. rt-4.2.3-88-gf889af6

Alex Vandiver alexmv at bestpractical.com
Thu Apr 24 14:50:37 EDT 2014


The branch, 4.2/self-merge-error has been created
        at  f889af66c5829f14818cf5e381cf7a2ed54cef92 (commit)

- Log -----------------------------------------------------------------
commit 2074209e2a497cd0264903a26361a21e14b9403c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Apr 24 14:48:48 2014 -0400

    Propagate return values from _MergeInto back from MergeInto
    
    Merging a ticket into itself now displays an error ("Merge
    failed. Couldn't set EffectiveId") and no logner leaves a backtrace in
    the logs (due to calling both ->Rollback _and_ ->Commit)
    
    Fixes I#26407.

diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 46c8f68..e272c8d 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1789,11 +1789,11 @@ sub MergeInto {
 
     $RT::Handle->BeginTransaction();
 
-    $self->_MergeInto( $MergeInto );
+    my ($ok, $msg) = $self->_MergeInto( $MergeInto );
 
-    $RT::Handle->Commit();
+    $RT::Handle->Commit() if $ok;
 
-    return ( 1, $self->loc("Merge Successful") );
+    return ($ok, $msg);
 }
 
 sub _MergeInto {
@@ -1933,6 +1933,8 @@ sub _MergeInto {
     $self->AddLink( Type   => 'MergedInto', Target => $MergeInto->Id());
 
     $MergeInto->_SetLastUpdated;    
+
+    return ( 1, $self->loc("Merge Successful") );
 }
 
 =head2 Merged

commit f889af66c5829f14818cf5e381cf7a2ed54cef92
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Apr 24 14:50:10 2014 -0400

    Provide a better error message for the case of self-merging

diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index e272c8d..b1f5824 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1777,6 +1777,11 @@ sub MergeInto {
         return ( 0, $self->loc("New ticket doesn't exist") );
     }
 
+    # Can't merge into yourself
+    if ( $MergeInto->Id == $self->Id ) {
+        return ( 0, $self->loc("Can't merge a ticket into itself") );
+    }
+
     # Make sure the current user can modify the new ticket.
     unless ( $MergeInto->CurrentUserHasRight('ModifyTicket') ) {
         return ( 0, $self->loc("Permission Denied") );

-----------------------------------------------------------------------


More information about the rt-commit mailing list