Circular scrip calls

I get this error when I run the ExtractCustomFieldValues scrip…

[Fri Feb 27 11:48:07 2004] [error]: Scrip 15 died. - Can’t call method
"Content" on an undefined value at /opt/rt3/lib/RT/Action/
ExtractCustomFieldValues.pm line 47.

I took a look at the code, and understand why it’s happening, and also that RT
protects itself against scrip failures, so it’s not a stability problem…
But its messy, and I was wondering re the best way to fix it.

The problem is the circular nature of adding custom fields…

  • Scan the msg (first attachment) of a new transaction
  • if found a match, we add field value to the relevant custom field
  • create a new transaction to say just that…
  • …which is then scanned for custom fields…
  • … except in this case the first attachment is scanned, and since it
    doesn’t exist, it fails.

Somehow, any scrip that creates a new transaction should not be allowed to run
on that transaction…

A ‘quick fix’ for this particular one is:
ExtractCustomFieldValues.pm :
sub Commit {

  • unless ( $Transaction->Attachments->First ) { return 1; }

But this should be made more general, yes?
I found the ‘ActivateScrips’ functionality in Transaction_overlay.pm
I could do something like:

$Ticket->AddCustomFieldValue (Field => $cf, Value => $_, Activate_Scrips=0);
and pass it through all the way to
Transaction_Overlay.pm sub Create…

But that kinda limits scrips… perhaps some pathological case wants to run a
different scrip on a transaction generated by a previous scrip?

So what’s the thinking on this one?
Cerion

Hello Cerion,

Thanks for the report.

–Am Freitag, 27. Februar 2004 15:01 Uhr +0100 schrieb Cerion Armour-Brown
cerion@terpsichore.ws:

A ‘quick fix’ for this particular one is:
ExtractCustomFieldValues.pm :
sub Commit {

  • unless ( $Transaction->Attachments->First ) { return 1; }

patched and built a new version:
http://page.mi.fu-berlin.de/~pape/rt3/ExtractCustomFieldValues-1.0b2.tgz.

I never had this error, though, because I trigger my
ExtractCustomFiledValues action only from “Create”-transcations, that
always have (so far I know) an attachment.

But this should be made more general, yes?
I found the ‘ActivateScrips’ functionality in Transaction_overlay.pm
I could do something like:

$Ticket->AddCustomFieldValue (Field => $cf, Value => $_,
Activate_Scrips=0); and pass it through all the way to
Transaction_Overlay.pm sub Create…

no, it is not a good way to decide in a scrip if other scrips should be
called afterwards.

We might have patched ECFV’s Prepare function to signal that the action is
not applicable, if there is no attachment on the transaction but your patch
is (maybe less performant) but more robust.

Dirk.