On 07/16/2013 08:48 PM, Craig Ringer wrote: > They're not related to database-level transactions since RT doesn't make > use of them.
This is wrong. RT _does_ make use of DB transactions. grep for BeginTransaction and/or Rollback. > It looks like --transaction picks an *existing* transaction to set as > the context of the cronjob. 'first' for the tx that created the ticket, > 'last' for the most recent ticket, or 'all' to select all transactions > on the ticket. > > [snip lots more] Yes, that all sounds about right without verifying myself. > I'm a little puzzled by the way crontool doesn't seem to have the > ability to create a *new* transaction for matching tickets. I guess the > action code is supposed to do that if a new transaction is required, eg > when adding a Comment to a ticket. rt-crontool can create new transactions by using the normal RT actions, just as you describe. I'm not sure why it seems odd to you. crontool is fundamentally a way to run scrip conditions/actions over a batch of tickets/transactions on a time-based trigger rather than solely event-based. > Some actions and conditions don't require a transaction context, and for > those no --transaction should be specified; there's an implicit > "--transaction none" where "undef" is passed as the transaction to act > on in process(...) . > > This can result in unexpected effects, like sending mail in the name of > the person who last did something on the ticket, so it's best to avoid > specifying a transaction unless you know you need one and one makes > sense in that context. > > For example, if you invoke RT::Action::SendEmail, it'll use the > transaction in GetFriendlyName to get the creator of the current > transaction and from it, the friendlyname. Same with SetReturnAddress. FWIW, the Notify* subclasses are generally much more useful than the SendEmail action directly. > It might be worth elaborating on this a little more in the documentation > and/or book. Feel free to use any of the above. As is, the above isn't really suitable for pasting into the usage doc for rt-crontool. A doc patch based on the above that fits with the rest of the doc would be appreciated, though. Thomas
