class CRM_Logging_Schema

Methods

static bool
checkLoggingSupport(mixed $value, array $fieldSpec)

Setting Callback - Validate.

static 
onToggle(array $oldValue, array $newValue, array $metadata)

Setting Callback - On Change.

__construct()

Populate $this->tables and $this->logs with current db state.

customDataLogTables()

Return logging custom data tables.

array
entityCustomDataLogTables(string $extends)

Return custom data tables for specified entity / extends.

disableLogging()

Disable logging by dropping the triggers (but keep the log tables intact).

dropTriggers(string $tableName = NULL)

Drop triggers for all logged tables.

enableLogging()

Enable site-wide logging.

fixSchemaDifferences(bool $enableLogging = FALSE)

Sync log tables and rebuild triggers.

updateLogTableSchema()

Update log tables structure.

string
getEngineForLogTable(string $table)

Get the engine for the given table.

array
getIndexesForTable(string $table)

Get all the indexes in the table.

bool
fixSchemaDifferencesFor(string $table, array $cols = array(), bool $rebuildTrigger = FALSE)

Add missing (potentially specified) log table columns for the given table.

fixSchemaDifferencesForAll(bool $rebuildTrigger = FALSE)

Fix schema differences.

mixed
fixTimeStampAndNotNullSQL(string $query)

Fix timestamp.

array
columnsWithDiffSpecs(string $civiTable, string $logTable)

Get columns that have changed.

array
getLogTableSpec()

Getter for logTableSpec.

isEnabled()

Predicate whether logging is enabled.

dropAllLogTables()

Drop all log tables.

string
getNonStandardTableNameFilterString()

Get an sql clause to find the names of any log tables that do not match the normal pattern.

triggerInfo(array $info, null $tableName = NULL, bool $force = FALSE)

Get trigger info.

static 
disableLoggingForThisConnection()

Disable logging temporarily.

getLogTablesForContact()

Get all the log tables that reference civicrm_contact.

Details

at line 82
static bool checkLoggingSupport(mixed $value, array $fieldSpec)

Setting Callback - Validate.

Parameters

mixed $value
array $fieldSpec

Return Value

bool

Exceptions

API_Exception

at line 104
static onToggle(array $oldValue, array $newValue, array $metadata)

Setting Callback - On Change.

Respond to changes in the "logging" setting. Set up or destroy triggers, etal.

Parameters

array $oldValue List of component names.
array $newValue List of component names.
array $metadata Specification of the setting (per *.settings.php).

at line 121
__construct()

Populate $this->tables and $this->logs with current db state.

at line 187
customDataLogTables()

Return logging custom data tables.

at line 198
array entityCustomDataLogTables(string $extends)

Return custom data tables for specified entity / extends.

Parameters

string $extends

Return Value

array

at line 211
disableLogging()

Disable logging by dropping the triggers (but keep the log tables intact).

at line 228
dropTriggers(string $tableName = NULL)

Drop triggers for all logged tables.

Parameters

string $tableName

at line 270
enableLogging()

Enable site-wide logging.

at line 280
fixSchemaDifferences(bool $enableLogging = FALSE)

Sync log tables and rebuild triggers.

Parameters

bool $enableLogging : Ensure logging is enabled

at line 302
updateLogTableSchema()

Update log tables structure.

This function updates log tables to have the log_conn_id type of varchar and also implements any engine change to INNODB defined by the hooks.

Note changing engine & adding hook-defined indexes, but not changing back to ARCHIVE if engine has not been deliberately set (by hook) and not dropping indexes. Sysadmin will need to manually intervene to revert to defaults.

at line 345
string getEngineForLogTable(string $table)

Get the engine for the given table.

Parameters

string $table

Return Value

string

at line 359
array getIndexesForTable(string $table)

Get all the indexes in the table.

Parameters

string $table

Return Value

array

at line 380
bool fixSchemaDifferencesFor(string $table, array $cols = array(), bool $rebuildTrigger = FALSE)

Add missing (potentially specified) log table columns for the given table.

Parameters

string $table name of the relevant table.
array $cols Mixed array of columns to add or null (to check for the missing columns).
bool $rebuildTrigger should we rebuild the triggers.

Return Value

bool

at line 456
fixSchemaDifferencesForAll(bool $rebuildTrigger = FALSE)

Fix schema differences.

Parameters

bool $rebuildTrigger

at line 487
mixed fixTimeStampAndNotNullSQL(string $query)

Fix timestamp.

Log_civicrm_contact.modified_date for example would always be copied from civicrm_contact.modified_date, so there's no need for a default timestamp and therefore we remove such default timestamps also eliminate the NOT NULL constraint, since we always copy and schema can change down the road)

Parameters

string $query

Return Value

mixed

at line 607
array columnsWithDiffSpecs(string $civiTable, string $logTable)

Get columns that have changed.

Parameters

string $civiTable
string $logTable

Return Value

array

at line 668
array getLogTableSpec()

Getter for logTableSpec.

Return Value

array

at line 755
isEnabled()

Predicate whether logging is enabled.

at line 774
dropAllLogTables()

Drop all log tables.

This does not currently have a usage outside the tests.

at line 791
string getNonStandardTableNameFilterString()

Get an sql clause to find the names of any log tables that do not match the normal pattern.

Most tables are civicrm_xxx with the log table being log_civicrm_xxx However, they don't have to match this pattern (e.g when defined by hook) so find the anomalies and return a filter string to include them.

Return Value

string

at line 819
triggerInfo(array $info, null $tableName = NULL, bool $force = FALSE)

Get trigger info.

Parameters

array $info
null $tableName
bool $force

at line 920
static disableLoggingForThisConnection()

Disable logging temporarily.

This allow logging to be temporarily disabled for certain cases where we want to do a mass cleanup but do not want to bother with an audit trail.

at line 932
getLogTablesForContact()

Get all the log tables that reference civicrm_contact.

Note that it might make sense to wrap this in a getLogTablesForEntity but this is the only entity currently available...