Contrib Censorware delete-transaction script errors

I am on 3.8.4 trying to use Jesse’s delete-transaction script written
in 2001 from
http://download.bestpractical.com/pub/rt/contrib/3.0/Other/Censorware/delete-transaction

the purpose of the script is to edit a transaction to redact all info
from it (whether file Attachment, Comment, or Reply) for cases where
there was something posted that should not be in the ticket system.

After editting the 2 “use lib” statements at the beginning of the
script to reflect my actual paths to RT, and running the script, I got
an error like: “Can’t locate [some plugin] in @INC…” I fixed that
by adding a 3rd “use lib” line listing the “local” RTlib.

Now the script sort of runs - it wipes a transaction and creates a new
System Message transaction that says " Transaction 137302 purged," but
also pours out a pile of errors.

Afterward, the transaction Content is replaced with the text “The
original content has been purged for the following reason,” but the
$reason given as CLI argument is not included. Since the script does
alter at least 3 db rows, the first error message “Mysql server has
gone away” makes no sense to me.

Here are all the errors when the script runs. Does anyone know what
they mean or how to fix them?

root@localhost# rt-delete-transaction 11260/137302 "because was bad"
Now deleting content and headers for attachment #82692
Now deleting content and headers for attachment #82693
Now deleting content and headers for attachment #82694
[Thu Aug 27 18:19:46 2009] [warning]: DBD::mysql::st execute failed:
MySQL server has gone away at
/usr/share/perl5/DBIx/SearchBuilder/Handle.pm line 505.
(/usr/share/perl5/DBIx/SearchBuilder/Handle.pm:505)
[Thu Aug 27 18:19:46 2009] [warning]: RT::Handle=HASH(0xb022c28)
couldn’t execute the query ‘SELECT * FROM Tickets WHERE id = ?’ at
/usr/share/perl5/DBIx/SearchBuilder/Handle.pm line 518
DBIx::SearchBuilder::Handle::SimpleQuery(‘RT::Handle=HASH(0xb022c28)’,
‘SELECT * FROM Tickets WHERE id = ?’, 11260) called at
/usr/share/perl5/DBIx/SearchBuilder/Record.pm line 1207
DBIx::SearchBuilder::Record::_LoadFromSQL(‘RT::Ticket=HASH(0xc2a1038)’,
‘SELECT * FROM Tickets WHERE id = ?’, 11260) called at
/usr/share/perl5/DBIx/SearchBuilder/Record.pm line 1126
DBIx::SearchBuilder::Record::LoadByCols(‘RT::Ticket=HASH(0xc2a1038)’,
‘id’, 11260) called at
/usr/share/perl5/DBIx/SearchBuilder/Record/Cachable.pm line 119
DBIx::SearchBuilder::Record::Cachable::LoadByCols(‘RT::Ticket=HASH(0xc2a1038)’,
‘id’, 11260) called at /usr/share/request-tracker3.8/lib/RT/Record.pm
line 350
RT::Record::LoadByCols(‘RT::Ticket=HASH(0xc2a1038)’, ‘id’,
11260) called at /usr/share/perl5/DBIx/SearchBuilder/Record.pm line
1141
DBIx::SearchBuilder::Record::LoadById(‘RT::Ticket=HASH(0xc2a1038)’,
11260) called at
/usr/share/request-tracker3.8/lib/RT/Ticket_Overlay.pm line 169
RT::ticket::Load(‘RT::Ticket=HASH(0xc2a1038)’, 11260) called
at /usr/share/request-tracker3.8/lib/RT/Transaction_Overlay.pm line
1039
RT::Transaction::Object(‘RT::Transaction=HASH(0xc2a6de0)’)
called at /usr/share/request-tracker3.8/lib/RT/Transaction_Overlay.pm
line 942
RT::Transaction::CurrentUserHasRight(‘RT::Transaction=HASH(0xc2a6de0)’,
‘ShowTicket’) called at
/usr/share/request-tracker3.8/lib/RT/Transaction_Overlay.pm line 963
RT::Transaction::CurrentUserCanSee(‘RT::Transaction=HASH(0xc2a6de0)’)
called at /usr/share/request-tracker3.8/lib/RT/Transaction_Overlay.pm
line 921
RT::Transaction::_Value(‘RT::Transaction=HASH(0xc2a6de0)’,
‘Type’) called at /usr/share/perl5/DBIx/SearchBuilder/Record.pm line
424
DBIx::SearchBuilder::Record::ANON(‘RT::Transaction=HASH(0xc2a6de0)’)
called at /usr/share/request-tracker3.8/lib/RT/Ticket_Overlay.pm line
3186
RT::ticket::DESTROY(‘RT::Ticket=HASH(0xc227f88)’) called at
/usr/sbin/rt-delete-transaction line 0
eval {…} called at /usr/sbin/rt-delete-transaction line 0
(/usr/share/perl/5.10/Carp.pm:47)
[Thu Aug 27 18:19:46 2009] [crit]: HasRight called with no valid
object (/usr/share/request-tracker3.8/lib/RT/Principal_Overlay.pm:322)
[Thu Aug 27 18:19:46 2009] [warning]: DBD::mysql::st execute failed:
MySQL server has gone away at
/usr/share/perl5/DBIx/SearchBuilder/Handle.pm line 505.
(/usr/share/perl5/DBIx/SearchBuilder/Handle.pm:505)
[Thu Aug 27 18:19:46 2009] [warning]: RT::Handle=HASH(0xb022c28)
couldn’t execute the query 'SELECT DISTINCT main.* FROM Scrips main
JOIN ScripConditions ScripConditions_1 ON ( ScripConditions_1.id =
main.ScripCondition ) WHERE (main.Queue = ‘1’ OR main.Queue = ‘0’)
AND (ScripConditions_1.ApplicableTransTypes LIKE ‘%Any%’) AND
(main.Stage = ‘TransactionBatch’) ORDER BY main.Description ASC ’ at
/usr/share/perl5/DBIx/SearchBuilder/Handle.pm line 518
DBIx::SearchBuilder::Handle::SimpleQuery(‘RT::Handle=HASH(0xb022c28)’,
‘SELECT DISTINCT main.* FROM Scrips main JOIN ScripConditions …’)
called at /usr/share/perl5/DBIx/SearchBuilder.pm line 238
DBIx::SearchBuilder::_DoSearch(‘RT::Scrips=HASH(0xc05a8c8)’)
called at /usr/share/request-tracker3.8/lib/RT/Scrips_Overlay.pm line
368
RT::Scrips::_FindScrips(‘RT::Scrips=HASH(0xc05a8c8)’, ‘Stage’,
‘TransactionBatch’, ‘Type’, ‘’) called at
/usr/share/request-tracker3.8/lib/RT/Scrips_Overlay.pm line 226
RT::Scrips::Prepare(‘RT::Scrips=HASH(0xc05a8c8)’, ‘Type’, ‘’,
‘TransactionObj’, ‘RT::Transaction=HASH(0xc2a6de0)’, ‘Ticket’, undef,
‘TicketObj’, ‘RT::Ticket=HASH(0xc227f88)’, …) called at
/usr/share/request-tracker3.8/lib/RT/Scrips_Overlay.pm line 174
RT::Scrips::Apply(‘RT::Scrips=HASH(0xc05a8c8)’, ‘Stage’,
‘TransactionBatch’, ‘TicketObj’, ‘RT::Ticket=HASH(0xc227f88)’,
‘TransactionObj’, ‘RT::Transaction=HASH(0xc2a6de0)’, ‘Type’, ‘’, …)
called at /usr/share/request-tracker3.8/lib/RT/Ticket_Overlay.pm line
3186
RT::ticket::DESTROY(‘RT::Ticket=HASH(0xc227f88)’) called at
/usr/sbin/rt-delete-transaction line 0
eval {…} called at /usr/sbin/rt-delete-transaction line 0
(/usr/share/perl/5.10/Carp.pm:47)
[Thu Aug 27 18:19:46 2009] [warning]: DBD::mysql::st execute failed:
MySQL server has gone away at
/usr/share/perl5/DBIx/SearchBuilder/Handle.pm line 505.
(/usr/share/perl5/DBIx/SearchBuilder/Handle.pm:505)
[Thu Aug 27 18:19:46 2009] [warning]: RT::Handle=HASH(0xb022c28)
couldn’t execute the query 'SELECT COUNT(DISTINCT main.id) FROM Scrips
main JOIN ScripConditions ScripConditions_1 ON ( ScripConditions_1.id
= main.ScripCondition ) WHERE (main.Queue = ‘1’ OR main.Queue = ‘0’)
AND (ScripConditions_1.ApplicableTransTypes LIKE ‘%Any%’) AND
(main.Stage = ‘TransactionBatch’) ’ at
/usr/share/perl5/DBIx/SearchBuilder/Handle.pm line 518
DBIx::SearchBuilder::Handle::SimpleQuery(‘RT::Handle=HASH(0xb022c28)’,
‘SELECT COUNT(DISTINCT main.id) FROM Scrips main JOIN ScripCon…’)
called at /usr/share/perl5/DBIx/SearchBuilder.pm line 294
DBIx::SearchBuilder::_DoCount(‘RT::Scrips=HASH(0xc05a8c8)’)
called at /usr/share/perl5/DBIx/SearchBuilder.pm line 1380
DBIx::SearchBuilder::Count(‘RT::Scrips=HASH(0xc05a8c8)’)
called at /usr/share/request-tracker3.8/lib/RT/Scrips_Overlay.pm line
370
RT::Scrips::_FindScrips(‘RT::Scrips=HASH(0xc05a8c8)’, ‘Stage’,
‘TransactionBatch’, ‘Type’, ‘’) called at
/usr/share/request-tracker3.8/lib/RT/Scrips_Overlay.pm line 226
RT::Scrips::Prepare(‘RT::Scrips=HASH(0xc05a8c8)’, ‘Type’, ‘’,
‘TransactionObj’, ‘RT::Transaction=HASH(0xc2a6de0)’, ‘Ticket’, undef,
‘TicketObj’, ‘RT::Ticket=HASH(0xc227f88)’, …) called at
/usr/share/request-tracker3.8/lib/RT/Scrips_Overlay.pm line 174
RT::Scrips::Apply(‘RT::Scrips=HASH(0xc05a8c8)’, ‘Stage’,
‘TransactionBatch’, ‘TicketObj’, ‘RT::Ticket=HASH(0xc227f88)’,
‘TransactionObj’, ‘RT::Transaction=HASH(0xc2a6de0)’, ‘Type’, ‘’, …)
called at /usr/share/request-tracker3.8/lib/RT/Ticket_Overlay.pm line
3186
RT::ticket::DESTROY(‘RT::Ticket=HASH(0xc227f88)’) called at
/usr/sbin/rt-delete-transaction line 0
eval {…} called at /usr/sbin/rt-delete-transaction line 0
(/usr/share/perl/5.10/Carp.pm:47)
[Thu Aug 27 18:19:46 2009] [warning]: DBD::mysql::st execute failed:
MySQL server has gone away at
/usr/share/perl5/DBIx/SearchBuilder/Handle.pm line 505.
(/usr/share/perl5/DBIx/SearchBuilder/Handle.pm:505)
[Thu Aug 27 18:19:46 2009] [warning]: RT::Handle=HASH(0xb022c28)
couldn’t execute the query 'SELECT DISTINCT main.* FROM Scrips main
JOIN ScripConditions ScripConditions_1 ON ( ScripConditions_1.id =
main.ScripCondition ) WHERE (main.Queue = ‘1’ OR main.Queue = ‘0’)
AND (ScripConditions_1.ApplicableTransTypes LIKE ‘%Any%’) AND
(main.Stage = ‘TransactionBatch’) ORDER BY main.Description ASC ’ at
/usr/share/perl5/DBIx/SearchBuilder/Handle.pm line 518
DBIx::SearchBuilder::Handle::SimpleQuery(‘RT::Handle=HASH(0xb022c28)’,
‘SELECT DISTINCT main.* FROM Scrips main JOIN ScripConditions …’)
called at /usr/share/perl5/DBIx/SearchBuilder.pm line 238
DBIx::SearchBuilder::_DoSearch(‘RT::Scrips=HASH(0xc05a8c8)’)
called at /usr/share/perl5/DBIx/SearchBuilder.pm line 498
DBIx::SearchBuilder::Next(‘RT::Scrips=HASH(0xc05a8c8)’) called
at /usr/share/request-tracker3.8/lib/RT/Scrips_Overlay.pm line 135
RT::Scrips::Next(‘RT::Scrips=HASH(0xc05a8c8)’) called at
/usr/share/request-tracker3.8/lib/RT/Scrips_Overlay.pm line 230
RT::Scrips::Prepare(‘RT::Scrips=HASH(0xc05a8c8)’, ‘Type’, ‘’,
‘TransactionObj’, ‘RT::Transaction=HASH(0xc2a6de0)’, ‘Ticket’, undef,
‘TicketObj’, ‘RT::Ticket=HASH(0xc227f88)’, …) called at
/usr/share/request-tracker3.8/lib/RT/Scrips_Overlay.pm line 174
RT::Scrips::Apply(‘RT::Scrips=HASH(0xc05a8c8)’, ‘Stage’,
‘TransactionBatch’, ‘TicketObj’, ‘RT::Ticket=HASH(0xc227f88)’,
‘TransactionObj’, ‘RT::Transaction=HASH(0xc2a6de0)’, ‘Type’, ‘’, …)
called at /usr/share/request-tracker3.8/lib/RT/Ticket_Overlay.pm line
3186
RT::ticket::DESTROY(‘RT::Ticket=HASH(0xc227f88)’) called at
/usr/sbin/rt-delete-transaction line 0
eval {…} called at /usr/sbin/rt-delete-transaction line 0
(/usr/share/perl/5.10/Carp.pm:47)
[Thu Aug 27 18:19:46 2009] [warning]: DBD::mysql::st execute failed:
MySQL server has gone away at
/usr/share/perl5/DBIx/SearchBuilder/Handle.pm line 505.
(/usr/share/perl5/DBIx/SearchBuilder/Handle.pm:505)
[Thu Aug 27 18:19:46 2009] [warning]: RT::Handle=HASH(0xb022c28)
couldn’t execute the query ‘SELECT * FROM Tickets WHERE id = ?’ at
/usr/share/perl5/DBIx/SearchBuilder/Handle.pm line 518
DBIx::SearchBuilder::Handle::SimpleQuery(‘RT::Handle=HASH(0xb022c28)’,
‘SELECT * FROM Tickets WHERE id = ?’, 11260) called at
/usr/share/perl5/DBIx/SearchBuilder/Record.pm line 1207
DBIx::SearchBuilder::Record::_LoadFromSQL(‘RT::Ticket=HASH(0xc265730)’,
‘SELECT * FROM Tickets WHERE id = ?’, 11260) called at
/usr/share/perl5/DBIx/SearchBuilder/Record.pm line 1126
DBIx::SearchBuilder::Record::LoadByCols(‘RT::Ticket=HASH(0xc265730)’,
‘id’, 11260) called at
/usr/share/perl5/DBIx/SearchBuilder/Record/Cachable.pm line 119
DBIx::SearchBuilder::Record::Cachable::LoadByCols(‘RT::Ticket=HASH(0xc265730)’,
‘id’, 11260) called at /usr/share/request-tracker3.8/lib/RT/Record.pm
line 350
RT::Record::LoadByCols(‘RT::Ticket=HASH(0xc265730)’, ‘id’,
11260) called at /usr/share/perl5/DBIx/SearchBuilder/Record.pm line
1141
DBIx::SearchBuilder::Record::LoadById(‘RT::Ticket=HASH(0xc265730)’,
11260) called at
/usr/share/request-tracker3.8/lib/RT/Ticket_Overlay.pm line 169
RT::ticket::Load(‘RT::Ticket=HASH(0xc265730)’, 11260) called
at /usr/share/request-tracker3.8/lib/RT/Transaction_Overlay.pm line
1039
RT::Transaction::Object(‘RT::Transaction=HASH(0xc2a6de0)’)
called at /usr/share/request-tracker3.8/lib/RT/Transaction_Overlay.pm
line 942
RT::Transaction::CurrentUserHasRight(‘RT::Transaction=HASH(0xc2a6de0)’,
‘ShowTicket’) called at
/usr/share/request-tracker3.8/lib/RT/Transaction_Overlay.pm line 963
RT::Transaction::CurrentUserCanSee(‘RT::Transaction=HASH(0xc2a6de0)’)
called at /usr/share/request-tracker3.8/lib/RT/Transaction_Overlay.pm
line 921
RT::Transaction::_Value(‘RT::Transaction=HASH(0xc2a6de0)’,
‘Type’) called at /usr/share/perl5/DBIx/SearchBuilder/Record.pm line
424
DBIx::SearchBuilder::Record::ANON(‘RT::Transaction=HASH(0xc2a6de0)’)
called at /usr/share/request-tracker3.8/lib/RT/Ticket_Overlay.pm line
3194
RT::ticket::DESTROY(‘RT::Ticket=HASH(0xc227f88)’) called at
/usr/sbin/rt-delete-transaction line 0
eval {…} called at /usr/sbin/rt-delete-transaction line 0
(/usr/share/perl/5.10/Carp.pm:47)
[Thu Aug 27 18:19:46 2009] [crit]: HasRight called with no valid
object (/usr/share/request-tracker3.8/lib/RT/Principal_Overlay.pm:322)

Apparently the source of most of the errors was the

$RT::Handle->Disconnect();

at the end of the file. Maybe this is because the handle relates to
SearchBuilder and no searches were performed in this script?

Other minor problems that made this script not really work on 3.8 are
fixed and all is posted at

http://wiki.bestpractical.com/view/delete-transaction

Allen