Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid "Couldn't load object RT::Transaction #0" warning
This can occur when a user submits the ticket reply page with a transaction custom field. The field name for that transaction custom field looks like: Object-RT::Transaction--CustomField-1-Value Recall that ordinarily, such custom field input names have the record id that we're modifying. But in this case, since we're creating a record (of class RT::Transaction), we don't have an id yet, hence the double dash between the class name and "CustomField". For most record types, this ends up working out because when we call ProcessObjectCustomFieldUpdates, RT will have already created the primary record and provided it as the "Object" argument, which is used for such "orphan" form fields. This is the codepath that, for example, specifying custom fields during creation of a group in the admin UI uses. In the case of ticket transactions, the ticket update logic in /Ticket/Display.html does not provide such an Object argument (and is not readily amenable to doing so, as the transaction is created and falls out of scope within ProcessUpdateMessage), and so ProcessObjectCustomFieldUpdates is left with both an orphan "Object-RT::Transaction--CustomField-1-Value" field name as well as no loaded RT::Transaction Object to use instead. This ends up causing no transaction object to be present, leading to the warning "Couldn't load object RT::Transaction #0". Incidentally, ticket transaction custom fields are added in a separate codepath: RT::Interface::Web ProcessUpdateMessage's calls to $Object->UpdateCustomFields. In cases where we have an orphan field name ($id false), and no loaded Object was provided (false $Object->id), we have nothing to load, and so the "Couldn't load object $class #0" warning is inappropriate. See previous commit for tests (t/web/ticket_txn_cf.t) which tickle the warning. Fixes: I#31548
- Loading branch information