Merge pull request #16691 from mattwire/eventcart_cleanup
[civicrm-core.git] / api / v3 / System.php
index 2abbdf4bc44cd73292ebb443c020f78d0da706fa..3eb6845ce4af7dac24bfc03517f31fcf16ecf764 100644 (file)
@@ -384,6 +384,38 @@ function civicrm_api3_system_updatelogtables($params) {
   return civicrm_api3_create_success($updatedTablesCount);
 }
 
+/**
+ * Update log table structures.
+ *
+ * This updates the engine type if defined in the hook and changes the field type
+ * for log_conn_id to reflect CRM-18193.
+ *
+ * @param array $params
+ *
+ * @return array
+ *
+ * @throws \API_Exception
+ */
+function civicrm_api3_system_utf8conversion($params) {
+  if (CRM_Core_BAO_SchemaHandler::migrateUtf8mb4($params['is_revert'])) {
+    return civicrm_api3_create_success(1);
+  }
+  throw new API_Exception('Conversion failed');
+}
+
+/**
+ * Metadata for conversion function.
+ *
+ * @param array $params
+ */
+function _civicrm_api3_system_utf8conversion_spec(&$params) {
+  $params['is_revert'] = [
+    'title' => ts('Revert back from UTF8MB4 to UTF8?'),
+    'type' => CRM_Utils_Type::T_BOOLEAN,
+    'api.default' => FALSE,
+  ];
+}
+
 /**
  * Adjust Metadata for Flush action.
  *