*
* Generated from xml/schema/CRM/Core/Managed.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:1f1273f734c559351767e25b05b3925e)
+ * (GenCodeChecksum:43846305220f9d67d37b9a1f910ad085)
*/
/**
public $id;
/**
- * Name of the module which declared this object
+ * Name of the module which declared this object (soft FK to civicrm_extension.full_name)
*
* @var string
- * (SQL type: varchar(127))
+ * (SQL type: varchar(255))
* Note that values will be retrieved from the database as a string.
*/
public $module;
/**
* Symbolic name used by the module to identify the object
*
- * @var string|null
- * (SQL type: varchar(127))
+ * @var string
+ * (SQL type: varchar(255))
* Note that values will be retrieved from the database as a string.
*/
public $name;
/**
* Policy on when to cleanup entity (always, never, unused)
*
- * @var string|null
- * (SQL type: varchar(32))
+ * @var string
+ * (SQL type: varchar(16))
* Note that values will be retrieved from the database as a string.
*/
public $cleanup;
'name' => 'module',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Module'),
- 'description' => ts('Name of the module which declared this object'),
+ 'description' => ts('Name of the module which declared this object (soft FK to civicrm_extension.full_name)'),
'required' => TRUE,
- 'maxlength' => 127,
+ 'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'entity' => 'Managed',
'bao' => 'CRM_Core_BAO_Managed',
'localizable' => 0,
+ 'pseudoconstant' => [
+ 'callback' => 'CRM_Core_BAO_Managed::getBaseModules',
+ ],
'add' => '4.2',
],
'name' => [
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Name'),
'description' => ts('Symbolic name used by the module to identify the object'),
- 'maxlength' => 127,
+ 'required' => TRUE,
+ 'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Cleanup Setting'),
'description' => ts('Policy on when to cleanup entity (always, never, unused)'),
- 'maxlength' => 32,
- 'size' => CRM_Utils_Type::MEDIUM,
+ 'required' => TRUE,
+ 'maxlength' => 16,
+ 'size' => CRM_Utils_Type::TWELVE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_managed.cleanup',
+ 'default' => 'always',
'table_name' => 'civicrm_managed',
'entity' => 'Managed',
'bao' => 'CRM_Core_BAO_Managed',
$dao->name = $item['name'];
$dao->entity_type = $item['entity_type'];
$dao->entity_id = $id;
- $dao->cleanup = $item['cleanup'] ?? NULL;
+ $dao->cleanup = $item['cleanup'] ?? 'always';
$dao->save();
}
$this->addTask('Update Tag.name field', 'alterColumn', 'civicrm_tag', 'name', "varchar(64) NOT NULL COMMENT 'Unique machine name'");
$this->addTask('Update Tag.created_date field', 'alterColumn', 'civicrm_tag', 'created_date', "datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'Date and time that tag was created.'");
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
+ $this->addTask('Update civicrm_managed.module', 'alterColumn', 'civicrm_managed', 'module', "varchar(255) NOT NULL COMMENT 'Name of the module which declared this object (soft FK to civicrm_extension.full_name)'");
+ $this->addTask('Update civicrm_managed.name', 'alterColumn', 'civicrm_managed', 'name', "varchar(255) NOT NULL COMMENT 'Symbolic name used by the module to identify the object'");
+ $this->addTask('Update civicrm_managed.cleanup', 'alterColumn', 'civicrm_managed', 'cleanup', "varchar(16) NOT NULL DEFAULT 'always' COMMENT 'Policy on when to cleanup entity (always, never, unused)'");
}
}
{* file to handle db changes in 5.68.alpha1 during upgrade *}
UPDATE `civicrm_tag` SET `label` = `name` WHERE `label` = '';
+
+{* This column is now required. Delete any null values; a managed entity without a name is useless *}
+DELETE FROM civicrm_managed WHERE name IS NULL;
+{* This column is now required. Set to default value if null or invalid *}
+UPDATE civicrm_managed SET cleanup = 'always' WHERE cleanup IS NULL OR cleanup NOT IN ('always', 'never', 'unused');
}
}
$name = ($parentName ?? '') . $entityType . '_' . ($record['name'] ?? count($this->exportedEntities[$entityType]));
- // Ensure safe characters, max length
- $name = \CRM_Utils_String::munge($name, '_', 127);
+ // Ensure safe characters, max length.
+ // This is used for the value of `civicrm_managed.name` which has a maxlength of 255, but is also used
+ // to generate a file by civix, and many filesystems have a maxlength of 255 including the suffix, so
+ // 255 - strlen('.mgd.php') = 247
+ $name = \CRM_Utils_String::munge($name, '_', 247);
// Include option group with custom field
if ($entityType === 'CustomField') {
if (
<name>module</name>
<title>Module</title>
<type>varchar</type>
- <length>127</length>
+ <length>255</length>
<required>true</required>
- <comment>Name of the module which declared this object</comment>
+ <comment>Name of the module which declared this object (soft FK to civicrm_extension.full_name)</comment>
+ <pseudoconstant>
+ <callback>CRM_Core_BAO_Managed::getBaseModules</callback>
+ </pseudoconstant>
<add>4.2</add>
</field>
<field>
<name>name</name>
<title>Name</title>
<type>varchar</type>
- <length>127</length>
+ <length>255</length>
+ <required>true</required>
<comment>Symbolic name used by the module to identify the object</comment>
<add>4.2</add>
</field>
<name>cleanup</name>
<title>Cleanup Setting</title>
<type>varchar</type>
- <length>32</length>
+ <length>16</length>
+ <required>true</required>
+ <default>'always'</default>
<comment>Policy on when to cleanup entity (always, never, unused)</comment>
<pseudoconstant>
<callback>CRM_Core_ManagedEntities::getCleanupOptions</callback>