From 83225dce9c266d49465f12274943b9db769b561a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 29 Jan 2021 19:28:06 -0500 Subject: [PATCH 1/2] Remove campaign_id pseudoconstants Pseudoconstants are intended for option lists small enough to be loaded into memory, whereas FKs are for options of any size. It is possible to have thousands of campaigns, and some sites do, which slows or breaks some UIs (first noticed in the Search Kit bulk update action). All these fields have both an FK and a pseudoconstant declared, which is redundant; both are not needed, and the pseudoconstant was unnecessarily hogging memory for sites with many campaigns. --- CRM/Activity/DAO/Activity.php | 7 +------ CRM/Campaign/DAO/CampaignGroup.php | 7 +------ CRM/Campaign/DAO/Survey.php | 7 +------ CRM/Contribute/DAO/Contribution.php | 7 +------ CRM/Contribute/DAO/ContributionPage.php | 7 +------ CRM/Contribute/DAO/ContributionRecur.php | 7 +------ CRM/Event/DAO/Event.php | 7 +------ CRM/Event/DAO/Participant.php | 7 +------ CRM/Mailing/DAO/Mailing.php | 7 +------ CRM/Member/DAO/Membership.php | 7 +------ CRM/Pledge/DAO/Pledge.php | 7 +------ xml/schema/Activity/Activity.xml | 5 ----- xml/schema/Campaign/CampaignGroup.xml | 5 ----- xml/schema/Campaign/Survey.xml | 5 ----- xml/schema/Contribute/Contribution.xml | 5 ----- xml/schema/Contribute/ContributionPage.xml | 5 ----- xml/schema/Contribute/ContributionRecur.xml | 5 ----- xml/schema/Event/Event.xml | 5 ----- xml/schema/Event/Participant.xml | 5 ----- xml/schema/Mailing/Mailing.xml | 5 ----- xml/schema/Member/Membership.xml | 5 ----- xml/schema/Pledge/Pledge.xml | 5 ----- 22 files changed, 11 insertions(+), 121 deletions(-) diff --git a/CRM/Activity/DAO/Activity.php b/CRM/Activity/DAO/Activity.php index 6d764364cbc5..e1acd532bc8b 100644 --- a/CRM/Activity/DAO/Activity.php +++ b/CRM/Activity/DAO/Activity.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Activity/Activity.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:20d5b91c29b14f4df12aabfc07c58e94) + * (GenCodeChecksum:e40c263d7d030dc0c6d6e714317a3970) */ /** @@ -659,11 +659,6 @@ public static function &fields() { 'html' => [ 'type' => 'Select', ], - 'pseudoconstant' => [ - 'table' => 'civicrm_campaign', - 'keyColumn' => 'id', - 'labelColumn' => 'title', - ], 'add' => '3.4', ], 'activity_engagement_level' => [ diff --git a/CRM/Campaign/DAO/CampaignGroup.php b/CRM/Campaign/DAO/CampaignGroup.php index a448bd16fb08..96863381a859 100644 --- a/CRM/Campaign/DAO/CampaignGroup.php +++ b/CRM/Campaign/DAO/CampaignGroup.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Campaign/CampaignGroup.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:88f73bc59595d75977b66fe76466a22c) + * (GenCodeChecksum:a10a2acb5e6198e023bf1b97883b16cf) */ /** @@ -133,11 +133,6 @@ public static function &fields() { 'bao' => 'CRM_Campaign_DAO_CampaignGroup', 'localizable' => 0, 'FKClassName' => 'CRM_Campaign_DAO_Campaign', - 'pseudoconstant' => [ - 'table' => 'civicrm_campaign', - 'keyColumn' => 'id', - 'labelColumn' => 'title', - ], 'add' => '3.3', ], 'group_type' => [ diff --git a/CRM/Campaign/DAO/Survey.php b/CRM/Campaign/DAO/Survey.php index aa303547eef3..72c340664801 100644 --- a/CRM/Campaign/DAO/Survey.php +++ b/CRM/Campaign/DAO/Survey.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Campaign/Survey.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:03edb270b63048ec3aa9f36667548961) + * (GenCodeChecksum:8a55f06388a594dd78f397320b1b55a6) */ /** @@ -270,11 +270,6 @@ public static function &fields() { 'bao' => 'CRM_Campaign_BAO_Survey', 'localizable' => 0, 'FKClassName' => 'CRM_Campaign_DAO_Campaign', - 'pseudoconstant' => [ - 'table' => 'civicrm_campaign', - 'keyColumn' => 'id', - 'labelColumn' => 'title', - ], 'add' => '3.3', ], 'activity_type_id' => [ diff --git a/CRM/Contribute/DAO/Contribution.php b/CRM/Contribute/DAO/Contribution.php index e9936e8cf2eb..b8c6b0a03c04 100644 --- a/CRM/Contribute/DAO/Contribution.php +++ b/CRM/Contribute/DAO/Contribution.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Contribute/Contribution.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:11b9f8bc6198e4338be2406de58b6723) + * (GenCodeChecksum:66fa0e83ae7eb57a3c2e515c8fdc371c) */ /** @@ -843,11 +843,6 @@ public static function &fields() { 'html' => [ 'type' => 'Select', ], - 'pseudoconstant' => [ - 'table' => 'civicrm_campaign', - 'keyColumn' => 'id', - 'labelColumn' => 'title', - ], 'add' => '3.4', ], 'creditnote_id' => [ diff --git a/CRM/Contribute/DAO/ContributionPage.php b/CRM/Contribute/DAO/ContributionPage.php index e38ebbf9fe1f..adc5656538a1 100644 --- a/CRM/Contribute/DAO/ContributionPage.php +++ b/CRM/Contribute/DAO/ContributionPage.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Contribute/ContributionPage.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:958ef76562a951e9f80b8e6f16afd6ee) + * (GenCodeChecksum:a8f42298c3fbe5b8c1986c81d77a8a0f) */ /** @@ -1033,11 +1033,6 @@ public static function &fields() { 'bao' => 'CRM_Contribute_BAO_ContributionPage', 'localizable' => 0, 'FKClassName' => 'CRM_Campaign_DAO_Campaign', - 'pseudoconstant' => [ - 'table' => 'civicrm_campaign', - 'keyColumn' => 'id', - 'labelColumn' => 'title', - ], 'add' => '3.4', ], 'is_share' => [ diff --git a/CRM/Contribute/DAO/ContributionRecur.php b/CRM/Contribute/DAO/ContributionRecur.php index 9bed9fd903ad..08f922a170a9 100644 --- a/CRM/Contribute/DAO/ContributionRecur.php +++ b/CRM/Contribute/DAO/ContributionRecur.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Contribute/ContributionRecur.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:5e2fa2241a3f8c014352d897be31fad1) + * (GenCodeChecksum:69bfc032333f519d938978caf8d9d7ec) */ /** @@ -771,11 +771,6 @@ public static function &fields() { 'html' => [ 'type' => 'Select', ], - 'pseudoconstant' => [ - 'table' => 'civicrm_campaign', - 'keyColumn' => 'id', - 'labelColumn' => 'title', - ], 'add' => '4.1', ], 'is_email_receipt' => [ diff --git a/CRM/Event/DAO/Event.php b/CRM/Event/DAO/Event.php index ea4305c1da9e..757ff158d46f 100644 --- a/CRM/Event/DAO/Event.php +++ b/CRM/Event/DAO/Event.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Event/Event.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:8747fe6387fcdec07b14c8a72e35868b) + * (GenCodeChecksum:c4d88cf24f327dc7f2f303f316e200c7) */ /** @@ -1637,11 +1637,6 @@ public static function &fields() { 'html' => [ 'type' => 'EntityRef', ], - 'pseudoconstant' => [ - 'table' => 'civicrm_campaign', - 'keyColumn' => 'id', - 'labelColumn' => 'title', - ], 'add' => '3.4', ], 'is_share' => [ diff --git a/CRM/Event/DAO/Participant.php b/CRM/Event/DAO/Participant.php index 34537d28fa41..090bb8fe0374 100644 --- a/CRM/Event/DAO/Participant.php +++ b/CRM/Event/DAO/Participant.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Event/Participant.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:a746f8f8a28c6f945abbba148794d2c2) + * (GenCodeChecksum:f9815c8a89ad1055602bed39a0f266e8) */ /** @@ -495,11 +495,6 @@ public static function &fields() { 'bao' => 'CRM_Event_BAO_Participant', 'localizable' => 0, 'FKClassName' => 'CRM_Campaign_DAO_Campaign', - 'pseudoconstant' => [ - 'table' => 'civicrm_campaign', - 'keyColumn' => 'id', - 'labelColumn' => 'title', - ], 'add' => '3.4', ], 'discount_amount' => [ diff --git a/CRM/Mailing/DAO/Mailing.php b/CRM/Mailing/DAO/Mailing.php index 0f754955da18..c76e999c8cb9 100644 --- a/CRM/Mailing/DAO/Mailing.php +++ b/CRM/Mailing/DAO/Mailing.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Mailing/Mailing.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:e2de6d8875a7f838b190810bcec4e27e) + * (GenCodeChecksum:9e22faebb14e886d7a5b4382249a0da6) */ /** @@ -968,11 +968,6 @@ public static function &fields() { 'html' => [ 'type' => 'Select', ], - 'pseudoconstant' => [ - 'table' => 'civicrm_campaign', - 'keyColumn' => 'id', - 'labelColumn' => 'title', - ], 'add' => '3.4', ], 'dedupe_email' => [ diff --git a/CRM/Member/DAO/Membership.php b/CRM/Member/DAO/Membership.php index 3b4cc6356269..a72f2fc14413 100644 --- a/CRM/Member/DAO/Membership.php +++ b/CRM/Member/DAO/Membership.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Member/Membership.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:497f88dd714287acb6b42017dc0b7cd3) + * (GenCodeChecksum:614dc19edb8e63eb4a8a4c3523454511) */ /** @@ -502,11 +502,6 @@ public static function &fields() { 'html' => [ 'type' => 'Select', ], - 'pseudoconstant' => [ - 'table' => 'civicrm_campaign', - 'keyColumn' => 'id', - 'labelColumn' => 'title', - ], 'add' => '3.4', ], ]; diff --git a/CRM/Pledge/DAO/Pledge.php b/CRM/Pledge/DAO/Pledge.php index c9ff550a9bf2..bb23c622e876 100644 --- a/CRM/Pledge/DAO/Pledge.php +++ b/CRM/Pledge/DAO/Pledge.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Pledge/Pledge.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:8a17ba664d9a2c65860be67652def7f5) + * (GenCodeChecksum:b7f0823c6d9fed7969a2734874ed20eb) */ /** @@ -657,11 +657,6 @@ public static function &fields() { 'html' => [ 'type' => 'Select', ], - 'pseudoconstant' => [ - 'table' => 'civicrm_campaign', - 'keyColumn' => 'id', - 'labelColumn' => 'title', - ], 'add' => '3.4', ], ]; diff --git a/xml/schema/Activity/Activity.xml b/xml/schema/Activity/Activity.xml index 3f7ee3169ca3..74f16248640c 100644 --- a/xml/schema/Activity/Activity.xml +++ b/xml/schema/Activity/Activity.xml @@ -339,11 +339,6 @@ Campaign true The campaign for which this activity has been triggered. - - civicrm_campaign
- id - title -
3.4 Select diff --git a/xml/schema/Campaign/CampaignGroup.xml b/xml/schema/Campaign/CampaignGroup.xml index ea143c1d1c48..1c1b40808209 100644 --- a/xml/schema/Campaign/CampaignGroup.xml +++ b/xml/schema/Campaign/CampaignGroup.xml @@ -25,11 +25,6 @@ int unsigned true Foreign key to the activity Campaign. - - civicrm_campaign
- id - title -
3.3 diff --git a/xml/schema/Campaign/Survey.xml b/xml/schema/Campaign/Survey.xml index 821af4bd4f41..bfe0cf95c0bb 100644 --- a/xml/schema/Campaign/Survey.xml +++ b/xml/schema/Campaign/Survey.xml @@ -39,11 +39,6 @@ int unsigned NULL Foreign key to the Campaign. - - civicrm_campaign
- id - title -
3.3 diff --git a/xml/schema/Contribute/Contribution.xml b/xml/schema/Contribute/Contribution.xml index 6c725b1ddc28..b09ee78061f2 100644 --- a/xml/schema/Contribute/Contribution.xml +++ b/xml/schema/Contribute/Contribution.xml @@ -451,11 +451,6 @@ Campaign true The campaign for which this contribution has been triggered. - - civicrm_campaign
- id - title -
3.4 Select diff --git a/xml/schema/Contribute/ContributionPage.xml b/xml/schema/Contribute/ContributionPage.xml index a8db2380f4a6..52f1df5eabbc 100644 --- a/xml/schema/Contribute/ContributionPage.xml +++ b/xml/schema/Contribute/ContributionPage.xml @@ -420,11 +420,6 @@ Contribution Page Campaign ID int unsigned The campaign for which we are collecting contributions with this page. - - civicrm_campaign
- id - title -
3.4 diff --git a/xml/schema/Contribute/ContributionRecur.xml b/xml/schema/Contribute/ContributionRecur.xml index fa78706c182e..fd6b8a948c62 100644 --- a/xml/schema/Contribute/ContributionRecur.xml +++ b/xml/schema/Contribute/ContributionRecur.xml @@ -408,11 +408,6 @@ Campaign true The campaign for which this contribution has been triggered. - - civicrm_campaign
- id - title -
4.1 Select diff --git a/xml/schema/Event/Event.xml b/xml/schema/Event/Event.xml index e6682fe97f27..f0ff62f4eab5 100644 --- a/xml/schema/Event/Event.xml +++ b/xml/schema/Event/Event.xml @@ -771,11 +771,6 @@ int unsigned Campaign The campaign for which this event has been created. - - civicrm_campaign
- id - title -
3.4 EntityRef diff --git a/xml/schema/Event/Participant.xml b/xml/schema/Event/Participant.xml index 6fd2a94f542b..44ecd7847ed1 100644 --- a/xml/schema/Event/Participant.xml +++ b/xml/schema/Event/Participant.xml @@ -249,11 +249,6 @@ Campaign true The campaign for which this participant has been registered. - - civicrm_campaign
- id - title -
3.4 diff --git a/xml/schema/Mailing/Mailing.xml b/xml/schema/Mailing/Mailing.xml index 45264afb4499..0b3422b8c3a6 100644 --- a/xml/schema/Mailing/Mailing.xml +++ b/xml/schema/Mailing/Mailing.xml @@ -415,11 +415,6 @@ int unsigned Mailing Campaign The campaign for which this mailing has been initiated. - - civicrm_campaign
- id - title -
3.4 Select diff --git a/xml/schema/Member/Membership.xml b/xml/schema/Member/Membership.xml index f8be7b360763..4a25c013c582 100644 --- a/xml/schema/Member/Membership.xml +++ b/xml/schema/Member/Membership.xml @@ -269,11 +269,6 @@ Campaign true The campaign for which this membership is attached. - - civicrm_campaign
- id - title -
3.4 Select diff --git a/xml/schema/Pledge/Pledge.xml b/xml/schema/Pledge/Pledge.xml index 6b967254f5a0..2f86cdef661f 100644 --- a/xml/schema/Pledge/Pledge.xml +++ b/xml/schema/Pledge/Pledge.xml @@ -325,11 +325,6 @@ Campaign true The campaign for which this pledge has been initiated. - - civicrm_campaign
- id - title -
3.4 Select From dbf668ee1f71befb3e5d7fa38c04bd456790ffe4 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 29 Jan 2021 21:45:07 -0500 Subject: [PATCH 2/2] Remove campaign pseudoconstants from tests --- tests/phpunit/CRM/Core/PseudoConstantTest.php | 53 ------------------- tests/phpunit/CRM/Export/BAO/ExportTest.php | 2 +- 2 files changed, 1 insertion(+), 54 deletions(-) diff --git a/tests/phpunit/CRM/Core/PseudoConstantTest.php b/tests/phpunit/CRM/Core/PseudoConstantTest.php index d83d48f28f3c..36a1dc33b73b 100644 --- a/tests/phpunit/CRM/Core/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Core/PseudoConstantTest.php @@ -81,15 +81,6 @@ public function testOptionValues() { ]; $result = civicrm_api3('payment_processor', 'create', $api_params); - // Create a Campaign for testing. - $campaign_name = md5(microtime()); - $api_params = [ - 'title' => $campaign_name, - 'is_active' => TRUE, - 'status_id' => 2, - ]; - $result = civicrm_api3('campaign', 'create', $api_params); - // Create a membership type for testing. $membership_type = md5(microtime()); $api_params = [ @@ -243,10 +234,6 @@ public function testOptionValues() { 'fieldName' => 'medium_id', 'sample' => 'Phone', ], - [ - 'fieldName' => 'campaign_id', - 'sample' => $campaign_name, - ], ], 'CRM_Campaign_DAO_Campaign' => [ [ @@ -261,10 +248,6 @@ public function testOptionValues() { ], ], 'CRM_Campaign_DAO_Survey' => [ - [ - 'fieldName' => 'campaign_id', - 'sample' => $campaign_name, - ], [ 'fieldName' => 'activity_type_id', 'sample' => 'Phone Call', @@ -272,10 +255,6 @@ public function testOptionValues() { ], ], 'CRM_Campaign_DAO_CampaignGroup' => [ - [ - 'fieldName' => 'campaign_id', - 'sample' => $campaign_name, - ], [ 'fieldName' => 'group_type', 'sample' => 'Include', @@ -499,10 +478,6 @@ public function testOptionValues() { 'fieldName' => 'payment_instrument_id', 'sample' => 'Check', ], - [ - 'fieldName' => 'campaign_id', - 'sample' => $campaign_name, - ], ], 'CRM_Pledge_DAO_PledgePayment' => [ [ @@ -525,10 +500,6 @@ public function testOptionValues() { 'fieldName' => 'frequency_unit', 'sample' => 'month', ], - [ - 'fieldName' => 'campaign_id', - 'sample' => $campaign_name, - ], ], 'CRM_PCP_DAO_PCP' => [ [ @@ -778,10 +749,6 @@ public function testOptionValues() { 'sample' => ['USD' => 'US Dollar'], 'max' => 200, ], - [ - 'fieldName' => 'campaign_id', - 'sample' => $campaign_name, - ], ], 'CRM_Event_DAO_Event' => [ [ @@ -809,10 +776,6 @@ public function testOptionValues() { 'sample' => ['USD' => 'US Dollar'], 'max' => 200, ], - [ - 'fieldName' => 'campaign_id', - 'sample' => $campaign_name, - ], ], 'CRM_Core_DAO_Menu' => [ [ @@ -833,10 +796,6 @@ public function testOptionValues() { 'fieldName' => 'status_id', 'sample' => 'New', ], - [ - 'fieldName' => 'campaign_id', - 'sample' => $campaign_name, - ], ], 'CRM_Member_DAO_MembershipStatus' => [ [ @@ -891,10 +850,6 @@ public function testOptionValues() { 'fieldName' => 'visibility', 'sample' => 'Public Pages', ], - [ - 'fieldName' => 'campaign_id', - 'sample' => $campaign_name, - ], ], 'CRM_Mailing_DAO_MailingComponent' => [ [ @@ -967,10 +922,6 @@ public function testOptionValues() { 'fieldName' => 'contribution_page_id', 'sample' => $contribution_page, ], - [ - 'fieldName' => 'campaign_id', - 'sample' => $campaign_name, - ], ], 'CRM_Contribute_DAO_PremiumsProduct' => [ [ @@ -992,10 +943,6 @@ public function testOptionValues() { 'sample' => ['USD' => 'US Dollar'], 'max' => 200, ], - [ - 'fieldName' => 'campaign_id', - 'sample' => $campaign_name, - ], ], 'CRM_Case_DAO_Case' => [ [ diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index 49d0500a2109..fbcc2897148a 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -574,7 +574,7 @@ public function testExportPseudoField() { public function testExportPseudoFieldCampaign() { $this->setUpContributionExportData(); $campaign = $this->callAPISuccess('Campaign', 'create', ['title' => 'Big campaign and kinda long too']); - $this->callAPISuccess('Contribution', 'create', ['campaign_id' => 'Big_campaign_and_kinda_long_too', 'id' => $this->contributionIDs[0]]); + $this->callAPISuccess('Contribution', 'create', ['campaign_id' => $campaign['id'], 'id' => $this->contributionIDs[0]]); $selectedFields = [ ['contact_type' => 'Individual', 'name' => 'gender_id'], ['contact_type' => 'Contribution', 'name' => 'contribution_campaign_title'],