Skip to content
Snippets Groups Projects
Commit b25fa2ce authored by Jared Hancock's avatar Jared Hancock
Browse files

Ensure unique form entries are made with each ticket

Fixes a case where multiple tickets are created in one request (such as a
cron job triggering multiple email fetches). The TicketForm::getInstance()
called in Ticket::create() used a singleton pattern to retrieve a cached
instance of the TicketForm. In the case of ticket creation, each ticket
needs a new TicketForm entry instance.
parent 7855484a
Branches
Tags
No related merge requests found
......@@ -179,12 +179,15 @@ class TicketForm extends DynamicForm {
}
static function getInstance() {
if (!isset(static::$instance)) {
$o = static::objects();
static::$instance = $o[0]->instanciate();
}
if (!isset(static::$instance))
static::$instance = static::getNewInstance();
return static::$instance;
}
static function getNewInstance() {
$o = static::objects();
return $o[0]->instanciate();
}
}
// Add fields from the standard ticket form to the ticket filterable fields
Filter::addSupportedMatches('Custom Fields', function() {
......@@ -698,7 +701,7 @@ class DynamicList extends VerySimpleModel {
return $selections;
}
}
FormField::addFieldTypes('Custom Lists', array(DynamicList, 'getSelections'));
FormField::addFieldTypes('Custom Lists', array('DynamicList', 'getSelections'));
/**
* Represents a single item in a dynamic list
......
......@@ -1928,7 +1928,7 @@ class Ticket {
}
// Create and verify the dynamic form entry for the new ticket
$form = TicketForm::getInstance();
$form = TicketForm::getNewInstance();
// If submitting via email, ensure we have a subject and such
foreach ($form->getFields() as $field) {
$fname = $field->get('name');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment