Fixing attributes with a CLI script

Hi,

I’m trying to repair my searches on test RT installation that I’ve
upgraded from rt3.6 to rt3.8. This problem is described on
http://requesttracker.wikia.com/wiki/RepairSearches

Rather than doing this manually, or just deleting all saved searches I’m
trying to do this with a script. I’ve copied the
/usr/sbin/rt-dump-database-3.8 as a starting point, and stripped out
things I don’t need from that script.

According to my print statements the script is doing what I want, but
the changes are not sticking to the database. I’m calling
$attribute->SetAttribute() to update the attributes I want to change.
Despite this after running the script the searches are still incorrect.

I’ve been reading the RT::Record code, but I don’t know what I’m doing
wrong. I thought maybe I wasn’t committing a transaction, but adding
'$RT::Handle->BeginTransaction() and $RT::EndTransaction() didn’t change
things.

Any tips on how to get these changes to make it to the database?

±Geoff Crompton
±-Debian System Administrator
±–Trinity College

Hi,

I’m trying to repair my searches on test RT installation that I’ve
upgraded from rt3.6 to rt3.8. This problem is described on
http://requesttracker.wikia.com/wiki/RepairSearches

Rather than doing this manually, or just deleting all saved searches I’m
trying to do this with a script. I’ve copied the
/usr/sbin/rt-dump-database-3.8 as a starting point, and stripped out
things I don’t need from that script.

According to my print statements the script is doing what I want, but
the changes are not sticking to the database. I’m calling
$attribute->SetAttribute() to update the attributes I want to change.
Despite this after running the script the searches are still incorrect.

I’ve been reading the RT::Record code, but I don’t know what I’m doing
wrong. I thought maybe I wasn’t committing a transaction, but adding
'$RT::Handle->BeginTransaction() and $RT::EndTransaction() didn’t change
things.

Any tips on how to get these changes to make it to the database?

I’ve done some more debugging. When I call $attribute->SetAttribute()
when I get down to DBIx::SearchBuilder::Record::__Set() the code returns
‘That is already the current value’.

It seems DBIx::SearchBuilder::Record::__Value() is returning the same
string as the __Set() Value arg. I’m not a perl programmer, so I don’t
really know what I’m doing, or why the way I’m calling the API is breaking.

Anyone got any pointers on where to look next?

±Geoff Crompton
±-Debian System Administrator
±–Trinity College

Hi,

I’m trying to repair my searches on test RT installation that I’ve
upgraded from rt3.6 to rt3.8. This problem is described on
http://requesttracker.wikia.com/wiki/RepairSearches

Rather than doing this manually, or just deleting all saved searches I’m
trying to do this with a script. I’ve copied the
/usr/sbin/rt-dump-database-3.8 as a starting point, and stripped out
things I don’t need from that script.

According to my print statements the script is doing what I want, but
the changes are not sticking to the database. I’m calling
$attribute->SetAttribute() to update the attributes I want to change.
Despite this after running the script the searches are still incorrect.

I’ve been reading the RT::Record code, but I don’t know what I’m doing
wrong. I thought maybe I wasn’t committing a transaction, but adding
'$RT::Handle->BeginTransaction() and $RT::EndTransaction() didn’t change
things.

Any tips on how to get these changes to make it to the database?

I’ve done some more debugging. When I call
$attribute->SetAttribute() when I get down to
DBIx::SearchBuilder::Record::__Set() the code returns ‘That is
already the current value’.

Is that actually an RT::Attribute that you’re calling SetAttribute on?

You either want to call SetAttribute on the object the Attribute
belongs to, or possibly update with SetContent manually to set the
Content of the attribute. The source of SetAttribute is quite short
and should show you the relevant methods you need on an Attribute.

-kevin