[Rt-commit] rtir branch, 4.0.1-releng, updated. 4.0.1rc1-2-g8f84f3d

Shawn Moore shawn at bestpractical.com
Thu Oct 5 11:00:43 EDT 2017


The branch, 4.0.1-releng has been updated
       via  8f84f3d40e7545d17b0555a2ce632650e959f35a (commit)
      from  1eadb5ba5d67f69e53430a97173ea7387e4c454b (commit)

Summary of changes:
 etc/upgrade/2.9.0/content | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

- Log -----------------------------------------------------------------
commit 8f84f3d40e7545d17b0555a2ce632650e959f35a
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Wed Sep 20 14:27:27 2017 -0400

    Drive select for state to status change from tickets
    
    The 2.9.0 upgrade script searches for the older state custom
    field and uses it to set status appropriately. The previous
    search worked from existing states in the state custom field, but
    state information is retained by custom fields when a ticket is
    moved to a different queue. The query would therefore find a state
    for an IR (new), for example, even if the ticket had been moved to
    the Incidents queue and there had a state of open. After an upgrade,
    the Incident ticket would have a status of new, which is incorrect and
    also not a valid status in the incidents lifecycle.
    
    Re-arrange the query to work from tickets rather than states to only
    pull state data and update status using current ticket information.

diff --git a/etc/upgrade/2.9.0/content b/etc/upgrade/2.9.0/content
index eabf2c4..226bbe6 100644
--- a/etc/upgrade/2.9.0/content
+++ b/etc/upgrade/2.9.0/content
@@ -165,16 +165,14 @@ our @Final = (
             my @states = custom_field_real_values( $cf );
 
             foreach my $state ( @states ) {
-                my $values = RT::ObjectCustomFieldValues->new( $RT::SystemUser );
-                $values->Limit( FIELD => 'CustomField', VALUE => $cf->id );
-                $values->Limit( FIELD => 'Disabled', VALUE => 0 );
-                $values->Limit( FIELD => 'Content', VALUE => $state );
-                $values->Limit( FIELD => 'ObjectType', VALUE => 'RT::Ticket' );
-                $values->Columns('ObjectId');
-                $values->OrderBy();
+                my $ticket_select = "select Tickets.id from Tickets, ObjectCustomFieldValues"
+                . " where Tickets.Queue = " . $queue->Id
+                . " and ObjectCustomFieldValues.ObjectId = Tickets.id and"
+                . " ObjectCustomFieldValues.CustomField = " . $cf->Id
+                . " and ObjectCustomFieldValues.Content = '$state'";
 
                 my $res = $RT::Handle->SimpleUpdateFromSelect(
-                    'Tickets', { Status => $state }, $values->BuildSelectQuery
+                    'Tickets', { Status => $state }, $ticket_select
                 );
                 $RT::Logger->error("Couldn't update tickets: $res")
                     unless $res;

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


More information about the rt-commit mailing list