From e26df891420908fff6d5112a15957d5779b4a124 Mon Sep 17 00:00:00 2001 From: Patrick Figel Date: Fri, 14 Jun 2019 20:48:23 +0200 Subject: [PATCH] Add API defaults in System.updatelogtables This adds API defaults for the updateChangedEngineConfig and forceEngineMigration parameters of System.updatelogtables and removes some fallback code that's unnecessary now. --- CRM/Logging/Schema.php | 11 +++-------- api/v3/System.php | 2 ++ tests/phpunit/CRM/Logging/SchemaTest.php | 6 +++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/CRM/Logging/Schema.php b/CRM/Logging/Schema.php index bc0eb23ec1..efbeb831c7 100644 --- a/CRM/Logging/Schema.php +++ b/CRM/Logging/Schema.php @@ -315,18 +315,13 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) * defaults. * * @param array $params - * 'updateChangedEngineConfig' - update if the engine config changes, - * default FALSE - * 'forceEngineMigration' - force engine upgrade from ARCHIVE to InnoDB, - * default FALSE + * 'updateChangedEngineConfig' - update if the engine config changes? + * 'forceEngineMigration' - force engine upgrade from ARCHIVE to InnoDB? * * @return int $updateTablesCount * @throws \CiviCRM_API3_Exception */ - public function updateLogTableSchema($params = []) { - isset($params['updateChangedEngineConfig']) ? NULL : $params['updateChangedEngineConfig'] = FALSE; - isset($params['forceEngineMigration']) ? NULL : $params['forceEngineMigration'] = FALSE; - + public function updateLogTableSchema($params) { $updateLogConn = FALSE; $updatedTablesCount = 0; foreach ($this->logs as $mainTable => $logTable) { diff --git a/api/v3/System.php b/api/v3/System.php index 5d52ba734a..54faf069a1 100644 --- a/api/v3/System.php +++ b/api/v3/System.php @@ -413,11 +413,13 @@ function _civicrm_api3_system_updatelogtables_spec(&$params) { 'title' => 'Update Engine Config if changed?', 'description' => 'By default, we only update if the ENGINE has changed, set this to TRUE to update if the ENGINE_CONFIG has changed.', 'type' => CRM_Utils_Type::T_BOOLEAN, + 'api.default' => FALSE, ]; $params['forceEngineMigration'] = [ 'title' => 'Force storage engine to upgrade to InnoDB?', 'description' => 'Older versions of CiviCRM used the ARCHIVE engine by default. Set this to TRUE to migrate the engine to the new default.', 'type' => CRM_Utils_Type::T_BOOLEAN, + 'api.default' => FALSE, ]; } diff --git a/tests/phpunit/CRM/Logging/SchemaTest.php b/tests/phpunit/CRM/Logging/SchemaTest.php index f49c76d350..f7fcdb8e51 100644 --- a/tests/phpunit/CRM/Logging/SchemaTest.php +++ b/tests/phpunit/CRM/Logging/SchemaTest.php @@ -77,13 +77,13 @@ class CRM_Logging_SchemaTest extends CiviUnitTestCase { $this->assertRegexp('/ENGINE=ARCHIVE/', $log_table->Create_Table); } // engine should not change by default - $schema->updateLogTableSchema(); + $schema->updateLogTableSchema(['updateChangedEngineConfig' => FALSE, 'forceEngineMigration' => FALSE]); $log_table = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE log_civicrm_acl"); while ($log_table->fetch()) { $this->assertRegexp('/ENGINE=ARCHIVE/', $log_table->Create_Table); } // update with forceEngineMigration should convert to InnoDB - $schema->updateLogTableSchema(['forceEngineMigration' => TRUE]); + $schema->updateLogTableSchema(['updateChangedEngineConfig' => FALSE, 'forceEngineMigration' => TRUE]); $log_table = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE log_civicrm_acl"); while ($log_table->fetch()) { $this->assertRegexp('/ENGINE=InnoDB/', $log_table->Create_Table); @@ -189,7 +189,7 @@ class CRM_Logging_SchemaTest extends CiviUnitTestCase { ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"); $schema = new CRM_Logging_Schema(); $schema->enableLogging(); - $schema->updateLogTableSchema(); + $schema->updateLogTableSchema(['updateChangedEngineConfig' => FALSE, 'forceEngineMigration' => FALSE]); $ci = \Civi::$statics['CRM_Logging_Schema']['columnSpecs']['civicrm_test_column_info']; $this->assertEquals('test_id', $ci['test_id']['COLUMN_NAME']); -- 2.25.1