while ($dao->fetch()) {
$this->tables[] = $dao->TABLE_NAME;
}
+ // Get any non standard table names used for custom groups.
+ // include these BEFORE the hook is called.
+ $customFieldDAO = CRM_Core_DAO::executeQuery("
+ SELECT DISTINCT table_name as TABLE_NAME FROM civicrm_custom_group
+ where table_name NOT LIKE 'civicrm_%';
+ ");
+ while ($customFieldDAO->fetch()) {
+ $this->tables[] = $customFieldDAO->TABLE_NAME;
+ }
// do not log temp import, cache, menu and log tables
$this->tables = preg_grep('/^civicrm_import_job_/', $this->tables, PREG_GREP_INVERT);
* name of the relevant table.
* @param array $cols
* Mixed array of columns to add or null (to check for the missing columns).
- *
- * @return bool
*/
- public function fixSchemaDifferencesFor($table, $cols = []) {
- if (empty($table)) {
- return FALSE;
+ public function fixSchemaDifferencesFor(string $table, array $cols = []): void {
+ if (!in_array($table, $this->tables, TRUE)) {
+ // Create the table if the log table does not exist and
+ // the table is in 'this->tables'. This latter array
+ // could have been altered by a hook if the site does not
+ // want to log a specific table.
+ return;
}
if (empty($this->logs[$table])) {
$this->createLogTableFor($table);
- return TRUE;
+ return;
}
if (empty($cols)) {
}
$this->resetSchemaCacheForTable("log_$table");
-
- return TRUE;
}
/**
* Get column query.
*
* @param string $col
- * @param bool $createQuery
+ * @param array $createQuery
*
* @return array|mixed|string
*/