[rt-users] fixing attributes with a CLI script

Kevin Falcone falcone at bestpractical.com
Tue May 24 09:43:04 EDT 2011


On Mon, May 23, 2011 at 03:00:37PM +1000, Geoff Crompton wrote:
> On 23/05/11 11:12, Geoff Crompton wrote:
> >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

> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110524/1b5d319a/attachment.sig>


More information about the rt-users mailing list