[Rt-commit] rtir branch 5.0/atomic-changes-on-edit-page created. 5.0.1-60-gd48ff10c

BPS Git Server git at git.bestpractical.com
Fri Feb 18 19:49:59 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rtir".

The branch, 5.0/atomic-changes-on-edit-page has been created
        at  d48ff10cd5014f6b4abd8d69bbaf5518e95b674d (commit)

- Log -----------------------------------------------------------------
commit d48ff10cd5014f6b4abd8d69bbaf5518e95b674d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Feb 18 03:24:48 2022 +0800

    Make ticket updates atomic on edit page
    
    This is consistent with RT modify page(see 8862bd94d3). Besides the
    atomic benefit, this also tweaks the run order of batch scrips, so they
    can run after all other changes, which is useful to make some final
    updates.  E.g. a batch scrip can set a custom field on owner change
    without worrying about it getting reset by empty inputs.

diff --git a/html/RTIR/Edit.html b/html/RTIR/Edit.html
index 4c8e5324..6fe3cb5b 100644
--- a/html/RTIR/Edit.html
+++ b/html/RTIR/Edit.html
@@ -254,44 +254,48 @@ if ( $SaveChanges ) {
     );
 }
 
-# XXX: process even if checks failed as EditPeople doesn't preserve state
 if ( $SaveChanges && !$skip_update && !$OnlySearchForPeople ) {
-
-    # XXX: ProcessTicketWatchers doesn't like WatcherTypeEmailX with
-    # empty WatcherAddressEmailX
-    delete $ARGS{"WatcherTypeEmail$_"} foreach
-        grep !$ARGS{"WatcherAddressEmail$_"} && $ARGS{"WatcherTypeEmail$_"},
-        1..3
-    ;
-
-    push @results, ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS );
-}
-
-if ( $SaveChanges && !$skip_update && !$checks_failure && !$OnlySearchForPeople ) {
-    my $strict_acl = RT->Config->Set( StrictLinkACL => 0 );
-    push @results, ProcessTicketLinks(    TicketObj => $Ticket, ARGSRef => \%ARGS );
-    RT->Config->Set( StrictLinkACL => $strict_acl );
-
-    push @results, ProcessTicketDates(    TicketObj => $Ticket, ARGSRef => \%ARGS );
-
-    push @results, ProcessUpdateMessage(  TicketObj => $Ticket, ARGSRef=>\%ARGS );
-    push @results, ProcessTicketBasics(   TicketObj => $Ticket, ARGSRef => \%ARGS );
-
-    push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS );
-
-    $m->callback(
-        CallbackName => 'AfterProcessing',
-        ARGSRef => \%ARGS, Ticket => $Ticket, results => \@results,
-    );
-
-    MaybeRedirectForResults(
-        Actions   => \@results,
-        Path      => RT->Config->Get('DisplayAfterEdit', $session{'CurrentUser'})
-        ? RT::IR->HREFTo("Display.html", IncludeWebPath => 0)
-        : RT::IR->HREFTo("Edit.html", IncludeWebPath => 0)
-        ,
-        Arguments => { id => $id },
+    $Ticket->Atomic(
+        sub {
+            # XXX: process even if checks failed as EditPeople doesn't preserve state
+            # XXX: ProcessTicketWatchers doesn't like WatcherTypeEmailX with
+            # empty WatcherAddressEmailX
+            delete $ARGS{"WatcherTypeEmail$_"} foreach
+                grep !$ARGS{"WatcherAddressEmail$_"} && $ARGS{"WatcherTypeEmail$_"},
+                1 .. 3;
+
+            push @results, ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS );
+
+            if ( !$checks_failure ) {
+                my $strict_acl = RT->Config->Set( StrictLinkACL => 0 );
+                push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS );
+                RT->Config->Set( StrictLinkACL => $strict_acl );
+
+                push @results, ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS );
+
+                push @results, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef => \%ARGS );
+                push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
+
+                push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS );
+
+                $m->callback(
+                    CallbackName => 'AfterProcessing',
+                    ARGSRef      => \%ARGS,
+                    Ticket       => $Ticket,
+                    results      => \@results,
+                );
+            }
+        }
     );
+    if ( !$checks_failure ) {
+        MaybeRedirectForResults(
+            Actions => \@results,
+            Path    => RT->Config->Get( 'DisplayAfterEdit', $session{'CurrentUser'} )
+            ? RT::IR->HREFTo( "Display.html", IncludeWebPath => 0 )
+            : RT::IR->HREFTo( "Edit.html",    IncludeWebPath => 0 ),
+            Arguments => { id => $id },
+        );
+    }
 }
 
 my $name = RT::IR::TicketType( Ticket => $Ticket );

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


hooks/post-receive
-- 
rtir


More information about the rt-commit mailing list