[Rt-commit] rt branch, 4.4/spurious-timeworked-message, created. rt-4.4.1-215-gbe85a7a

Shawn Moore shawn at bestpractical.com
Fri Dec 30 17:08:11 EST 2016

The branch, 4.4/spurious-timeworked-message has been created
        at  be85a7aef6e55346e681964ac281776a347e6a35 (commit)

- Log -----------------------------------------------------------------
commit be85a7aef6e55346e681964ac281776a347e6a35
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri Dec 30 21:42:34 2016 +0000

    Avoid spurious "That is already the current value" for time worked
    The mere presence of the argument (which can happen when you submit
    Modify.html after having logged time to a ticket) means RT
    unconditionally updates the TimeWorked field, which means it
    unconditionally adds "That is already the current value" to the results
    Instead, only update time worked if the value submitted is not the same
    as the current value of TimeWorked on the ticket.
    Special consideration is given to setting time worked to the value "0",
    which should adjust the time worked on the ticket to 0 rather than being
    silently ignored.
    This regression was introduced in
    1bb578722e7d0a7c57134db82b7ed801cf9d79e8; TimeWorked being an ordinary
    field in @attribs means that RT::Record::Update would skip updating that
    field because the existing value was the same as the submitted value.
    But since TimeWorked no longer uses the Update codepath, there was no
    provision to skip it when it's submitted unchanged.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index add8432..0f16257 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2960,7 +2960,7 @@ sub ProcessTicketBasics {
         ARGSRef       => $ARGSRef,
-    if ( $ARGSRef->{'TimeWorked'} ) {
+    if ( defined($ARGSRef->{'TimeWorked'}) && ($ARGSRef->{'TimeWorked'} || 0) != $TicketObj->TimeWorked ) {
         my ( $val, $msg, $txn ) = $TicketObj->SetTimeWorked( $ARGSRef->{'TimeWorked'} );
         push( @results, $msg );
         $txn->UpdateCustomFields( %$ARGSRef) if $txn;
diff --git a/t/web/ticket_modify_all.t b/t/web/ticket_modify_all.t
index 2f6e92d..22470df 100644
--- a/t/web/ticket_modify_all.t
+++ b/t/web/ticket_modify_all.t
@@ -31,10 +31,15 @@ $m->get_ok($url . '/Ticket/ModifyAll.html?id=' . $ticket->id);
 $m->field(Owner => 'root');
+$m->field(TimeWorked => 120);
+$m->text_contains('Owner changed from Nobody to root');
+$m->text_contains('Worked 2 hours (120 minutes)');
 is($m->value('Owner'), 'root', 'owner was successfully changed to root');
+is($m->value('TimeWorked'), 120, 'logged 2 hours');
 $m->get_ok($url . "/Ticket/ModifyAll.html?id=" . $ticket->id);
@@ -97,5 +102,17 @@ $m->text_contains(
     'no duplicate watchers',
+$m->get( $url . '/Ticket/ModifyAll.html?id=' . $ticket->id );
+$m->content_lacks("That is already the current value", 'no spurious messages');
+$m->field(TimeWorked => 0);
+$m->text_contains('Adjusted time worked by -120 minutes');
+is($m->value('TimeWorked'), "", 'no time worked');
 undef $m;


More information about the rt-commit mailing list