Ticket #1289 (closed defect: fixed)

Opened 11 months ago

Last modified 10 months ago

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

Changed 11 months ago by jwage

  • version changed from 0.11 to 1.0
  • milestone changed from Unknown to 1.0.0-RC1

Changed 11 months ago by jwage

  • description modified (diff)

Changed 11 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [4755]) fixes #1289

Changed 10 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Note: See TracTickets for help on using tickets.