foreach ($columns as $column) {
$tableExceptions = array_key_exists('exceptions', $this->logTableSpec[$table]) ? $this->logTableSpec[$table]['exceptions'] : array();
// ignore modified_date changes
- if ($column != 'modified_date' && !in_array($column, $tableExceptions)) {
+ $tableExceptions[] = 'modified_date';
+ // exceptions may be provided with or without backticks
+ $excludeColumn = in_array($column, $tableExceptions) ||
+ in_array(str_replace('`', '', $column), $tableExceptions);
+ if (!$excludeColumn) {
$cond[] = "IFNULL(OLD.$column,'') <> IFNULL(NEW.$column,'')";
}
}
$this->assertTrue(empty($diffs['OBSOLETE']));
}
+ /**
+ * Test logging trigger definition
+ */
+ public function testTriggerInfo() {
+ $info = [];
+ $schema = new CRM_Logging_Schema();
+ $schema->enableLogging();
+ $schema->triggerInfo($info, 'civicrm_group');
+ // should have 3 triggers (insert/update/delete)
+ $this->assertCount(3, $info);
+ foreach ($info as $trigger) {
+ // table for trigger should be civicrm_group
+ $this->assertEquals('civicrm_group', $trigger['table'][0]);
+ if ($trigger['event'][0] == 'UPDATE') {
+ // civicrm_group.cache_date should be an exception, i.e. not logged
+ $this->assertNotContains(
+ "IFNULL(OLD.`cache_date`,'') <> IFNULL(NEW.`cache_date`,'')",
+ $trigger['sql']
+ );
+ }
+ }
+ }
+
}