// Temporary hack - in 5.27 a new field is added to civicrm_custom_field. There is a high
// risk this function is called before the upgrade page can be reached and if
// so it will potentially result in fatal error.
- $serializeField = CRM_Core_BAO_Domain::isDBUpdateRequired() ? '' : "$cfTable.serialize,";
+ $serializeField = CRM_Core_BAO_Domain::isDBVersionAtLeast('5.27.alpha1') ? '' : "$cfTable.serialize,";
$query = "SELECT $cfTable.id, $cfTable.label,
$cgTable.title,
$fields[$dao->id]['is_required'] = $dao->is_required;
$fields[$dao->id]['table_name'] = $dao->table_name;
$fields[$dao->id]['column_name'] = $dao->column_name;
- $fields[$dao->id]['serialize'] = $dao->serialize;
+ $fields[$dao->id]['serialize'] = $serializeField ? $dao->serialize : (int) self::isSerialized($dao);
$fields[$dao->id]['where'] = $dao->table_name . '.' . $dao->column_name;
// Probably we should use a different fn to get the extends tables but this is a refactor so not changing that now.
$fields[$dao->id]['extends_table'] = array_key_exists($dao->extends, CRM_Core_BAO_CustomQuery::$extendsMap) ? CRM_Core_BAO_CustomQuery::$extendsMap[$dao->extends] : '';
if ($html_type === 'CheckBox' || strpos($html_type, 'Multi') !== FALSE) {
return TRUE;
}
- // Otherwise this is the new standard as of 5.26
+ // Otherwise this is the new standard as of 5.27
return is_object($field) ? !empty($field->serialize) : !empty($field['serialize']);
}
return version_compare($dbVersion, $codeVersion) < 0;
}
+ /**
+ * Checks that the current DB schema is at least $min version
+ *
+ * @param string|number $min
+ * @return bool
+ */
+ public static function isDBVersionAtLeast($min) {
+ return version_compare(self::version(), $min, '>=');
+ }
+
/**
* Get the location values of a domain.
*
* @return array
*/
function civicrm_api3_custom_field_get($params) {
- if (!CRM_Core_BAO_Domain::isDBUpdateRequired() && ($params['legacy_html_type'] ?? TRUE) && !empty($params['return'])) {
+ if (!CRM_Core_BAO_Domain::isDBVersionAtLeast('5.27.alpha1') && ($params['legacy_html_type'] ?? TRUE) && !empty($params['return'])) {
if (is_array($params['return'])) {
$params['return'][] = 'serialize';
}