/**
* Fix schema differences.
- *
- * @param bool $rebuildTrigger
*/
- public function fixSchemaDifferencesForAll($rebuildTrigger = FALSE) {
+ public function fixSchemaDifferencesForAll(): void {
$diffs = [];
$this->resetTableColumnsCache();
foreach ($diffs as $table => $cols) {
$this->fixSchemaDifferencesFor($table, $cols);
}
- if ($rebuildTrigger) {
- // invoke the meta trigger creation call
- CRM_Core_DAO::triggerRebuild(NULL, TRUE);
- }
}
/**
/**
* Clean up log tables.
+ *
+ * @throws \API_Exception
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
protected function tearDown(): void {
$this->quickCleanup(['civicrm_email', 'civicrm_address']);
/**
* Test that logging is successfully enabled and disabled.
+ *
+ * @throws \CRM_Core_Exception
*/
- public function testEnableDisableLogging() {
+ public function testEnableDisableLogging(): void {
$this->assertEquals(0, $this->callAPISuccessGetValue('Setting', ['name' => 'logging']));
$this->assertLoggingEnabled(FALSE);
/**
* Check that if a field is added then the trigger is updated on refresh.
+ *
+ * @throws \CRM_Core_Exception
*/
- public function testRebuildTriggerAfterSchemaChange() {
+ public function testRebuildTriggerAfterSchemaChange(): void {
$this->callAPISuccess('Setting', 'create', ['logging' => TRUE]);
$tables = ['civicrm_acl', 'civicrm_website'];
foreach ($tables as $table) {
CRM_Core_DAO::executeQuery("ALTER TABLE $table ADD column temp_col INT(10)");
}
+ unset(\Civi::$statics['CRM_Logging_Schema']);
$schema = new CRM_Logging_Schema();
- $schema->fixSchemaDifferencesForAll(TRUE);
+ $schema->fixSchemaDifferencesForAll();
+ Civi::service('sql_triggers')->rebuild();
foreach ($tables as $table) {
$this->assertTrue($this->checkColumnExistsInTable('log_' . $table, 'temp_col'), 'log_' . $table . ' has temp_col');
$this->assertStringContainsString('temp_col', $dao->Statement);
}
}
- CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_acl DROP column temp_col");
- CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_website DROP column temp_col");
+ CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_acl DROP column temp_col');
+ CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_website DROP column temp_col');
}
/**