Ticket #1289 (closed defect: fixed)
AuditLog does not handle fieldName != columnName
| Reported by: | millermichaelx@… | Owned by: | jwage |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | Versionable | Version: | 1.0.0 |
| Severity: | Keywords: | ||
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | no |
Description (last modified by jwage) (diff)
When a table is versionable, and a field on the table uses an uppercase character, the field will always set to null in the version table.
This is because AudtiLog?->setTableDefinition() uses the table column definitions to pass to VersionTable?->hasColumns(). The column definitions only contain lowercase column names, and not the proper fieldNames. When the record is saved/updated, the AuditLog? Listener merges the record into the version record, but the values are not set because the field names do not match.
This is a suggested fix for the AuditLog?->setTableDefinitions() function (I added the fields array):
public function setTableDefinition()
{
$name = $this->_options['table']->getComponentName();
$columns = $this->_options['table']->getColumns();
$fields = array();
// remove all sequence, autoincrement and unique constraint definitions
foreach ($columns as $column => $definition) {
//reset the name
$fields[$this->_options['table']->getFieldName($column)] = $columns[$column];
unset($columns[$column]['autoincrement']);
unset($columns[$column]['sequence']);
unset($columns[$column]['unique']);
}
$this->hasColumns($fields);
// the version column should be part of the primary key definition
$this->hasColumn($this->_options['versionColumn'], 'integer', 8, array('primary' => true));
}
Change History
Note: See
TracTickets for help on using
tickets.