[Rt-commit] rtir branch, 4.0/state-to-status-upgrade, created. 4.0.0-58-g55e165b
Jim Brandt
jbrandt at bestpractical.com
Wed Sep 20 14:33:51 EDT 2017
The branch, 4.0/state-to-status-upgrade has been created
at 55e165b1d8f135645c5954d035e46babeb068dcb (commit)
- Log -----------------------------------------------------------------
commit 55e165b1d8f135645c5954d035e46babeb068dcb
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