From bcf70e08b7678f3aa99bb131a8d2dc6e88a8f763 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 16 Jul 2020 00:21:58 -0700 Subject: [PATCH] Rename RelationshipVortex to RelationshipCache --- ...onshipVortex.php => RelationshipCache.php} | 24 ++-- ...onshipVortex.php => RelationshipCache.php} | 132 +++++++++--------- CRM/Core/DAO/AllCoreTables.data.php | 8 +- .../Incremental/php/FiveTwentyNine.php | 10 +- .../Incremental/sql/5.29.alpha1.mysql.tpl | 20 +-- Civi/Core/Container.php | 2 +- ...rtexTest.php => RelationshipCacheTest.php} | 16 +-- tests/phpunit/CRM/Dedupe/MergerTest.php | 4 +- ...onshipVortex.xml => RelationshipCache.xml} | 18 +-- xml/schema/Contact/files.xml | 2 +- 10 files changed, 118 insertions(+), 118 deletions(-) rename CRM/Contact/BAO/{RelationshipVortex.php => RelationshipCache.php} (88%) rename CRM/Contact/DAO/{RelationshipVortex.php => RelationshipCache.php} (72%) rename tests/phpunit/CRM/Contact/BAO/{RelationshipVortexTest.php => RelationshipCacheTest.php} (83%) rename xml/schema/Contact/{RelationshipVortex.xml => RelationshipCache.xml} (83%) diff --git a/CRM/Contact/BAO/RelationshipVortex.php b/CRM/Contact/BAO/RelationshipCache.php similarity index 88% rename from CRM/Contact/BAO/RelationshipVortex.php rename to CRM/Contact/BAO/RelationshipCache.php index fe6f889c24..686fc0a351 100644 --- a/CRM/Contact/BAO/RelationshipVortex.php +++ b/CRM/Contact/BAO/RelationshipCache.php @@ -10,12 +10,12 @@ */ /** - * Class CRM_Contact_BAO_RelationshipVortex. + * Class CRM_Contact_BAO_RelationshipCache. */ -class CRM_Contact_BAO_RelationshipVortex extends CRM_Contact_DAO_RelationshipVortex { +class CRM_Contact_BAO_RelationshipCache extends CRM_Contact_DAO_RelationshipCache { /** - * The "mappings" array defines the values to put into `civicrm_relationship_vtx` + * The "mappings" array defines the values to put into `civicrm_relationship_cache` * using data from `civicrm_relationship rel` and `civicrm_relationship_type reltype`. * * @var array @@ -59,7 +59,7 @@ class CRM_Contact_BAO_RelationshipVortex extends CRM_Contact_DAO_RelationshipVor /** * A list of of fields in `civicrm_relationship_type` which (if changed) - * will necessitate an update to the vortex. + * will necessitate an update to the cache. * * @var array */ @@ -78,7 +78,7 @@ class CRM_Contact_BAO_RelationshipVortex extends CRM_Contact_DAO_RelationshipVor * This trigger runs whenever a "civicrm_relationship" record is inserted or updated. * * Goal: Ensure that every relationship record has two corresponding entries in the - * vortex, the forward relationship (A=>B) and reverse relationship (B=>A). + * cache, the forward relationship (A=>B) and reverse relationship (B=>A). */ $triggers[] = [ 'table' => 'civicrm_relationship', @@ -109,27 +109,27 @@ class CRM_Contact_BAO_RelationshipVortex extends CRM_Contact_DAO_RelationshipVor ]; } - // Note: We do not need a DELETE trigger to maintain `civicrm_relationship_vtx` because it uses `CASCADE`. + // Note: We do not need a DELETE trigger to maintain `civicrm_relationship_cache` because it uses `CASCADE`. $st = new \Civi\Core\SqlTrigger\StaticTriggers($triggers); $st->onTriggerInfo($e); } /** - * Read all records from civicrm_relationship and populate the vortex. + * Read all records from civicrm_relationship and populate the cache. * Each ordinary relationship in `civicrm_relationship` becomes two - * distinct records in the vortex (one for A=>B relations; and one for B=>A). + * distinct records in the cache (one for A=>B relations; and one for B=>A). * * This method is primarily written (a) for manual testing and (b) in case * a broken DBMS, screwy import, buggy code, etc causes a corruption. * - * NOTE: This is closely related to FiveTwentyNine::populateRelationshipVortex(), + * NOTE: This is closely related to FiveTwentyNine::populateRelationshipCache(), * except that the upgrader users pagination. */ public static function rebuild() { $relUpdates = self::createInsertUpdateQueries(); - CRM_Core_DAO::executeQuery('TRUNCATE civicrm_relationship_vtx'); + CRM_Core_DAO::executeQuery('TRUNCATE civicrm_relationship_cache'); foreach ($relUpdates as $relUpdate) { $relUpdate->execute(); } @@ -137,7 +137,7 @@ class CRM_Contact_BAO_RelationshipVortex extends CRM_Contact_DAO_RelationshipVor /** * Prepare a list of SQL queries that map data from civicrm_relationship - * to civicrm_relationship_vtx. + * to civicrm_relationship_cache. * * @return CRM_Utils_SQL_Select[] * A list of SQL queries - one for each mapping. @@ -147,7 +147,7 @@ class CRM_Contact_BAO_RelationshipVortex extends CRM_Contact_DAO_RelationshipVor foreach (self::$mappings as $name => $mapping) { $queries[$name] = CRM_Utils_SQL_Select::from('civicrm_relationship rel') ->join('reltype', 'INNER JOIN civicrm_relationship_type reltype ON rel.relationship_type_id = reltype.id') - ->syncInto('civicrm_relationship_vtx', self::$keyFields, $mapping); + ->syncInto('civicrm_relationship_cache', self::$keyFields, $mapping); } return $queries; } diff --git a/CRM/Contact/DAO/RelationshipVortex.php b/CRM/Contact/DAO/RelationshipCache.php similarity index 72% rename from CRM/Contact/DAO/RelationshipVortex.php rename to CRM/Contact/DAO/RelationshipCache.php index b20ff00465..f79fd1ee67 100644 --- a/CRM/Contact/DAO/RelationshipVortex.php +++ b/CRM/Contact/DAO/RelationshipCache.php @@ -4,22 +4,22 @@ * @package CRM * @copyright CiviCRM LLC https://civicrm.org/licensing * - * Generated from xml/schema/CRM/Contact/RelationshipVortex.xml + * Generated from xml/schema/CRM/Contact/RelationshipCache.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:01ed7a8f57a4438462decea08a76138a) + * (GenCodeChecksum:082fd4d2b313bc1928f56da80a620582) */ /** - * Database access object for the RelationshipVortex entity. + * Database access object for the RelationshipCache entity. */ -class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { +class CRM_Contact_DAO_RelationshipCache extends CRM_Core_DAO { /** * Static instance to hold the table name. * * @var string */ - public static $_tableName = 'civicrm_relationship_vtx'; + public static $_tableName = 'civicrm_relationship_cache'; /** * Icon associated with this entity. @@ -36,7 +36,7 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { public static $_log = FALSE; /** - * Relationship Vortex ID + * Relationship Cache ID * * @var int */ @@ -57,7 +57,7 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { public $relationship_type_id; /** - * The vortex record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship. + * The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship. * * @var string */ @@ -123,7 +123,7 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { * Class constructor. */ public function __construct() { - $this->__table = 'civicrm_relationship_vtx'; + $this->__table = 'civicrm_relationship_cache'; parent::__construct(); } @@ -131,7 +131,7 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { * Returns localized title of this entity. */ public static function getEntityTitle() { - return ts('Relationship Vortexes'); + return ts('Relationship Caches'); } /** @@ -164,13 +164,13 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 'id' => [ 'name' => 'id', 'type' => CRM_Utils_Type::T_INT, - 'title' => ts('Relationship Vortex ID'), - 'description' => ts('Relationship Vortex ID'), + 'title' => ts('Relationship Cache ID'), + 'description' => ts('Relationship Cache ID'), 'required' => TRUE, - 'where' => 'civicrm_relationship_vtx.id', - 'table_name' => 'civicrm_relationship_vtx', - 'entity' => 'RelationshipVortex', - 'bao' => 'CRM_Contact_BAO_RelationshipVortex', + 'where' => 'civicrm_relationship_cache.id', + 'table_name' => 'civicrm_relationship_cache', + 'entity' => 'RelationshipCache', + 'bao' => 'CRM_Contact_BAO_RelationshipCache', 'localizable' => 0, 'add' => '5.29', ], @@ -180,10 +180,10 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 'title' => ts('Relationship'), 'description' => ts('id of the relationship (FK to civicrm_relationship.id)'), 'required' => TRUE, - 'where' => 'civicrm_relationship_vtx.relationship_id', - 'table_name' => 'civicrm_relationship_vtx', - 'entity' => 'RelationshipVortex', - 'bao' => 'CRM_Contact_BAO_RelationshipVortex', + 'where' => 'civicrm_relationship_cache.relationship_id', + 'table_name' => 'civicrm_relationship_cache', + 'entity' => 'RelationshipCache', + 'bao' => 'CRM_Contact_BAO_RelationshipCache', 'localizable' => 0, 'FKClassName' => 'CRM_Contact_DAO_Relationship', 'add' => '5.29', @@ -194,10 +194,10 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 'title' => ts('Relationship Type'), 'description' => ts('id of the relationship type'), 'required' => TRUE, - 'where' => 'civicrm_relationship_vtx.relationship_type_id', - 'table_name' => 'civicrm_relationship_vtx', - 'entity' => 'RelationshipVortex', - 'bao' => 'CRM_Contact_BAO_RelationshipVortex', + 'where' => 'civicrm_relationship_cache.relationship_type_id', + 'table_name' => 'civicrm_relationship_cache', + 'entity' => 'RelationshipCache', + 'bao' => 'CRM_Contact_BAO_RelationshipCache', 'localizable' => 0, 'FKClassName' => 'CRM_Contact_DAO_RelationshipType', 'add' => '5.29', @@ -206,14 +206,14 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 'name' => 'orientation', 'type' => CRM_Utils_Type::T_STRING, 'title' => ts('Orientation (a_b or b_a)'), - 'description' => ts('The vortex record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.'), + 'description' => ts('The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.'), 'required' => TRUE, 'maxlength' => 3, 'size' => CRM_Utils_Type::FOUR, - 'where' => 'civicrm_relationship_vtx.orientation', - 'table_name' => 'civicrm_relationship_vtx', - 'entity' => 'RelationshipVortex', - 'bao' => 'CRM_Contact_BAO_RelationshipVortex', + 'where' => 'civicrm_relationship_cache.orientation', + 'table_name' => 'civicrm_relationship_cache', + 'entity' => 'RelationshipCache', + 'bao' => 'CRM_Contact_BAO_RelationshipCache', 'localizable' => 0, 'add' => '5.29', ], @@ -223,10 +223,10 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 'title' => ts('Contact ID (Near side)'), 'description' => ts('id of the first contact'), 'required' => TRUE, - 'where' => 'civicrm_relationship_vtx.near_contact_id', - 'table_name' => 'civicrm_relationship_vtx', - 'entity' => 'RelationshipVortex', - 'bao' => 'CRM_Contact_BAO_RelationshipVortex', + 'where' => 'civicrm_relationship_cache.near_contact_id', + 'table_name' => 'civicrm_relationship_cache', + 'entity' => 'RelationshipCache', + 'bao' => 'CRM_Contact_BAO_RelationshipCache', 'localizable' => 0, 'FKClassName' => 'CRM_Contact_DAO_Contact', 'add' => '5.29', @@ -238,10 +238,10 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 'description' => ts('name for relationship of near_contact to far_contact.'), 'maxlength' => 64, 'size' => CRM_Utils_Type::BIG, - 'where' => 'civicrm_relationship_vtx.near_relation', - 'table_name' => 'civicrm_relationship_vtx', - 'entity' => 'RelationshipVortex', - 'bao' => 'CRM_Contact_BAO_RelationshipVortex', + 'where' => 'civicrm_relationship_cache.near_relation', + 'table_name' => 'civicrm_relationship_cache', + 'entity' => 'RelationshipCache', + 'bao' => 'CRM_Contact_BAO_RelationshipCache', 'localizable' => 0, 'add' => '5.29', ], @@ -251,10 +251,10 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 'title' => ts('Contact ID (Far side)'), 'description' => ts('id of the second contact'), 'required' => TRUE, - 'where' => 'civicrm_relationship_vtx.far_contact_id', - 'table_name' => 'civicrm_relationship_vtx', - 'entity' => 'RelationshipVortex', - 'bao' => 'CRM_Contact_BAO_RelationshipVortex', + 'where' => 'civicrm_relationship_cache.far_contact_id', + 'table_name' => 'civicrm_relationship_cache', + 'entity' => 'RelationshipCache', + 'bao' => 'CRM_Contact_BAO_RelationshipCache', 'localizable' => 0, 'FKClassName' => 'CRM_Contact_DAO_Contact', 'html' => [ @@ -269,10 +269,10 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 'description' => ts('name for relationship of far_contact to near_contact.'), 'maxlength' => 64, 'size' => CRM_Utils_Type::BIG, - 'where' => 'civicrm_relationship_vtx.far_relation', - 'table_name' => 'civicrm_relationship_vtx', - 'entity' => 'RelationshipVortex', - 'bao' => 'CRM_Contact_BAO_RelationshipVortex', + 'where' => 'civicrm_relationship_cache.far_relation', + 'table_name' => 'civicrm_relationship_cache', + 'entity' => 'RelationshipCache', + 'bao' => 'CRM_Contact_BAO_RelationshipCache', 'localizable' => 0, 'add' => '5.29', ], @@ -281,11 +281,11 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Relationship Is Active'), 'description' => ts('is the relationship active ?'), - 'where' => 'civicrm_relationship_vtx.is_active', + 'where' => 'civicrm_relationship_cache.is_active', 'default' => '1', - 'table_name' => 'civicrm_relationship_vtx', - 'entity' => 'RelationshipVortex', - 'bao' => 'CRM_Contact_BAO_RelationshipVortex', + 'table_name' => 'civicrm_relationship_cache', + 'entity' => 'RelationshipCache', + 'bao' => 'CRM_Contact_BAO_RelationshipCache', 'localizable' => 0, 'html' => [ 'type' => 'CheckBox', @@ -297,10 +297,10 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Relationship Start Date'), 'description' => ts('date when the relationship started'), - 'where' => 'civicrm_relationship_vtx.start_date', - 'table_name' => 'civicrm_relationship_vtx', - 'entity' => 'RelationshipVortex', - 'bao' => 'CRM_Contact_BAO_RelationshipVortex', + 'where' => 'civicrm_relationship_cache.start_date', + 'table_name' => 'civicrm_relationship_cache', + 'entity' => 'RelationshipCache', + 'bao' => 'CRM_Contact_BAO_RelationshipCache', 'localizable' => 0, 'html' => [ 'type' => 'Select Date', @@ -313,10 +313,10 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Relationship End Date'), 'description' => ts('date when the relationship ended'), - 'where' => 'civicrm_relationship_vtx.end_date', - 'table_name' => 'civicrm_relationship_vtx', - 'entity' => 'RelationshipVortex', - 'bao' => 'CRM_Contact_BAO_RelationshipVortex', + 'where' => 'civicrm_relationship_cache.end_date', + 'table_name' => 'civicrm_relationship_cache', + 'entity' => 'RelationshipCache', + 'bao' => 'CRM_Contact_BAO_RelationshipCache', 'localizable' => 0, 'html' => [ 'type' => 'Select Date', @@ -329,11 +329,11 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_INT, 'title' => ts('Relationship Case'), 'description' => ts('FK to civicrm_case'), - 'where' => 'civicrm_relationship_vtx.case_id', + 'where' => 'civicrm_relationship_cache.case_id', 'default' => 'NULL', - 'table_name' => 'civicrm_relationship_vtx', - 'entity' => 'RelationshipVortex', - 'bao' => 'CRM_Contact_BAO_RelationshipVortex', + 'table_name' => 'civicrm_relationship_cache', + 'entity' => 'RelationshipCache', + 'bao' => 'CRM_Contact_BAO_RelationshipCache', 'localizable' => 0, 'FKClassName' => 'CRM_Case_DAO_Case', 'add' => '5.29', @@ -383,7 +383,7 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { * @return array */ public static function &import($prefix = FALSE) { - $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship_vtx', $prefix, []); + $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'relationship_cache', $prefix, []); return $r; } @@ -395,7 +395,7 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { * @return array */ public static function &export($prefix = FALSE) { - $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship_vtx', $prefix, []); + $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'relationship_cache', $prefix, []); return $r; } @@ -416,7 +416,7 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { ], 'localizable' => FALSE, 'unique' => TRUE, - 'sig' => 'civicrm_relationship_vtx::1::relationship_id::orientation', + 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation', ], 'index_nearid_nearrelation' => [ 'name' => 'index_nearid_nearrelation', @@ -425,7 +425,7 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 1 => 'near_relation', ], 'localizable' => FALSE, - 'sig' => 'civicrm_relationship_vtx::0::near_contact_id::near_relation', + 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation', ], 'index_nearid_farrelation' => [ 'name' => 'index_nearid_farrelation', @@ -434,7 +434,7 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 1 => 'far_relation', ], 'localizable' => FALSE, - 'sig' => 'civicrm_relationship_vtx::0::near_contact_id::far_relation', + 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation', ], 'index_near_relation' => [ 'name' => 'index_near_relation', @@ -442,7 +442,7 @@ class CRM_Contact_DAO_RelationshipVortex extends CRM_Core_DAO { 0 => 'near_relation', ], 'localizable' => FALSE, - 'sig' => 'civicrm_relationship_vtx::0::near_relation', + 'sig' => 'civicrm_relationship_cache::0::near_relation', ], ]; return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; diff --git a/CRM/Core/DAO/AllCoreTables.data.php b/CRM/Core/DAO/AllCoreTables.data.php index db3fd969dd..fcf35a9eed 100644 --- a/CRM/Core/DAO/AllCoreTables.data.php +++ b/CRM/Core/DAO/AllCoreTables.data.php @@ -567,10 +567,10 @@ return [ 'class' => 'CRM_Contact_DAO_Relationship', 'table' => 'civicrm_relationship', ], - 'CRM_Contact_DAO_RelationshipVortex' => [ - 'name' => 'RelationshipVortex', - 'class' => 'CRM_Contact_DAO_RelationshipVortex', - 'table' => 'civicrm_relationship_vtx', + 'CRM_Contact_DAO_RelationshipCache' => [ + 'name' => 'RelationshipCache', + 'class' => 'CRM_Contact_DAO_RelationshipCache', + 'table' => 'civicrm_relationship_cache', ], 'CRM_Mailing_DAO_Mailing' => [ 'name' => 'Mailing', diff --git a/CRM/Upgrade/Incremental/php/FiveTwentyNine.php b/CRM/Upgrade/Incremental/php/FiveTwentyNine.php index bb2aa19ca8..f384a5f57a 100644 --- a/CRM/Upgrade/Incremental/php/FiveTwentyNine.php +++ b/CRM/Upgrade/Incremental/php/FiveTwentyNine.php @@ -65,12 +65,12 @@ class CRM_Upgrade_Incremental_php_FiveTwentyNine extends CRM_Upgrade_Incremental FROM civicrm_relationship ")->getDatabaseResult()->fetchRow(); for ($startId = $minId; $startId <= $maxId; $startId += self::BATCH_SIZE) { $endId = $startId + self::BATCH_SIZE - 1; - $title = ts("Upgrade DB to %1: Fill civicrm_relationship_vtx (%2 => %3)", [ + $title = ts("Upgrade DB to %1: Fill civicrm_relationship_cache (%2 => %3)", [ 1 => $rev, 2 => $startId, 3 => $endId, ]); - $this->addTask($title, 'populateRelationshipVortex', $startId, $endId); + $this->addTask($title, 'populateRelationshipCache', $startId, $endId); } } @@ -115,8 +115,8 @@ class CRM_Upgrade_Incremental_php_FiveTwentyNine extends CRM_Upgrade_Incremental * @return bool * TRUE on success */ - public static function populateRelationshipVortex(CRM_Queue_TaskContext $ctx, $startId, $endId) { - // NOTE: We duplicate CRM_Contact_BAO_RelationshipVortex::$mappings in case + public static function populateRelationshipCache(CRM_Queue_TaskContext $ctx, $startId, $endId) { + // NOTE: We duplicate CRM_Contact_BAO_RelationshipCache::$mappings in case // the schema evolves over multiple releases. $mappings = [ 'a_b' => [ @@ -151,7 +151,7 @@ class CRM_Upgrade_Incremental_php_FiveTwentyNine extends CRM_Upgrade_Incremental foreach ($mappings as $mapping) { $query = CRM_Utils_SQL_Select::from('civicrm_relationship rel') ->join('reltype', 'INNER JOIN civicrm_relationship_type reltype ON rel.relationship_type_id = reltype.id') - ->syncInto('civicrm_relationship_vtx', $keyFields, $mapping) + ->syncInto('civicrm_relationship_cache', $keyFields, $mapping) ->where('rel.id >= #START AND rel.id <= #END', [ '#START' => $startId, '#END' => $endId, diff --git a/CRM/Upgrade/Incremental/sql/5.29.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.29.alpha1.mysql.tpl index 2fefa417eb..3483c5ebde 100644 --- a/CRM/Upgrade/Incremental/sql/5.29.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/5.29.alpha1.mysql.tpl @@ -1,12 +1,12 @@ {* file to handle db changes in 5.29.alpha1 during upgrade *} --- The RelationshipVortex is a high-level index/cache for querying relationships. -DROP TABLE IF EXISTS `civicrm_relationship_vtx`; -CREATE TABLE `civicrm_relationship_vtx` ( - `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Relationship Vortex ID', +-- The RelationshipCache is a high-level index/cache for querying relationships. +DROP TABLE IF EXISTS `civicrm_relationship_cache`; +CREATE TABLE `civicrm_relationship_cache` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Relationship Cache ID', `relationship_id` int unsigned NOT NULL COMMENT 'id of the relationship (FK to civicrm_relationship.id)', `relationship_type_id` int unsigned NOT NULL COMMENT 'id of the relationship type', - `orientation` char(3) NOT NULL COMMENT 'The vortex record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.', + `orientation` char(3) NOT NULL COMMENT 'The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.', `near_contact_id` int unsigned NOT NULL COMMENT 'id of the first contact', `near_relation` varchar(64) COMMENT 'name for relationship of near_contact to far_contact.', `far_contact_id` int unsigned NOT NULL COMMENT 'id of the second contact', @@ -20,9 +20,9 @@ CREATE TABLE `civicrm_relationship_vtx` ( INDEX `index_nearid_nearrelation`(near_contact_id, near_relation), INDEX `index_nearid_farrelation`(near_contact_id, far_relation), INDEX `index_near_relation`(near_relation), - CONSTRAINT FK_civicrm_relationship_vtx_relationship_id FOREIGN KEY (`relationship_id`) REFERENCES `civicrm_relationship`(`id`) ON DELETE CASCADE, - CONSTRAINT FK_civicrm_relationship_vtx_relationship_type_id FOREIGN KEY (`relationship_type_id`) REFERENCES `civicrm_relationship_type`(`id`) ON DELETE CASCADE, - CONSTRAINT FK_civicrm_relationship_vtx_near_contact_id FOREIGN KEY (`near_contact_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE CASCADE, - CONSTRAINT FK_civicrm_relationship_vtx_far_contact_id FOREIGN KEY (`far_contact_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE CASCADE, - CONSTRAINT FK_civicrm_relationship_vtx_case_id FOREIGN KEY (`case_id`) REFERENCES `civicrm_case`(`id`) ON DELETE CASCADE + CONSTRAINT FK_civicrm_relationship_cache_relationship_id FOREIGN KEY (`relationship_id`) REFERENCES `civicrm_relationship`(`id`) ON DELETE CASCADE, + CONSTRAINT FK_civicrm_relationship_cache_relationship_type_id FOREIGN KEY (`relationship_type_id`) REFERENCES `civicrm_relationship_type`(`id`) ON DELETE CASCADE, + CONSTRAINT FK_civicrm_relationship_cache_near_contact_id FOREIGN KEY (`near_contact_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE CASCADE, + CONSTRAINT FK_civicrm_relationship_cache_far_contact_id FOREIGN KEY (`far_contact_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE CASCADE, + CONSTRAINT FK_civicrm_relationship_cache_case_id FOREIGN KEY (`case_id`) REFERENCES `civicrm_case`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index 624e8659fa..2e2435a30f 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -355,7 +355,7 @@ class Container { $dispatcher->addListener('hook_civicrm_coreResourceList', ['\CRM_Utils_System', 'appendCoreResources']); $dispatcher->addListener('hook_civicrm_getAssetUrl', ['\CRM_Utils_System', 'alterAssetUrl']); $dispatcher->addListener('hook_civicrm_alterExternUrl', ['\CRM_Utils_System', 'migrateExternUrl'], 1000); - $dispatcher->addListener('hook_civicrm_triggerInfo', ['\CRM_Contact_BAO_RelationshipVortex', 'onHookTriggerInfo']); + $dispatcher->addListener('hook_civicrm_triggerInfo', ['\CRM_Contact_BAO_RelationshipCache', 'onHookTriggerInfo']); $dispatcher->addListener('civi.dao.postInsert', ['\CRM_Core_BAO_RecurringEntity', 'triggerInsert']); $dispatcher->addListener('civi.dao.postUpdate', ['\CRM_Core_BAO_RecurringEntity', 'triggerUpdate']); $dispatcher->addListener('civi.dao.postDelete', ['\CRM_Core_BAO_RecurringEntity', 'triggerDelete']); diff --git a/tests/phpunit/CRM/Contact/BAO/RelationshipVortexTest.php b/tests/phpunit/CRM/Contact/BAO/RelationshipCacheTest.php similarity index 83% rename from tests/phpunit/CRM/Contact/BAO/RelationshipVortexTest.php rename to tests/phpunit/CRM/Contact/BAO/RelationshipCacheTest.php index e3c654c38f..9c5f900178 100644 --- a/tests/phpunit/CRM/Contact/BAO/RelationshipVortexTest.php +++ b/tests/phpunit/CRM/Contact/BAO/RelationshipCacheTest.php @@ -10,12 +10,12 @@ */ /** - * Test class for CRM_Contact_BAO_RelationshipVortex + * Test class for CRM_Contact_BAO_RelationshipCache * * @package CiviCRM * @group headless */ -class RelationshipVortexTest extends CiviUnitTestCase { +class RelationshipCacheTest extends CiviUnitTestCase { protected function setUp() { $this->useTransaction(TRUE); @@ -24,9 +24,9 @@ class RelationshipVortexTest extends CiviUnitTestCase { /** * Whenever one `Relationship` is created, there should be two corresponding - * `RelationshipVortex` records. + * `RelationshipCache` records. */ - public function testRelationshipVortex() { + public function testRelationshipCache() { // add a new type $relationship_type_id_1 = $this->relationshipTypeCreate([ 'name_a_b' => 'Praegustator is', @@ -47,14 +47,14 @@ class RelationshipVortexTest extends CiviUnitTestCase { ]; $relationshipObj = CRM_Contact_BAO_Relationship::add($params); - // Let's make sure the vortex records were created! - $vtxs = CRM_Core_DAO::executeQuery('SELECT * FROM civicrm_relationship_vtx WHERE relationship_id = %1', [ + // Let's make sure the cache records were created! + $caches = CRM_Core_DAO::executeQuery('SELECT * FROM civicrm_relationship_cache WHERE relationship_id = %1', [ 1 => [$relationshipObj->id, 'Positive'], ])->fetchAll(); // There should be two records - the a_b record and the b_a record. - $this->assertCount(2, $vtxs); - $idx = CRM_Utils_Array::index(['orientation'], $vtxs); + $this->assertCount(2, $caches); + $idx = CRM_Utils_Array::index(['orientation'], $caches); $this->assertEquals($relationship_type_id_1, $idx['a_b']['relationship_type_id']); $this->assertEquals($contact_id_1, $idx['a_b']['near_contact_id']); diff --git a/tests/phpunit/CRM/Dedupe/MergerTest.php b/tests/phpunit/CRM/Dedupe/MergerTest.php index eba607a801..c0709f0c56 100644 --- a/tests/phpunit/CRM/Dedupe/MergerTest.php +++ b/tests/phpunit/CRM/Dedupe/MergerTest.php @@ -300,7 +300,7 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase { $this->assertEquals($sortRefs(array_diff_key($this->getCalculatedCIDRefs(), $unsetRefs)), $sortRefs(CRM_Dedupe_Merger::cidRefs())); // These are deliberately unset. - // $unsetRefs = array_fill_keys(['civicrm_group_contact_cache', 'civicrm_acl_cache', 'civicrm_acl_contact_cache', 'civicrm_relationship_vtx'], 1); + // $unsetRefs = array_fill_keys(['civicrm_group_contact_cache', 'civicrm_acl_cache', 'civicrm_acl_contact_cache', 'civicrm_relationship_cache'], 1); // $this->assertEquals(array_diff_key($this->getStaticCIDRefs(), $unsetRefs), CRM_Dedupe_Merger::cidRefs()); // $this->assertEquals(array_diff_key($this->getCalculatedCIDRefs(), $unsetRefs), CRM_Dedupe_Merger::cidRefs()); } @@ -1343,7 +1343,7 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase { 0 => 'contact_id_a', 1 => 'contact_id_b', ], - 'civicrm_relationship_vtx' => [ + 'civicrm_relationship_cache' => [ 0 => 'near_contact_id', 1 => 'far_contact_id', ], diff --git a/xml/schema/Contact/RelationshipVortex.xml b/xml/schema/Contact/RelationshipCache.xml similarity index 83% rename from xml/schema/Contact/RelationshipVortex.xml rename to xml/schema/Contact/RelationshipCache.xml index c18ac9154f..3c80d0e183 100644 --- a/xml/schema/Contact/RelationshipVortex.xml +++ b/xml/schema/Contact/RelationshipCache.xml @@ -2,9 +2,9 @@ CRM/Contact - RelationshipVortex - civicrm_relationship_vtx - The vortex permutes information from the relationship table to facilitate querying. Every relationship is mapped to multiple records in the vortex. Joins should begin on the near side and extract info from the far side. + RelationshipCache + civicrm_relationship_cache + The cache permutes information from the relationship table to facilitate querying. Every relationship is mapped to multiple records in the cache. Joins should begin on the near side and extract info from the far side.5.29falsefa-handshake-o @@ -12,9 +12,9 @@ id int unsigned - Relationship Vortex ID + Relationship Cache ID true - Relationship Vortex ID + Relationship Cache ID 5.29 @@ -61,7 +61,7 @@ Orientation (a_b or b_a) true - The vortex record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship. + The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship. 5.29 @@ -126,21 +126,21 @@ 5.29 - + index_nearid_nearrelation near_contact_id near_relation 5.29 - + index_nearid_farrelation near_contact_id far_relation 5.29 - + index_near_relation near_relation 5.29 diff --git a/xml/schema/Contact/files.xml b/xml/schema/Contact/files.xml index dd9ea40d1c..7ffa2241ce 100644 --- a/xml/schema/Contact/files.xml +++ b/xml/schema/Contact/files.xml @@ -13,7 +13,7 @@ - + -- 2.25.1