[Rt-commit] rt branch, 4.2-trunk, updated. rt-4.2.11-13-gd8b700c

Shawn Moore shawn at bestpractical.com
Wed Jun 3 13:55:42 EDT 2015


The branch, 4.2-trunk has been updated
       via  d8b700cba4293b3079f11bf786f9e920f9146763 (commit)
      from  fb03b4bcb0c76baee597fe5548b0cdd646d2d50b (commit)

Summary of changes:
 lib/RT/Ticket.pm | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit d8b700cba4293b3079f11bf786f9e920f9146763
Author: Christian Loos <cloos at netcologne.de>
Date:   Fri May 29 11:06:10 2015 +0200

    consistent "now" value on ticket create
    
    Without this, creating a ticket with a open status, Started is set to
    now in RT::Ticket->Create and Created is set to now in
    RT::Record->Create, where the later method call can be a second later
    (actually on the next second) than the former one. This results in
    Started is one second before Created.
    
    Avoid this by setting Created on RT::Ticket->Create.
    
    Also use a consistent now value for other date values, if they are set
    to now.

diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 6f8d2b4..9c43e1a 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -314,6 +314,10 @@ sub Create {
         unless defined $args{'Priority'};
 
     # Dates
+
+    my $Now = RT::Date->new( $self->CurrentUser );
+    $Now->SetToNow();
+
     #TODO we should see what sort of due date we're getting, rather +
     # than assuming it's in ISO format.
 
@@ -323,7 +327,7 @@ sub Create {
         $Due->Set( Format => 'ISO', Value => $args{'Due'} );
     }
     elsif ( my $due_in = $QueueObj->DefaultDueIn ) {
-        $Due->SetToNow;
+        $Due->Set( Format => 'ISO', Value => $Now->ISO );
         $Due->AddDays( $due_in );
     }
 
@@ -339,7 +343,7 @@ sub Create {
 
     # If the status is not an initial status, set the started date
     elsif ( !$cycle->IsInitial($args{'Status'}) ) {
-        $Started->SetToNow;
+        $Started->Set( Format => 'ISO', Value => $Now->ISO );
     }
 
     my $Resolved = RT::Date->new( $self->CurrentUser );
@@ -353,7 +357,7 @@ sub Create {
         $RT::Logger->debug( "Got a ". $args{'Status'}
             ."(inactive) ticket with undefined resolved date. Setting to now."
         );
-        $Resolved->SetToNow;
+        $Resolved->Set( Format => 'ISO', Value => $Now->ISO );
     }
 
     # Dealing with time fields
@@ -383,6 +387,7 @@ sub Create {
         TimeEstimated   => $args{'TimeEstimated'},
         TimeLeft        => $args{'TimeLeft'},
         Type            => $args{'Type'},
+        Created         => $Now->ISO,
         Starts          => $Starts->ISO,
         Started         => $Started->ISO,
         Resolved        => $Resolved->ISO,

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


More information about the rt-commit mailing list