From e9d6557cff448c42f07c50d7b8776bcf1e27a332 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 1 Apr 2023 20:38:51 -0400 Subject: [PATCH] BAO - Deprecate setIsActive BAO functions --- CRM/ACL/BAO/ACL.php | 12 ++----- CRM/ACL/BAO/ACLEntityRole.php | 8 ++--- CRM/Badge/BAO/Layout.php | 8 ++--- CRM/Campaign/BAO/Campaign.php | 8 ++--- CRM/Campaign/BAO/Survey.php | 8 ++--- CRM/Contact/BAO/ContactType.php | 8 ++--- CRM/Contact/BAO/Group.php | 7 +---- CRM/Contact/BAO/RelationshipType.php | 8 ++--- CRM/Contribute/BAO/ContributionPage.php | 8 +---- CRM/Contribute/BAO/Premium.php | 8 ++--- CRM/Contribute/BAO/Product.php | 7 ++--- CRM/Core/BAO/ActionSchedule.php | 8 ++--- CRM/Core/BAO/CustomField.php | 9 ++---- CRM/Core/BAO/CustomGroup.php | 8 ++--- CRM/Core/BAO/Job.php | 8 ++--- CRM/Core/BAO/LocationType.php | 8 ++--- CRM/Core/BAO/MessageTemplate.php | 8 ++--- CRM/Core/BAO/Navigation.php | 8 ++--- CRM/Core/BAO/OptionGroup.php | 8 ++--- CRM/Core/BAO/OptionValue.php | 7 +---- CRM/Core/BAO/UFField.php | 7 +---- CRM/Core/BAO/UFGroup.php | 7 +---- CRM/Event/BAO/Event.php | 8 ++--- CRM/Event/BAO/ParticipantStatusType.php | 5 +-- CRM/Financial/BAO/FinancialAccount.php | 8 ++--- CRM/Financial/BAO/FinancialType.php | 7 ++--- CRM/Financial/BAO/PaymentProcessor.php | 8 ++--- CRM/Financial/BAO/PaymentProcessorType.php | 7 +---- CRM/Mailing/BAO/MailingComponent.php | 8 ++--- CRM/Member/BAO/MembershipStatus.php | 8 ++--- CRM/Member/BAO/MembershipType.php | 8 ++--- CRM/Price/BAO/PriceField.php | 7 +---- CRM/Price/BAO/PriceFieldValue.php | 7 +---- CRM/Price/BAO/PriceSet.php | 9 ++---- CRM/SMS/BAO/Provider.php | 5 +-- .../Contribute/BAO/ContributionPageTest.php | 19 ------------ .../Contribute/BAO/ContributionTypeTest.php | 20 ------------ .../CRM/Contribute/BAO/ProductTest.php | 25 --------------- .../phpunit/CRM/Core/BAO/CustomGroupTest.php | 29 ----------------- .../CRM/Event/BAO/ParticipantStatusTest.php | 27 ---------------- .../Financial/BAO/FinancialAccountTest.php | 23 -------------- .../CRM/Financial/BAO/FinancialTypeTest.php | 23 -------------- .../CRM/Member/BAO/MembershipStatusTest.php | 18 ----------- .../CRM/Member/BAO/MembershipTypeTest.php | 31 ------------------- 44 files changed, 65 insertions(+), 421 deletions(-) diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 89067de60a..ab3497f4a7 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -175,21 +175,13 @@ SELECT acl.* } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { - Civi::cache('fields')->flush(); - // reset ACL and system caches. - CRM_Core_BAO_Cache::resetCaches(); - + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_ACL_DAO_ACL', $id, 'is_active', $is_active); } diff --git a/CRM/ACL/BAO/ACLEntityRole.php b/CRM/ACL/BAO/ACLEntityRole.php index a892cf4ac7..26ae773ad1 100644 --- a/CRM/ACL/BAO/ACLEntityRole.php +++ b/CRM/ACL/BAO/ACLEntityRole.php @@ -61,17 +61,13 @@ class CRM_ACL_BAO_ACLEntityRole extends CRM_ACL_DAO_ACLEntityRole { } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue(__CLASS__, $id, 'is_active', $is_active); } diff --git a/CRM/Badge/BAO/Layout.php b/CRM/Badge/BAO/Layout.php index dd34add77a..c146c3a49c 100644 --- a/CRM/Badge/BAO/Layout.php +++ b/CRM/Badge/BAO/Layout.php @@ -30,17 +30,13 @@ class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel { } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_PrintLabel', $id, 'is_active', $is_active); } diff --git a/CRM/Campaign/BAO/Campaign.php b/CRM/Campaign/BAO/Campaign.php index 8229c944cf..ee01e49e3e 100644 --- a/CRM/Campaign/BAO/Campaign.php +++ b/CRM/Campaign/BAO/Campaign.php @@ -481,17 +481,13 @@ INNER JOIN civicrm_group grp ON ( grp.id = campgrp.entity_id ) } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Campaign_DAO_Campaign', $id, 'is_active', $is_active); } diff --git a/CRM/Campaign/BAO/Survey.php b/CRM/Campaign/BAO/Survey.php index c6b0bd2aaa..3f42995ee0 100644 --- a/CRM/Campaign/BAO/Survey.php +++ b/CRM/Campaign/BAO/Survey.php @@ -341,17 +341,13 @@ SELECT survey.id as id, } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Campaign_DAO_Survey', $id, 'is_active', $is_active); } diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index 05f9177e4c..77eaa89407 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -588,17 +588,13 @@ WHERE contact_sub_type LIKE '%{$subType}%'"; } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); $params = ['id' => $id]; self::retrieve($params, $contactinfo); $params = ['name' => "New $contactinfo[name]"]; diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 38131496c8..27c5a65f2f 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -541,15 +541,10 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $isActive - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $isActive) { return CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Group', $id, 'is_active', $isActive); diff --git a/CRM/Contact/BAO/RelationshipType.php b/CRM/Contact/BAO/RelationshipType.php index 3059ac9e49..e74b475c3d 100644 --- a/CRM/Contact/BAO/RelationshipType.php +++ b/CRM/Contact/BAO/RelationshipType.php @@ -38,17 +38,13 @@ class CRM_Contact_BAO_RelationshipType extends CRM_Contact_DAO_RelationshipType } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_RelationshipType', $id, 'is_active', $is_active); } diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index 9945d10286..43a401bdf0 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -53,19 +53,13 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio } /** - * Update the is_active flag in the db. - * * @deprecated - this bypasses hooks. - * * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_ContributionPage', $id, 'is_active', $is_active); } diff --git a/CRM/Contribute/BAO/Premium.php b/CRM/Contribute/BAO/Premium.php index 4b03e896a5..2f648474de 100644 --- a/CRM/Contribute/BAO/Premium.php +++ b/CRM/Contribute/BAO/Premium.php @@ -37,17 +37,13 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Premium', $id, 'premiums_active ', $is_active); } diff --git a/CRM/Contribute/BAO/Product.php b/CRM/Contribute/BAO/Product.php index 754106904e..f4f6f5f4dc 100644 --- a/CRM/Contribute/BAO/Product.php +++ b/CRM/Contribute/BAO/Product.php @@ -44,16 +44,13 @@ class CRM_Contribute_BAO_Product extends CRM_Contribute_DAO_Product { } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); if (!$is_active) { $dao = new CRM_Contribute_DAO_PremiumsProduct(); $dao->product_id = $id; diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index dbbeeac111..d22b86c2c2 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -216,17 +216,13 @@ FROM civicrm_action_schedule cas } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_ActionSchedule', $id, 'is_active', $is_active); } diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index cf05c109b2..5da3581da9 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -263,18 +263,13 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { - + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); CRM_Utils_System::flushCache(); //enable-disable CustomField diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 50aeb3dea2..a4a33744a6 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -251,17 +251,13 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup implements \Civi } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); // reset the cache Civi::cache('fields')->flush(); // reset ACL and system caches. diff --git a/CRM/Core/BAO/Job.php b/CRM/Core/BAO/Job.php index c8c849d381..1f8fd506fb 100644 --- a/CRM/Core/BAO/Job.php +++ b/CRM/Core/BAO/Job.php @@ -52,17 +52,13 @@ class CRM_Core_BAO_Job extends CRM_Core_DAO_Job { } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_Job', $id, 'is_active', $is_active); } diff --git a/CRM/Core/BAO/LocationType.php b/CRM/Core/BAO/LocationType.php index 3200e149d1..6493470d3d 100644 --- a/CRM/Core/BAO/LocationType.php +++ b/CRM/Core/BAO/LocationType.php @@ -44,17 +44,13 @@ class CRM_Core_BAO_LocationType extends CRM_Core_DAO_LocationType implements \Ci } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_LocationType', $id, 'is_active', $is_active); } diff --git a/CRM/Core/BAO/MessageTemplate.php b/CRM/Core/BAO/MessageTemplate.php index be77c649dd..9b70920b2d 100644 --- a/CRM/Core/BAO/MessageTemplate.php +++ b/CRM/Core/BAO/MessageTemplate.php @@ -43,17 +43,13 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate implemen } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_MessageTemplate', $id, 'is_active', $is_active); } diff --git a/CRM/Core/BAO/Navigation.php b/CRM/Core/BAO/Navigation.php index 1f4345fbee..ae9a0e3180 100644 --- a/CRM/Core/BAO/Navigation.php +++ b/CRM/Core/BAO/Navigation.php @@ -56,17 +56,13 @@ class CRM_Core_BAO_Navigation extends CRM_Core_DAO_Navigation { } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_Navigation', $id, 'is_active', $is_active); } diff --git a/CRM/Core/BAO/OptionGroup.php b/CRM/Core/BAO/OptionGroup.php index ff28aacc77..bd3ffe9c33 100644 --- a/CRM/Core/BAO/OptionGroup.php +++ b/CRM/Core/BAO/OptionGroup.php @@ -34,17 +34,13 @@ class CRM_Core_BAO_OptionGroup extends CRM_Core_DAO_OptionGroup implements \Civi } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_OptionGroup', $id, 'is_active', $is_active); } diff --git a/CRM/Core/BAO/OptionValue.php b/CRM/Core/BAO/OptionValue.php index cd9c7e0fd9..622fca1c20 100644 --- a/CRM/Core/BAO/OptionValue.php +++ b/CRM/Core/BAO/OptionValue.php @@ -107,15 +107,10 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue implements \Civi } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_OptionValue', $id, 'is_active', $is_active); diff --git a/CRM/Core/BAO/UFField.php b/CRM/Core/BAO/UFField.php index 82cfeb0858..5ade83e12f 100644 --- a/CRM/Core/BAO/UFField.php +++ b/CRM/Core/BAO/UFField.php @@ -131,15 +131,10 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField { } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { //check if custom data profile field is disabled diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 0d121267dc..aa471362ce 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -94,15 +94,10 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup implements \Civi\Core\Ho } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', $id, 'is_active', $is_active); diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 55503aad23..6b9154a173 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -34,17 +34,13 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event implements \Civi\Core\Hook } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Event', $id, 'is_active', $is_active); } diff --git a/CRM/Event/BAO/ParticipantStatusType.php b/CRM/Event/BAO/ParticipantStatusType.php index bd773993e5..4c0941166f 100644 --- a/CRM/Event/BAO/ParticipantStatusType.php +++ b/CRM/Event/BAO/ParticipantStatusType.php @@ -88,12 +88,13 @@ class CRM_Event_BAO_ParticipantStatusType extends CRM_Event_DAO_ParticipantStatu } /** + * @deprecated - this bypasses hooks. * @param int $id - * @param $isActive - * + * @param bool $isActive * @return bool */ public static function setIsActive($id, $isActive) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Event_BAO_ParticipantStatusType', $id, 'is_active', $isActive); } diff --git a/CRM/Financial/BAO/FinancialAccount.php b/CRM/Financial/BAO/FinancialAccount.php index 5e04cda5c2..88b9b879b9 100644 --- a/CRM/Financial/BAO/FinancialAccount.php +++ b/CRM/Financial/BAO/FinancialAccount.php @@ -34,17 +34,13 @@ class CRM_Financial_BAO_FinancialAccount extends CRM_Financial_DAO_FinancialAcco } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_FinancialAccount', $id, 'is_active', $is_active); } diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index d02b7c8fe8..bb2cc98d7f 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -49,16 +49,13 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType im } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_FinancialType', $id, 'is_active', $is_active); } diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index 0f82508439..986adf5573 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -90,17 +90,13 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_PaymentProcessor', $id, 'is_active', $is_active); } diff --git a/CRM/Financial/BAO/PaymentProcessorType.php b/CRM/Financial/BAO/PaymentProcessorType.php index 83f0a4491f..356dc2bb59 100644 --- a/CRM/Financial/BAO/PaymentProcessorType.php +++ b/CRM/Financial/BAO/PaymentProcessorType.php @@ -40,15 +40,10 @@ class CRM_Financial_BAO_PaymentProcessorType extends CRM_Financial_DAO_PaymentPr } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { return CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_PaymentProcessorType', $id, 'is_active', $is_active); diff --git a/CRM/Mailing/BAO/MailingComponent.php b/CRM/Mailing/BAO/MailingComponent.php index 96d3c8e624..72c75cb63a 100644 --- a/CRM/Mailing/BAO/MailingComponent.php +++ b/CRM/Mailing/BAO/MailingComponent.php @@ -34,17 +34,13 @@ class CRM_Mailing_BAO_MailingComponent extends CRM_Mailing_DAO_MailingComponent } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_MailingComponent', $id, 'is_active', $is_active); } diff --git a/CRM/Member/BAO/MembershipStatus.php b/CRM/Member/BAO/MembershipStatus.php index 7c791d5812..a2e8895412 100644 --- a/CRM/Member/BAO/MembershipStatus.php +++ b/CRM/Member/BAO/MembershipStatus.php @@ -34,17 +34,13 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus im } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Member_DAO_MembershipStatus', $id, 'is_active', $is_active); } diff --git a/CRM/Member/BAO/MembershipType.php b/CRM/Member/BAO/MembershipType.php index 789eebe74d..d51f768d7f 100644 --- a/CRM/Member/BAO/MembershipType.php +++ b/CRM/Member/BAO/MembershipType.php @@ -42,17 +42,13 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType implem } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Member_DAO_MembershipType', $id, 'is_active', $is_active); } diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index b76d95c321..f0163d150f 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -187,15 +187,10 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceField', $id, 'is_active', $is_active); diff --git a/CRM/Price/BAO/PriceFieldValue.php b/CRM/Price/BAO/PriceFieldValue.php index dd614637cd..70e150d500 100644 --- a/CRM/Price/BAO/PriceFieldValue.php +++ b/CRM/Price/BAO/PriceFieldValue.php @@ -182,15 +182,10 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. * @param bool $is_active - * Value we want to set the is_active field. - * * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceFieldValue', $id, 'is_active', $is_active); diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index 982115ed82..a5840caee4 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -86,16 +86,13 @@ class CRM_Price_BAO_PriceSet extends CRM_Price_DAO_PriceSet { } /** - * Update the is_active flag in the db. - * + * @deprecated - this bypasses hooks. * @param int $id - * Id of the database record. - * @param $isActive - * + * @param bool $isActive * @return bool - * true if we found and updated the object, else false */ public static function setIsActive($id, $isActive) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $id, 'is_active', $isActive); } diff --git a/CRM/SMS/BAO/Provider.php b/CRM/SMS/BAO/Provider.php index f820b10430..11b16e97fb 100644 --- a/CRM/SMS/BAO/Provider.php +++ b/CRM/SMS/BAO/Provider.php @@ -103,12 +103,13 @@ class CRM_SMS_BAO_Provider extends CRM_SMS_DAO_Provider { } /** + * @deprecated - this bypasses hooks. * @param int $id - * @param $is_active - * + * @param bool $is_active * @return bool */ public static function setIsActive($id, $is_active) { + CRM_Core_Error::deprecatedFunctionWarning('writeRecord'); return CRM_Core_DAO::setFieldValue('CRM_SMS_DAO_Provider', $id, 'is_active', $is_active); } diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php index 6961b681c1..da86515a93 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php @@ -52,25 +52,6 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionpage->id]); } - /** - * test setIsActive() method - */ - public function testsetIsActive() { - - $params = [ - 'title' => 'Test Contribution Page', - 'financial_type_id' => self::FINANCIAL_TYPE_ID, - 'is_active' => 1, - ]; - - $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params); - $id = $contributionpage->id; - $is_active = 1; - $pageActive = CRM_Contribute_BAO_ContributionPage::setIsActive($id, $is_active); - $this->assertEquals($pageActive, TRUE, 'Verify financial types record deletion.'); - $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionpage->id]); - } - /** * Test setValues() method */ diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php index fe9bce3f1c..a14714659d 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php @@ -44,24 +44,4 @@ class CRM_Contribute_BAO_ContributionTypeTest extends CiviUnitTestCase { $this->assertEquals($result, 'Donations', 'Verify financial type name.'); } - /** - * Check method setIsActive() - */ - public function testSetIsActive() { - $params = [ - 'name' => 'Donations', - 'is_deductible' => 0, - 'is_active' => 1, - ]; - $contributionType = CRM_Financial_BAO_FinancialType::writeRecord($params); - $result = CRM_Financial_BAO_FinancialType::setIsActive($contributionType->id, 0); - $this->assertEquals($result, TRUE, 'Verify financial type record updation for is_active.'); - - $isActive = $this->assertDBNotNull('CRM_Financial_BAO_FinancialType', $contributionType->id, - 'is_active', 'id', - 'Database check on updated for financial type is_active.' - ); - $this->assertEquals($isActive, 0, 'Verify financial types is_active.'); - } - } diff --git a/tests/phpunit/CRM/Contribute/BAO/ProductTest.php b/tests/phpunit/CRM/Contribute/BAO/ProductTest.php index e630e35706..b87dc2bffc 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ProductTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ProductTest.php @@ -59,31 +59,6 @@ class CRM_Contribute_BAO_ProductTest extends CiviUnitTestCase { $this->assertEquals(empty($result), FALSE, 'Verify products record.'); } - /** - * Check method setIsActive( ) - */ - public function testSetIsActive() { - $params = [ - 'name' => 'Test Product', - 'sku' => 'TP-10', - 'imageOption' => 'noImage', - 'price' => 12, - 'cost' => 5, - 'min_contribution' => 5, - 'is_active' => 1, - ]; - - $product = CRM_Contribute_BAO_Product::create($params); - CRM_Contribute_BAO_Product::setIsActive($product->id, 0); - - $isActive = $this->assertDBNotNull('CRM_Contribute_BAO_Product', $product->id, - 'is_active', 'id', - 'Database check on updated for product records is_active.' - ); - - $this->assertEquals($isActive, 0, 'Verify product records is_active.'); - } - /** * Check method del( ) */ diff --git a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php index 7b28c94dbd..f7abbdd37d 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php @@ -190,35 +190,6 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase { $this->getAndCheck($groupParams, $customGroup['id'], 'CustomGroup'); } - /** - * Test setIsActive() - */ - public function testSetIsActive() { - $customGroupTitle = 'My Custom Group'; - $groupParams = [ - 'title' => $customGroupTitle, - 'name' => 'my_custom_group', - 'style' => 'Tab', - 'extends' => 'Individual', - 'is_active' => 0, - ]; - - $customGroup = $this->customGroupCreate($groupParams); - $customGroupId = $customGroup['id']; - - //update is_active - $result = CRM_Core_BAO_CustomGroup::setIsActive($customGroupId, TRUE); - - //check for object update - $this->assertEquals(TRUE, $result); - //check for is_active - $this->assertDBCompareValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'is_active', 'id', 1, - 'Database check for custom group is_active field.' - ); - - $this->customGroupDelete($customGroup['id']); - } - /** * Test getGroupDetail() with Empty Params */ diff --git a/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php b/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php index f70b6f9588..7ed735291c 100644 --- a/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php +++ b/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php @@ -111,31 +111,4 @@ class CRM_Event_BAO_ParticipantStatusTest extends CiviUnitTestCase { } } - /** - * SetIsActive() method of participant status type - */ - public function testSetIsActiveStatusType() { - - $params = [ - 'name' => 'testStatus', - 'label' => 'testParticipant', - 'class' => 'Positive', - 'is_active' => 0, - 'is_counted' => 1, - 'weight' => 15, - 'visibility_id' => 1, - ]; - - $statusType = CRM_Event_BAO_ParticipantStatusType::create($params); - $isActive = 1; - - // set participant status type active - CRM_Event_BAO_ParticipantStatusType::setIsActive($statusType->id, $isActive); - - // compare expected value in db - $this->assertDBCompareValue('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'is_Active', - 'id', $isActive, 'Check DB for is_Active value' - ); - } - } diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php index 9811c2af9d..2b6100a294 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php @@ -63,29 +63,6 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase { $this->assertEquals($result->name, 'Donations', 'Verify financial account name.'); } - /** - * Check method setIsActive() - */ - public function testSetIsActive() { - $params = [ - 'name' => 'Donations', - 'is_deductible' => 0, - 'is_active' => 1, - ]; - $financialAccount = CRM_Financial_BAO_FinancialAccount::writeRecord($params); - $result = CRM_Financial_BAO_FinancialAccount::setIsActive($financialAccount->id, 0); - $this->assertEquals($result, TRUE, 'Verify financial account record updation for is_active.'); - - $isActive = $this->assertDBNotNull( - 'CRM_Financial_BAO_FinancialAccount', - $financialAccount->id, - 'is_active', - 'id', - 'Database check on updated for financial account is_active.' - ); - $this->assertEquals($isActive, 0, 'Verify financial account is_active.'); - } - /** * Check method del() * diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php index ceac27811b..7496eddb6e 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialTypeTest.php @@ -27,29 +27,6 @@ class CRM_Financial_BAO_FinancialTypeTest extends CiviUnitTestCase { parent::tearDown(); } - /** - * Check method setIsActive(). - * - * @throws \CRM_Core_Exception - */ - public function testSetIsActive(): void { - $financialTypeID = FinancialType::create()->setValues([ - 'name' => 'Donations', - 'is_deductible' => 0, - 'is_active' => 1, - ])->execute()->first()['id']; - $result = CRM_Financial_BAO_FinancialType::setIsActive($financialTypeID, 0); - $this->assertEquals(TRUE, $result, 'Verify financial type record updated for is_active.'); - $isActive = $this->assertDBNotNull( - 'CRM_Financial_DAO_FinancialType', - $financialTypeID, - 'is_active', - 'id', - 'Database check on updated for financial type is_active.' - ); - $this->assertEquals(0, $isActive, 'Verify financial types is_active.'); - } - /** * Delete test for testGitLabIssue1108. * diff --git a/tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php b/tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php index cf1dd5b1f4..f7eaabbdef 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php @@ -72,24 +72,6 @@ class CRM_Member_BAO_MembershipStatusTest extends CiviUnitTestCase { $this->assertEquals($result, 'Changed Status', 'Verify updated membership status label From PseudoConstant.'); } - public function testSetIsActive() { - - $params = [ - 'name' => 'added', - 'is_active' => 1, - ]; - - $this->ids['MembershipStatus'][0] = $this->callAPISuccess('MembershipStatus', 'create', $params)['id']; - $result = CRM_Member_BAO_MembershipStatus::setIsActive($this->ids['MembershipStatus'][0], 0); - $this->assertEquals($result, TRUE, 'Verify membership status record updated.'); - - $isActive = $this->assertDBNotNull('CRM_Member_BAO_MembershipStatus', $this->ids['MembershipStatus'][0], - 'is_active', 'id', - 'Database check on updated membership status record.' - ); - $this->assertEquals($isActive, 0, 'Verify membership status is_active.'); - } - public function testGetMembershipStatus() { $params = [ 'name' => 'added', diff --git a/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php b/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php index 4037b9f82e..a9074985d6 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php @@ -107,37 +107,6 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { $this->assertEquals('General', $result->name, 'Verify membership type name.'); } - /** - * Test setIsActive. - * - * @throws \CRM_Core_Exception - */ - public function testSetIsActive(): void { - $params = [ - 'name' => 'General', - 'description' => NULL, - 'domain_id' => 1, - 'minimum_fee' => 100, - 'duration_unit' => 'year', - 'period_type' => 'fixed', - 'duration_interval' => 1, - 'member_of_contact_id' => $this->ids['Contact']['organization'], - 'financial_type_id:name' => 'Donation', - 'relationship_type_id' => $this->ids['RelationshipType'][0], - 'visibility' => 'Public', - 'is_active' => 1, - ]; - $membershipID = MembershipType::create()->setValues($params)->execute()->first()['id']; - - CRM_Member_BAO_MembershipType::setIsActive($membershipID, 0); - - $isActive = $this->assertDBNotNull('CRM_Member_BAO_MembershipType', $membershipID, - 'is_active', 'id', - 'Database check on membership type status.' - ); - $this->assertEquals(0, $isActive, 'Verify membership type status.'); - } - /** * Test delete. * -- 2.25.1