$cols = <<<COLS
,
log_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- log_conn_id INTEGER,
+ log_conn_id VARCHAR(17),
log_user_id INTEGER,
log_action ENUM('Initialization', 'Insert', 'Update', 'Delete')
COLS;
CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray, TRUE, NULL, FALSE, FALSE);
$columns = implode(', ', $this->columnsOf($table));
- CRM_Core_DAO::executeQuery("INSERT INTO `{$this->db}`.log_$table ($columns, log_conn_id, log_user_id, log_action) SELECT $columns, CONNECTION_ID(), @civicrm_user_id, 'Initialization' FROM {$table}", CRM_Core_DAO::$_nullArray, TRUE, NULL, FALSE, FALSE);
+ CRM_Core_DAO::executeQuery("INSERT INTO `{$this->db}`.log_$table ($columns, log_conn_id, log_user_id, log_action) SELECT $columns, @uniqueID, @civicrm_user_id, 'Initialization' FROM {$table}", CRM_Core_DAO::$_nullArray, TRUE, NULL, FALSE, FALSE);
$this->tables[] = $table;
+ if(empty($this->logs)) {
+ civicrm_api3('Setting', 'create', array('logging_uniqueid_date' => 'now'));
+ civicrm_api3('Setting', 'create', array('logging_all_tables_uniquid' => 1));
+ }
$this->logs[$table] = "log_$table";
}
$sqlStmt .= "NEW.$column, ";
$deleteSQL .= "OLD.$column, ";
}
- $sqlStmt .= "CONNECTION_ID(), @civicrm_user_id, '{eventName}');";
- $deleteSQL .= "CONNECTION_ID(), @civicrm_user_id, '{eventName}');";
+ if (civicrm_api3('Setting', 'getvalue', array('name' => 'logging_uniqueid_date', 'group' => 'core'))) {
+ $sqlStmt .= "@uniqueID, @civicrm_user_id, '{eventName}');";
+ $deleteSQL .= "@uniqueID, @civicrm_user_id, '{eventName}');";
+ }
+ else {
+ // The log tables have not yet been converted to have varchar(17) fields for log_conn_id.
+ // Continue to use the less reliable connection_id for al tables for now.
+ $sqlStmt .= "CONNECTION_ID(), @civicrm_user_id, '{eventName}');";
+ $deleteSQL .= "@uniqueID, @civicrm_user_id, '{eventName}');";
+ }
$sqlStmt .= "END IF;";
$deleteSQL .= "END IF;";
'CRM_Logging_Schema::onToggle',
),
),
+ 'logging_uniqueid_date' => array(
+ 'add' => '4.7',
+ 'help_text' => ts('This is the date when CRM-18193 was implemented'),
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'group_name' => 'CiviCRM Preferences',
+ 'group' => 'core',
+ 'name' => 'logging_uniqueid_date',
+ 'type' => 'Date',
+ 'quick_form_type' => 'DateTime',
+ 'html_type' => '',
+ 'default' => NULL,
+ 'title' => 'Logging Unique ID not recorded before',
+ 'description' => 'This is the date when CRM-18193 was implemented',
+ ),
+ 'logging_all_tables_uniquid' => array(
+ 'add' => '4.7',
+ 'help_text' => ts('This indicates there are no tables holdng pre-uniqid log_conn_id values (CRM-18193)'),
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'group_name' => 'CiviCRM Preferences',
+ 'group' => 'core',
+ 'name' => 'logging_all_tables_uniquid',
+ 'type' => 'Boolean',
+ 'quick_form_type' => 'YesNo',
+ 'html_type' => '',
+ 'default' => 0,
+ 'title' => 'All tables use Unique Connection ID',
+ 'description' => 'Do some tables pre-date CRM-18193?',
+ ),
'userFrameworkUsersTableName' => array(
'add' => '4.7',
'help_text' => NULL,