From f37c24eb2a43207051cc6250a93af6254ab30617 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 29 Oct 2019 17:34:20 -0700 Subject: [PATCH] DB Tpl Strings - Remove table "civicrm_persistent" --- CRM/Core/BAO/Persistent.php | 111 -------------- CRM/Core/DAO/AllCoreTables.data.php | 5 - CRM/Core/DAO/Persistent.php | 219 ---------------------------- CRM/Utils/Migrate/Import.php | 20 --- sql/civicrm_generated.mysql | 9 -- xml/schema/Core/Persistent.xml | 1 + 6 files changed, 1 insertion(+), 364 deletions(-) delete mode 100644 CRM/Core/BAO/Persistent.php delete mode 100644 CRM/Core/DAO/Persistent.php diff --git a/CRM/Core/BAO/Persistent.php b/CRM/Core/BAO/Persistent.php deleted file mode 100644 index 2694f8bef0..0000000000 --- a/CRM/Core/BAO/Persistent.php +++ /dev/null @@ -1,111 +0,0 @@ -copyValues($params); - - if ($dao->find(TRUE)) { - CRM_Core_DAO::storeValues($dao, $defaults); - if (CRM_Utils_Array::value('is_config', $defaults) == 1) { - $defaults['data'] = unserialize($defaults['data']); - } - return $dao; - } - return NULL; - } - - /** - * Add the Persistent Record. - * - * @param array $params - * Reference array contains the values submitted by the form. - * @param array $ids - * Reference array contains the id. - * - * - * @return object - */ - public static function add(&$params, &$ids) { - if (CRM_Utils_Array::value('is_config', $params) == 1) { - $params['data'] = serialize(explode(',', $params['data'])); - } - $persistentDAO = new CRM_Core_DAO_Persistent(); - $persistentDAO->copyValues($params); - - $persistentDAO->id = CRM_Utils_Array::value('persistent', $ids); - $persistentDAO->save(); - return $persistentDAO; - } - - /** - * @param $context - * @param null $name - * - * @return mixed - */ - public static function getContext($context, $name = NULL) { - static $contextNameData = []; - - if (!array_key_exists($context, $contextNameData)) { - $contextNameData[$context] = []; - $persisntentDAO = new CRM_Core_DAO_Persistent(); - $persisntentDAO->context = $context; - $persisntentDAO->find(); - - while ($persisntentDAO->fetch()) { - $contextNameData[$context][$persisntentDAO->name] = $persisntentDAO->is_config == 1 ? unserialize($persisntentDAO->data) : $persisntentDAO->data; - } - } - if (empty($name)) { - return $contextNameData[$context]; - } - else { - return CRM_Utils_Array::value($name, $contextNameData[$context]); - } - } - -} diff --git a/CRM/Core/DAO/AllCoreTables.data.php b/CRM/Core/DAO/AllCoreTables.data.php index 8a366e7b07..cf649fb224 100644 --- a/CRM/Core/DAO/AllCoreTables.data.php +++ b/CRM/Core/DAO/AllCoreTables.data.php @@ -57,11 +57,6 @@ return [ 'class' => 'CRM_Core_DAO_Component', 'table' => 'civicrm_component', ], - 'CRM_Core_DAO_Persistent' => [ - 'name' => 'Persistent', - 'class' => 'CRM_Core_DAO_Persistent', - 'table' => 'civicrm_persistent', - ], 'CRM_Core_DAO_PrevNextCache' => [ 'name' => 'PrevNextCache', 'class' => 'CRM_Core_DAO_PrevNextCache', diff --git a/CRM/Core/DAO/Persistent.php b/CRM/Core/DAO/Persistent.php deleted file mode 100644 index 294f8e4a84..0000000000 --- a/CRM/Core/DAO/Persistent.php +++ /dev/null @@ -1,219 +0,0 @@ -__table = 'civicrm_persistent'; - parent::__construct(); - } - - /** - * Returns all the column names of this table - * - * @return array - */ - public static function &fields() { - if (!isset(Civi::$statics[__CLASS__]['fields'])) { - Civi::$statics[__CLASS__]['fields'] = [ - 'id' => [ - 'name' => 'id', - 'type' => CRM_Utils_Type::T_INT, - 'title' => ts('Persistent ID'), - 'description' => ts('Persistent Record Id'), - 'required' => TRUE, - 'where' => 'civicrm_persistent.id', - 'table_name' => 'civicrm_persistent', - 'entity' => 'Persistent', - 'bao' => 'CRM_Core_BAO_Persistent', - 'localizable' => 0, - ], - 'context' => [ - 'name' => 'context', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Context'), - 'description' => ts('Context for which name data pair is to be stored'), - 'required' => TRUE, - 'maxlength' => 255, - 'size' => CRM_Utils_Type::HUGE, - 'where' => 'civicrm_persistent.context', - 'table_name' => 'civicrm_persistent', - 'entity' => 'Persistent', - 'bao' => 'CRM_Core_BAO_Persistent', - 'localizable' => 0, - ], - 'name' => [ - 'name' => 'name', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Name'), - 'description' => ts('Name of Context'), - 'required' => TRUE, - 'maxlength' => 255, - 'size' => CRM_Utils_Type::HUGE, - 'where' => 'civicrm_persistent.name', - 'table_name' => 'civicrm_persistent', - 'entity' => 'Persistent', - 'bao' => 'CRM_Core_BAO_Persistent', - 'localizable' => 0, - ], - 'data' => [ - 'name' => 'data', - 'type' => CRM_Utils_Type::T_LONGTEXT, - 'title' => ts('Data'), - 'description' => ts('data associated with name'), - 'where' => 'civicrm_persistent.data', - 'table_name' => 'civicrm_persistent', - 'entity' => 'Persistent', - 'bao' => 'CRM_Core_BAO_Persistent', - 'localizable' => 0, - ], - 'is_config' => [ - 'name' => 'is_config', - 'type' => CRM_Utils_Type::T_BOOLEAN, - 'title' => ts('Is Configuration?'), - 'description' => ts('Config Settings'), - 'required' => TRUE, - 'where' => 'civicrm_persistent.is_config', - 'default' => '0', - 'table_name' => 'civicrm_persistent', - 'entity' => 'Persistent', - 'bao' => 'CRM_Core_BAO_Persistent', - 'localizable' => 0, - ], - ]; - CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); - } - return Civi::$statics[__CLASS__]['fields']; - } - - /** - * Return a mapping from field-name to the corresponding key (as used in fields()). - * - * @return array - * Array(string $name => string $uniqueName). - */ - public static function &fieldKeys() { - if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { - Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); - } - return Civi::$statics[__CLASS__]['fieldKeys']; - } - - /** - * Returns the names of this table - * - * @return string - */ - public static function getTableName() { - return self::$_tableName; - } - - /** - * Returns if this table needs to be logged - * - * @return bool - */ - public function getLog() { - return self::$_log; - } - - /** - * Returns the list of fields that can be imported - * - * @param bool $prefix - * - * @return array - */ - public static function &import($prefix = FALSE) { - $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'persistent', $prefix, []); - return $r; - } - - /** - * Returns the list of fields that can be exported - * - * @param bool $prefix - * - * @return array - */ - public static function &export($prefix = FALSE) { - $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'persistent', $prefix, []); - return $r; - } - - /** - * Returns the list of indices - * - * @param bool $localize - * - * @return array - */ - public static function indices($localize = TRUE) { - $indices = []; - return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; - } - -} diff --git a/CRM/Utils/Migrate/Import.php b/CRM/Utils/Migrate/Import.php index 802e2647de..714225da97 100644 --- a/CRM/Utils/Migrate/Import.php +++ b/CRM/Utils/Migrate/Import.php @@ -86,9 +86,6 @@ class CRM_Utils_Migrate_Import { $this->profileFields($xml, $idMap); $this->profileJoins($xml, $idMap); - // create DB Template String sample data - $this->dbTemplateString($xml, $idMap); - // clean up all caches etc CRM_Core_Config::clearDBCache(); } @@ -367,23 +364,6 @@ AND v.name = %1 } } - /** - * @param $xml - * @param $idMap - */ - public function dbTemplateString(&$xml, &$idMap) { - foreach ($xml->Persistent as $persistentXML) { - foreach ($persistentXML->Persistent as $persistent) { - $persistentObj = new CRM_Core_DAO_Persistent(); - - if ($persistent->is_config == 1) { - $persistent->data = serialize(explode(',', $persistent->data)); - } - $this->copyData($persistentObj, $persistent, TRUE, 'context'); - } - } - } - /** * @param $xml * @param $idMap diff --git a/sql/civicrm_generated.mysql b/sql/civicrm_generated.mysql index 669ff106ce..3102e8dec4 100644 --- a/sql/civicrm_generated.mysql +++ b/sql/civicrm_generated.mysql @@ -1097,15 +1097,6 @@ INSERT INTO `civicrm_pcp_block` (`id`, `entity_table`, `entity_id`, `target_enti /*!40000 ALTER TABLE `civicrm_pcp_block` ENABLE KEYS */; UNLOCK TABLES; --- --- Dumping data for table `civicrm_persistent` --- - -LOCK TABLES `civicrm_persistent` WRITE; -/*!40000 ALTER TABLE `civicrm_persistent` DISABLE KEYS */; -/*!40000 ALTER TABLE `civicrm_persistent` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Dumping data for table `civicrm_phone` -- diff --git a/xml/schema/Core/Persistent.xml b/xml/schema/Core/Persistent.xml index 4ea044d140..6c48b577ab 100644 --- a/xml/schema/Core/Persistent.xml +++ b/xml/schema/Core/Persistent.xml @@ -5,6 +5,7 @@ civicrm_persistent DB Template Customization strings 3.2 + 5.20 id Persistent ID -- 2.25.1