From bf9042a88baceb1bc90b266388e2432cbf1769b7 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 16 Apr 2022 10:54:02 +1200 Subject: [PATCH 001/106] Remove redundant financialacl check --- CRM/Member/Form/MembershipView.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/CRM/Member/Form/MembershipView.php b/CRM/Member/Form/MembershipView.php index a8af679e49da..1396c74727d7 100644 --- a/CRM/Member/Form/MembershipView.php +++ b/CRM/Member/Form/MembershipView.php @@ -15,6 +15,8 @@ * @copyright CiviCRM LLC https://civicrm.org/licensing */ +use Civi\Api4\Membership; + /** * This class generates form components for Payment-Instrument */ @@ -154,11 +156,14 @@ public function preProcess() { $this->assign('context', $context); if ($this->membershipID) { - $values = \Civi\Api4\Membership::get() + $memberships = Membership::get() ->addSelect('*', 'status_id:label', 'membership_type_id:label', 'membership_type_id.financial_type_id', 'status_id.is_current_member') ->addWhere('id', '=', $this->membershipID) - ->execute() - ->first(); + ->execute(); + if (!count($memberships)) { + CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); + } + $values = $memberships->first(); // Ensure keys expected by MembershipView.tpl are set correctly // Some of these defaults are overwritten dependant on context below @@ -170,16 +175,11 @@ public function preProcess() { $values['owner_display_name'] = FALSE; $values['campaign'] = FALSE; - if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) { - $finTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $values['membership_type_id'], 'financial_type_id'); - $finType = CRM_Contribute_PseudoConstant::financialType($finTypeId); - if (!CRM_Core_Permission::check('view contributions of type ' . $finType)) { - CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); - } - } - else { - $this->assign('noACL', TRUE); - } + // This tells the template not to check financial acls when determining + // whether to show edit & delete links. Link decisions + // should be moved to the php layer - with financialacls using hooks. + $this->assign('noACL', !CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()); + $membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($values['membership_type_id']); // Do the action on related Membership if needed From 8e7ecd426178e0f8adeb653449ea75f9cc5b4379 Mon Sep 17 00:00:00 2001 From: larssandergreen Date: Sun, 2 Oct 2022 19:04:04 -0600 Subject: [PATCH 002/106] Add crm-disabled --- CRM/Contribute/Page/ContributionPage.php | 2 +- css/civicrm.css | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/Page/ContributionPage.php b/CRM/Contribute/Page/ContributionPage.php index 9f96923ec30f..db9f1ba790f9 100644 --- a/CRM/Contribute/Page/ContributionPage.php +++ b/CRM/Contribute/Page/ContributionPage.php @@ -694,7 +694,7 @@ public function formatConfigureLinks($sectionsInfo) { if (isset($link['class'])) { $classes = $link['class']; } - $link['class'] = array_merge($classes, array('disabled')); + $link['class'] = array_merge($classes, array('crm-disabled')); } } diff --git a/css/civicrm.css b/css/civicrm.css index 7306d752d6dd..e958d97ba0ac 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -2784,6 +2784,7 @@ tbody.scrollContent tr.alternateRow { } .crm-container .disabled, +.crm-container .crm-disabled, .crm-container .disabled *, .crm-container .cancelled, .crm-container .cancelled td, From 1090db413680855d449671b841af8185f0baeb1f Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 27 Dec 2022 10:15:20 +1300 Subject: [PATCH 003/106] Divide & conquer Copy complext function into merger class, ready to disentangle as little shared code is really used --- CRM/Core/BAO/CustomGroup.php | 9 +- CRM/Dedupe/Merger.php | 333 +++++++++++++++++++++++- tests/phpunit/CRM/Dedupe/MergerTest.php | 4 +- 3 files changed, 340 insertions(+), 6 deletions(-) diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 378c58502c8b..ea0fee15bb37 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -635,13 +635,15 @@ public static function getTree( /** * Clean and validate the filter before it is used in a db query. * + * @internal this will be private again soon. + * * @param string $entityType * @param string $subType * * @return string * @throws \CRM_Core_Exception */ - protected static function validateSubTypeByEntity($entityType, $subType) { + public static function validateSubTypeByEntity($entityType, $subType) { $subType = trim($subType, CRM_Core_DAO::VALUE_SEPARATOR); if (is_numeric($subType)) { return $subType; @@ -2273,6 +2275,9 @@ public static function getMultipleFieldGroup() { /** * Build the metadata tree for the custom group. * + * @internal - function is temporarily public but will be private again + * once separated function disentangled. + * * @param string $entityType * @param array $toReturn * @param array $subTypes @@ -2283,7 +2288,7 @@ public static function getMultipleFieldGroup() { * @return array * @throws \CRM_Core_Exception */ - private static function buildGroupTree($entityType, $toReturn, $subTypes, $queryString, $params, $subType) { + public static function buildGroupTree($entityType, $toReturn, $subTypes, $queryString, $params, $subType) { $groupTree = $multipleFieldGroups = []; $crmDAO = CRM_Core_DAO::executeQuery($queryString, $params); $customValueTables = []; diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 9dfec97e9fad..37b61ed1310f 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -1607,11 +1607,11 @@ public static function getRowsElementsAndInfo($mainId, $otherId, $checkPermissio } // handle custom fields - $mainTree = CRM_Core_BAO_CustomGroup::getTree($main['contact_type'], NULL, $mainId, -1, + $mainTree = self::getTree($main['contact_type'], NULL, $mainId, -1, CRM_Utils_Array::value('contact_sub_type', $main), NULL, TRUE, NULL, TRUE, $checkPermissions ? CRM_Core_Permission::EDIT : FALSE ); - $otherTree = CRM_Core_BAO_CustomGroup::getTree($main['contact_type'], NULL, $otherId, -1, + $otherTree = self::getTree($main['contact_type'], NULL, $otherId, -1, CRM_Utils_Array::value('contact_sub_type', $other), NULL, TRUE, NULL, TRUE, $checkPermissions ? CRM_Core_Permission::EDIT : FALSE ); @@ -1673,6 +1673,335 @@ public static function getRowsElementsAndInfo($mainId, $otherId, $checkPermissio return $result; } + /** + * Function is separated from shared function & can likely be distilled to an api call. + * + * @todo clean up post split. + * + * Get custom groups/fields data for type of entity in a tree structure representing group->field hierarchy + * This may also include entity specific data values. + * + * An array containing all custom groups and their custom fields is returned. + * + * @param string $entityType + * Of the contact whose contact type is needed. + * @param array $toReturn + * What data should be returned. ['custom_group' => ['id', 'name', etc.], 'custom_field' => ['id', 'label', etc.]] + * @param int $entityID + * @param int $groupID + * @param array $subTypes + * @param string $subName + * @param bool $fromCache + * @param bool $onlySubType + * Only return specified subtype or return specified subtype + unrestricted fields. + * @param bool $returnAll + * Do not restrict by subtype at all. (The parameter feels a bit cludgey but is only used from the + * api - through which it is properly tested - so can be refactored with some comfort.) + * @param bool|int $checkPermission + * Either a CRM_Core_Permission constant or FALSE to disable checks + * @param string|int $singleRecord + * holds 'new' or id if view/edit/copy form for a single record is being loaded. + * @param bool $showPublicOnly + * + * @return array + * Custom field 'tree'. + * + * The returned array is keyed by group id and has the custom group table fields + * and a subkey 'fields' holding the specific custom fields. + * If entityId is passed in the fields keys have a subkey 'customValue' which holds custom data + * if set for the given entity. This is structured as an array of values with each one having the keys 'id', 'data' + * + * @todo - review this - It also returns an array called 'info' with tables, select, from, where keys + * The reason for the info array in unclear and it could be determined from parsing the group tree after creation + * With caching the performance impact would be small & the function would be cleaner + * + * @throws \CRM_Core_Exception + */ + public static function getTree( + $entityType, + $toReturn = [], + $entityID = NULL, + $groupID = NULL, + $subTypes = [], + $subName = NULL, + $fromCache = TRUE, + $onlySubType = NULL, + $returnAll = FALSE, + $checkPermission = CRM_Core_Permission::EDIT, + $singleRecord = NULL, + $showPublicOnly = FALSE + ) { + if ($checkPermission === TRUE) { + CRM_Core_Error::deprecatedWarning('Unexpected TRUE passed to CustomGroup::getTree $checkPermission param.'); + $checkPermission = CRM_Core_Permission::EDIT; + } + if ($entityID) { + $entityID = CRM_Utils_Type::escape($entityID, 'Integer'); + } + if (!is_array($subTypes)) { + if (empty($subTypes)) { + $subTypes = []; + } + else { + if (stristr($subTypes, ',')) { + $subTypes = explode(',', $subTypes); + } + else { + $subTypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($subTypes, CRM_Core_DAO::VALUE_SEPARATOR)); + } + } + } + + // create a new tree + + // legacy hardcoded list of data to return + $tableData = [ + 'custom_field' => [ + 'id', + 'name', + 'label', + 'column_name', + 'data_type', + 'html_type', + 'default_value', + 'attributes', + 'is_required', + 'is_view', + 'help_pre', + 'help_post', + 'options_per_line', + 'start_date_years', + 'end_date_years', + 'date_format', + 'time_format', + 'option_group_id', + 'in_selector', + ], + 'custom_group' => [ + 'id', + 'name', + 'table_name', + 'title', + 'help_pre', + 'help_post', + 'collapse_display', + 'style', + 'is_multiple', + 'extends', + 'extends_entity_column_id', + 'extends_entity_column_value', + 'max_multiple', + ], + ]; + $current_db_version = CRM_Core_BAO_Domain::version(); + $is_public_version = version_compare($current_db_version, '4.7.19', '>='); + $serialize_version = version_compare($current_db_version, '5.27.alpha1', '>='); + if ($is_public_version) { + $tableData['custom_group'][] = 'is_public'; + } + if ($serialize_version) { + $tableData['custom_field'][] = 'serialize'; + } + if (!$toReturn || !is_array($toReturn)) { + $toReturn = $tableData; + } + else { + // Supply defaults and remove unknown array keys + $toReturn = array_intersect_key(array_filter($toReturn) + $tableData, $tableData); + // Merge in required fields that we must have + $toReturn['custom_field'] = array_unique(array_merge($toReturn['custom_field'], ['id', 'column_name', 'data_type'])); + $toReturn['custom_group'] = array_unique(array_merge($toReturn['custom_group'], ['id', 'is_multiple', 'table_name', 'name'])); + // Validate return fields + $toReturn['custom_field'] = array_intersect($toReturn['custom_field'], array_keys(CRM_Core_DAO_CustomField::fieldKeys())); + $toReturn['custom_group'] = array_intersect($toReturn['custom_group'], array_keys(CRM_Core_DAO_CustomGroup::fieldKeys())); + } + + // create select + $select = []; + foreach ($toReturn as $tableName => $tableColumn) { + foreach ($tableColumn as $columnName) { + $select[] = "civicrm_{$tableName}.{$columnName} as civicrm_{$tableName}_{$columnName}"; + } + } + $strSelect = "SELECT " . implode(', ', $select); + + // from, where, order by + $strFrom = " +FROM civicrm_custom_group +LEFT JOIN civicrm_custom_field ON (civicrm_custom_field.custom_group_id = civicrm_custom_group.id) +"; + + // if entity is either individual, organization or household pls get custom groups for 'contact' too. + if ($entityType == "Individual" || $entityType == 'Organization' || + $entityType == 'Household' + ) { + $in = "'$entityType', 'Contact'"; + } + elseif (strpos($entityType, "'") !== FALSE) { + // this allows the calling function to send in multiple entity types + $in = $entityType; + } + else { + // quote it + $in = "'$entityType'"; + } + + $params = []; + $sqlParamKey = 1; + $subType = ''; + if (!empty($subTypes)) { + foreach ($subTypes as $key => $subType) { + $subTypeClauses[] = self::whereListHas("civicrm_custom_group.extends_entity_column_value", CRM_Core_BAO_CustomGroup::validateSubTypeByEntity($entityType, $subType)); + } + $subTypeClause = '(' . implode(' OR ', $subTypeClauses) . ')'; + if (!$onlySubType) { + $subTypeClause = '(' . $subTypeClause . ' OR civicrm_custom_group.extends_entity_column_value IS NULL )'; + } + + $strWhere = " +WHERE civicrm_custom_group.is_active = 1 + AND civicrm_custom_field.is_active = 1 + AND civicrm_custom_group.extends IN ($in) + AND $subTypeClause +"; + if ($subName) { + $strWhere .= " AND civicrm_custom_group.extends_entity_column_id = %{$sqlParamKey}"; + $params[$sqlParamKey] = [$subName, 'String']; + $sqlParamKey = $sqlParamKey + 1; + } + } + else { + $strWhere = " +WHERE civicrm_custom_group.is_active = 1 + AND civicrm_custom_field.is_active = 1 + AND civicrm_custom_group.extends IN ($in) +"; + if (!$returnAll) { + $strWhere .= "AND civicrm_custom_group.extends_entity_column_value IS NULL"; + } + } + + if ($groupID > 0) { + // since we want a specific group id we add it to the where clause + $strWhere .= " AND civicrm_custom_group.id = %{$sqlParamKey}"; + $params[$sqlParamKey] = [$groupID, 'Integer']; + } + elseif (!$groupID) { + // since groupID is false we need to show all Inline groups + $strWhere .= " AND civicrm_custom_group.style = 'Inline'"; + } + if ($checkPermission) { + // ensure that the user has access to these custom groups + $strWhere .= " AND " . + CRM_Core_Permission::customGroupClause($checkPermission, + 'civicrm_custom_group.' + ); + } + + if ($showPublicOnly && $is_public_version) { + $strWhere .= "AND civicrm_custom_group.is_public = 1"; + } + + $orderBy = " +ORDER BY civicrm_custom_group.weight, + civicrm_custom_group.title, + civicrm_custom_field.weight, + civicrm_custom_field.label +"; + + // final query string + $queryString = "$strSelect $strFrom $strWhere $orderBy"; + + // lets see if we can retrieve the groupTree from cache + $cacheString = $queryString; + if ($groupID > 0) { + $cacheString .= "_{$groupID}"; + } + else { + $cacheString .= "_Inline"; + } + + $cacheKey = "CRM_Core_DAO_CustomGroup_Query " . md5($cacheString); + $multipleFieldGroupCacheKey = "CRM_Core_DAO_CustomGroup_QueryMultipleFields " . md5($cacheString); + $cache = CRM_Utils_Cache::singleton(); + if ($fromCache) { + $groupTree = $cache->get($cacheKey); + $multipleFieldGroups = $cache->get($multipleFieldGroupCacheKey); + } + + if (empty($groupTree)) { + [$multipleFieldGroups, $groupTree] = CRM_Core_BAO_CustomGroup::buildGroupTree($entityType, $toReturn, $subTypes, $queryString, $params, $subType); + + $cache->set($cacheKey, $groupTree); + $cache->set($multipleFieldGroupCacheKey, $multipleFieldGroups); + } + // entitySelectClauses is an array of select clauses for custom value tables which are not multiple + // and have data for the given entities. $entityMultipleSelectClauses is the same for ones with multiple + $entitySingleSelectClauses = $entityMultipleSelectClauses = $groupTree['info']['select'] = []; + $singleFieldTables = []; + // now that we have all the groups and fields, lets get the values + // since we need to know the table and field names + // add info to groupTree + + if (isset($groupTree['info']) && !empty($groupTree['info']) && + !empty($groupTree['info']['tables']) && $singleRecord != 'new' + ) { + $select = $from = $where = []; + $groupTree['info']['where'] = NULL; + + foreach ($groupTree['info']['tables'] as $table => $fields) { + $groupTree['info']['from'][] = $table; + $select = [ + "{$table}.id as {$table}_id", + "{$table}.entity_id as {$table}_entity_id", + ]; + foreach ($fields as $column => $dontCare) { + $select[] = "{$table}.{$column} as {$table}_{$column}"; + } + $groupTree['info']['select'] = array_merge($groupTree['info']['select'], $select); + if ($entityID) { + $groupTree['info']['where'][] = "{$table}.entity_id = $entityID"; + if (in_array($table, $multipleFieldGroups) && + CRM_Core_BAO_CustomGroup::customGroupDataExistsForEntity($entityID, $table) + ) { + $entityMultipleSelectClauses[$table] = $select; + } + else { + $singleFieldTables[] = $table; + $entitySingleSelectClauses = array_merge($entitySingleSelectClauses, $select); + } + + } + } + if ($entityID && !empty($singleFieldTables)) { + CRM_Core_BAO_CustomGroup::buildEntityTreeSingleFields($groupTree, $entityID, $entitySingleSelectClauses, $singleFieldTables); + } + $multipleFieldTablesWithEntityData = array_keys($entityMultipleSelectClauses); + if (!empty($multipleFieldTablesWithEntityData)) { + CRM_Core_BAO_CustomGroup::buildEntityTreeMultipleFields($groupTree, $entityID, $entityMultipleSelectClauses, $multipleFieldTablesWithEntityData, $singleRecord); + } + + } + return $groupTree; + } + + /** + * Suppose you have a SQL column, $column, which includes a delimited list, and you want + * a WHERE condition for rows that include $value. Use whereListHas(). + * + * @param string $column + * @param string $value + * @param string $delimiter + * @return string + * SQL condition. + */ + private static function whereListHas($column, $value, $delimiter = CRM_Core_DAO::VALUE_SEPARATOR) { + // ? + $bareValue = trim($value, $delimiter); + $escapedValue = CRM_Utils_Type::escape("%{$delimiter}{$bareValue}{$delimiter}%", 'String', FALSE); + return "($column LIKE \"$escapedValue\")"; + } + /** * Based on the provided two contact_ids and a set of tables, move the belongings of the * other contact to the main one - be it Location / CustomFields or Contact .. related info. diff --git a/tests/phpunit/CRM/Dedupe/MergerTest.php b/tests/phpunit/CRM/Dedupe/MergerTest.php index fe9bcd080a62..9443d792dc40 100644 --- a/tests/phpunit/CRM/Dedupe/MergerTest.php +++ b/tests/phpunit/CRM/Dedupe/MergerTest.php @@ -787,7 +787,7 @@ public function testMergeMembership() { * * @throws \CRM_Core_Exception */ - public function testCustomDataOverwrite() { + public function testCustomDataOverwrite(): void { // Create Custom Field $createGroup = $this->setupCustomGroupForIndividual(); $createField = $this->setupCustomField('Graduation', $createGroup); @@ -819,7 +819,7 @@ public function testCustomDataOverwrite() { // update the text custom field for duplicate contact 2 with value 'ghi' $this->callAPISuccess('Contact', 'create', [ 'id' => $duplicateContactID2, - "{$customFieldName}" => 'ghi', + (string) ($customFieldName) => 'ghi', ]); $this->assertCustomFieldValue($duplicateContactID2, 'ghi', $customFieldName); From 220f8a5854ac51a27c3921f8fedf6d15c83bc222 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 28 Dec 2022 13:35:15 +1300 Subject: [PATCH 004/106] Add Report Instance apiv4 --- Civi/Api4/ReportInstance.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Civi/Api4/ReportInstance.php diff --git a/Civi/Api4/ReportInstance.php b/Civi/Api4/ReportInstance.php new file mode 100644 index 000000000000..aaa1f89774c6 --- /dev/null +++ b/Civi/Api4/ReportInstance.php @@ -0,0 +1,23 @@ + Date: Fri, 30 Dec 2022 12:54:13 +1300 Subject: [PATCH 005/106] Remove a couple of legacy uses of contributeMode --- .../Contribute/Form/Contribution/Confirm.tpl | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/templates/CRM/Contribute/Form/Contribution/Confirm.tpl b/templates/CRM/Contribute/Form/Contribution/Confirm.tpl index ba9f97286ccd..9ef4ad93d078 100644 --- a/templates/CRM/Contribute/Form/Contribution/Confirm.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Confirm.tpl @@ -207,9 +207,7 @@ {/if} - {if ( $contributeMode ne 'notify' and (!$is_pay_later or $isBillingAddressRequiredForPayLater) and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 ) ) or $email } - {if $contributeMode ne 'notify' and (!$is_pay_later or $isBillingAddressRequiredForPayLater) and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 ) } - {if $billingName or $address} + {if $billingName or $address}
{ts}Billing Name and Address{/ts} @@ -224,8 +222,7 @@
{/if} - {/if} - {if !$emailExists} + {if $email && !$emailExists}
{ts}Your Email{/ts} @@ -236,19 +233,17 @@
{/if} - {/if} {* Show credit or debit card section for 'direct' mode, except for PayPal Express (detected because credit card number is empty) *} - {if $contributeMode eq 'direct' and ! $is_pay_later and $is_monetary and ( $amount GT 0 OR $minimum_fee GT 0 )} {crmRegion name="contribution-confirm-billing-block"} - {if ($credit_card_number or $bank_account_number)} + {if in_array('credit_card_number', $form) || in_array('bank_account_number', $form)}
{if $paymentFieldsetLabel}
{$paymentFieldsetLabel}
{/if} - {if $paymentProcessor.payment_type == 2} + {if in_array('bank_account_number', $form)}
{ts}Account Holder{/ts}: {$account_holder}
{ts}Bank Account Number{/ts}: {$bank_account_number}
@@ -265,7 +260,8 @@
{/if} - {else} + {/if} + {if in_array('credit_card_number', $form)}
{$credit_card_type}
{$credit_card_number}
@@ -276,7 +272,6 @@
{/if} {/crmRegion} - {/if} {include file="CRM/Contribute/Form/Contribution/PremiumBlock.tpl" context="confirmContribution"} From b48a2ee2c7baa2535f80c419b01528939c6a8efe Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 1 Jan 2023 15:58:11 +1300 Subject: [PATCH 006/106] Run Civix upgrade on afform/core with template patch applied --- ext/afform/core/CRM/Afform/Upgrader.php | 2 +- ext/afform/core/CRM/Afform/Upgrader/Base.php | 396 ------------------- ext/afform/core/afform.civix.php | 94 +---- ext/afform/core/afform.php | 36 -- ext/afform/core/info.xml | 3 +- 5 files changed, 8 insertions(+), 523 deletions(-) delete mode 100644 ext/afform/core/CRM/Afform/Upgrader/Base.php diff --git a/ext/afform/core/CRM/Afform/Upgrader.php b/ext/afform/core/CRM/Afform/Upgrader.php index d104d03f286d..4859a2981a71 100644 --- a/ext/afform/core/CRM/Afform/Upgrader.php +++ b/ext/afform/core/CRM/Afform/Upgrader.php @@ -4,7 +4,7 @@ /** * Collection of upgrade steps. */ -class CRM_Afform_Upgrader extends CRM_Afform_Upgrader_Base { +class CRM_Afform_Upgrader extends CRM_Extension_Upgrader_Base { /** * Update names of blocks and joins diff --git a/ext/afform/core/CRM/Afform/Upgrader/Base.php b/ext/afform/core/CRM/Afform/Upgrader/Base.php deleted file mode 100644 index 207520ddd58b..000000000000 --- a/ext/afform/core/CRM/Afform/Upgrader/Base.php +++ /dev/null @@ -1,396 +0,0 @@ -ctx = array_shift($args); - $instance->queue = $instance->ctx->queue; - $method = array_shift($args); - return call_user_func_array([$instance, $method], $args); - } - - /** - * CRM_Afform_Upgrader_Base constructor. - * - * @param $extensionName - * @param $extensionDir - */ - public function __construct($extensionName, $extensionDir) { - $this->extensionName = $extensionName; - $this->extensionDir = $extensionDir; - } - - // ******** Task helpers ******** - - /** - * Run a CustomData file. - * - * @param string $relativePath - * the CustomData XML file path (relative to this extension's dir) - * @return bool - */ - public function executeCustomDataFile($relativePath) { - $xml_file = $this->extensionDir . '/' . $relativePath; - return $this->executeCustomDataFileByAbsPath($xml_file); - } - - /** - * Run a CustomData file - * - * @param string $xml_file - * the CustomData XML file path (absolute path) - * - * @return bool - */ - protected function executeCustomDataFileByAbsPath($xml_file) { - $import = new CRM_Utils_Migrate_Import(); - $import->run($xml_file); - return TRUE; - } - - /** - * Run a SQL file. - * - * @param string $relativePath - * the SQL file path (relative to this extension's dir) - * - * @return bool - */ - public function executeSqlFile($relativePath) { - CRM_Utils_File::sourceSQLFile( - CIVICRM_DSN, - $this->extensionDir . DIRECTORY_SEPARATOR . $relativePath - ); - return TRUE; - } - - /** - * Run the sql commands in the specified file. - * - * @param string $tplFile - * The SQL file path (relative to this extension's dir). - * Ex: "sql/mydata.mysql.tpl". - * - * @return bool - * @throws \CRM_Core_Exception - */ - public function executeSqlTemplate($tplFile) { - // Assign multilingual variable to Smarty. - $upgrade = new CRM_Upgrade_Form(); - - $tplFile = CRM_Utils_File::isAbsolute($tplFile) ? $tplFile : $this->extensionDir . DIRECTORY_SEPARATOR . $tplFile; - $smarty = CRM_Core_Smarty::singleton(); - $smarty->assign('domainID', CRM_Core_Config::domainID()); - CRM_Utils_File::sourceSQLFile( - CIVICRM_DSN, $smarty->fetch($tplFile), NULL, TRUE - ); - return TRUE; - } - - /** - * Run one SQL query. - * - * This is just a wrapper for CRM_Core_DAO::executeSql, but it - * provides syntactic sugar for queueing several tasks that - * run different queries - * - * @return bool - */ - public function executeSql($query, $params = []) { - // FIXME verify that we raise an exception on error - CRM_Core_DAO::executeQuery($query, $params); - return TRUE; - } - - /** - * Syntactic sugar for enqueuing a task which calls a function in this class. - * - * The task is weighted so that it is processed - * as part of the currently-pending revision. - * - * After passing the $funcName, you can also pass parameters that will go to - * the function. Note that all params must be serializable. - */ - public function addTask($title) { - $args = func_get_args(); - $title = array_shift($args); - $task = new CRM_Queue_Task( - [get_class($this), '_queueAdapter'], - $args, - $title - ); - return $this->queue->createItem($task, ['weight' => -1]); - } - - // ******** Revision-tracking helpers ******** - - /** - * Determine if there are any pending revisions. - * - * @return bool - */ - public function hasPendingRevisions() { - $revisions = $this->getRevisions(); - $currentRevision = $this->getCurrentRevision(); - - if (empty($revisions)) { - return FALSE; - } - if (empty($currentRevision)) { - return TRUE; - } - - return ($currentRevision < max($revisions)); - } - - /** - * Add any pending revisions to the queue. - * - * @param CRM_Queue_Queue $queue - */ - public function enqueuePendingRevisions(CRM_Queue_Queue $queue) { - $this->queue = $queue; - - $currentRevision = $this->getCurrentRevision(); - foreach ($this->getRevisions() as $revision) { - if ($revision > $currentRevision) { - $title = E::ts('Upgrade %1 to revision %2', [ - 1 => $this->extensionName, - 2 => $revision, - ]); - - // note: don't use addTask() because it sets weight=-1 - - $task = new CRM_Queue_Task( - [get_class($this), '_queueAdapter'], - ['upgrade_' . $revision], - $title - ); - $this->queue->createItem($task); - - $task = new CRM_Queue_Task( - [get_class($this), '_queueAdapter'], - ['setCurrentRevision', $revision], - $title - ); - $this->queue->createItem($task); - } - } - } - - /** - * Get a list of revisions. - * - * @return array - * revisionNumbers sorted numerically - */ - public function getRevisions() { - if (!is_array($this->revisions)) { - $this->revisions = []; - - $clazz = new ReflectionClass(get_class($this)); - $methods = $clazz->getMethods(); - foreach ($methods as $method) { - if (preg_match('/^upgrade_(.*)/', $method->name, $matches)) { - $this->revisions[] = $matches[1]; - } - } - sort($this->revisions, SORT_NUMERIC); - } - - return $this->revisions; - } - - public function getCurrentRevision() { - $revision = CRM_Core_BAO_Extension::getSchemaVersion($this->extensionName); - if (!$revision) { - $revision = $this->getCurrentRevisionDeprecated(); - } - return $revision; - } - - private function getCurrentRevisionDeprecated() { - $key = $this->extensionName . ':version'; - if ($revision = \Civi::settings()->get($key)) { - $this->revisionStorageIsDeprecated = TRUE; - } - return $revision; - } - - public function setCurrentRevision($revision) { - CRM_Core_BAO_Extension::setSchemaVersion($this->extensionName, $revision); - // clean up legacy schema version store (CRM-19252) - $this->deleteDeprecatedRevision(); - return TRUE; - } - - private function deleteDeprecatedRevision() { - if ($this->revisionStorageIsDeprecated) { - $setting = new CRM_Core_BAO_Setting(); - $setting->name = $this->extensionName . ':version'; - $setting->delete(); - CRM_Core_Error::debug_log_message("Migrated extension schema revision ID for {$this->extensionName} from civicrm_setting (deprecated) to civicrm_extension.\n"); - } - } - - // ******** Hook delegates ******** - - /** - * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install - */ - public function onInstall() { - $files = glob($this->extensionDir . '/sql/*_install.sql'); - if (is_array($files)) { - foreach ($files as $file) { - CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $file); - } - } - $files = glob($this->extensionDir . '/sql/*_install.mysql.tpl'); - if (is_array($files)) { - foreach ($files as $file) { - $this->executeSqlTemplate($file); - } - } - $files = glob($this->extensionDir . '/xml/*_install.xml'); - if (is_array($files)) { - foreach ($files as $file) { - $this->executeCustomDataFileByAbsPath($file); - } - } - if (is_callable([$this, 'install'])) { - $this->install(); - } - } - - /** - * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall - */ - public function onPostInstall() { - $revisions = $this->getRevisions(); - if (!empty($revisions)) { - $this->setCurrentRevision(max($revisions)); - } - if (is_callable([$this, 'postInstall'])) { - $this->postInstall(); - } - } - - /** - * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall - */ - public function onUninstall() { - $files = glob($this->extensionDir . '/sql/*_uninstall.mysql.tpl'); - if (is_array($files)) { - foreach ($files as $file) { - $this->executeSqlTemplate($file); - } - } - if (is_callable([$this, 'uninstall'])) { - $this->uninstall(); - } - $files = glob($this->extensionDir . '/sql/*_uninstall.sql'); - if (is_array($files)) { - foreach ($files as $file) { - CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $file); - } - } - } - - /** - * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable - */ - public function onEnable() { - // stub for possible future use - if (is_callable([$this, 'enable'])) { - $this->enable(); - } - } - - /** - * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable - */ - public function onDisable() { - // stub for possible future use - if (is_callable([$this, 'disable'])) { - $this->disable(); - } - } - - public function onUpgrade($op, CRM_Queue_Queue $queue = NULL) { - switch ($op) { - case 'check': - return [$this->hasPendingRevisions()]; - - case 'enqueue': - return $this->enqueuePendingRevisions($queue); - - default: - } - } - -} diff --git a/ext/afform/core/afform.civix.php b/ext/afform/core/afform.civix.php index 11006a5f58cc..85f9a141821c 100644 --- a/ext/afform/core/afform.civix.php +++ b/ext/afform/core/afform.civix.php @@ -84,27 +84,20 @@ public static function findClass($suffix) { * * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config */ -function _afform_civix_civicrm_config(&$config = NULL) { +function _afform_civix_civicrm_config($config = NULL) { static $configured = FALSE; if ($configured) { return; } $configured = TRUE; - $template = CRM_Core_Smarty::singleton(); - $extRoot = __DIR__ . DIRECTORY_SEPARATOR; $extDir = $extRoot . 'templates'; - - if (is_array($template->template_dir)) { - array_unshift($template->template_dir, $extDir); - } - else { - $template->template_dir = [$extDir, $template->template_dir]; - } + CRM_Core_Smarty::singleton()->addTemplateDir($extDir); $include_path = $extRoot . PATH_SEPARATOR . get_include_path(); set_include_path($include_path); + // Based on , this does not currently require mixin/polyfill.php. } /** @@ -114,35 +107,7 @@ function _afform_civix_civicrm_config(&$config = NULL) { */ function _afform_civix_civicrm_install() { _afform_civix_civicrm_config(); - if ($upgrader = _afform_civix_upgrader()) { - $upgrader->onInstall(); - } -} - -/** - * Implements hook_civicrm_postInstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall - */ -function _afform_civix_civicrm_postInstall() { - _afform_civix_civicrm_config(); - if ($upgrader = _afform_civix_upgrader()) { - if (is_callable([$upgrader, 'onPostInstall'])) { - $upgrader->onPostInstall(); - } - } -} - -/** - * Implements hook_civicrm_uninstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall - */ -function _afform_civix_civicrm_uninstall(): void { - _afform_civix_civicrm_config(); - if ($upgrader = _afform_civix_upgrader()) { - $upgrader->onUninstall(); - } + // Based on , this does not currently require mixin/polyfill.php. } /** @@ -152,56 +117,7 @@ function _afform_civix_civicrm_uninstall(): void { */ function _afform_civix_civicrm_enable(): void { _afform_civix_civicrm_config(); - if ($upgrader = _afform_civix_upgrader()) { - if (is_callable([$upgrader, 'onEnable'])) { - $upgrader->onEnable(); - } - } -} - -/** - * (Delegated) Implements hook_civicrm_disable(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable - * @return mixed - */ -function _afform_civix_civicrm_disable(): void { - _afform_civix_civicrm_config(); - if ($upgrader = _afform_civix_upgrader()) { - if (is_callable([$upgrader, 'onDisable'])) { - $upgrader->onDisable(); - } - } -} - -/** - * (Delegated) Implements hook_civicrm_upgrade(). - * - * @param $op string, the type of operation being performed; 'check' or 'enqueue' - * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks - * - * @return mixed - * based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending) - * for 'enqueue', returns void - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade - */ -function _afform_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { - if ($upgrader = _afform_civix_upgrader()) { - return $upgrader->onUpgrade($op, $queue); - } -} - -/** - * @return CRM_Afform_Upgrader - */ -function _afform_civix_upgrader() { - if (!file_exists(__DIR__ . '/CRM/Afform/Upgrader.php')) { - return NULL; - } - else { - return CRM_Afform_Upgrader_Base::instance(); - } + // Based on , this does not currently require mixin/polyfill.php. } /** diff --git a/ext/afform/core/afform.php b/ext/afform/core/afform.php index e72f2eca212f..b381f64801a9 100644 --- a/ext/afform/core/afform.php +++ b/ext/afform/core/afform.php @@ -76,24 +76,6 @@ function afform_civicrm_install() { _afform_civix_civicrm_install(); } -/** - * Implements hook_civicrm_postInstall(). - * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_postInstall - */ -function afform_civicrm_postInstall() { - _afform_civix_civicrm_postInstall(); -} - -/** - * Implements hook_civicrm_uninstall(). - * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall - */ -function afform_civicrm_uninstall() { - _afform_civix_civicrm_uninstall(); -} - /** * Implements hook_civicrm_enable(). * @@ -103,24 +85,6 @@ function afform_civicrm_enable() { _afform_civix_civicrm_enable(); } -/** - * Implements hook_civicrm_disable(). - * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable - */ -function afform_civicrm_disable() { - _afform_civix_civicrm_disable(); -} - -/** - * Implements hook_civicrm_upgrade(). - * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade - */ -function afform_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { - return _afform_civix_civicrm_upgrade($op, $queue); -} - /** * Implements hook_civicrm_managed(). * diff --git a/ext/afform/core/info.xml b/ext/afform/core/info.xml index 6289c93124b4..5dad5ebf44ca 100644 --- a/ext/afform/core/info.xml +++ b/ext/afform/core/info.xml @@ -21,7 +21,7 @@ The Form Core extension is required to use any dynamic form. To administer and edit forms, also install the FormBuilder extension. CRM/Afform - 22.10.0 + 22.12.1 @@ -35,4 +35,5 @@ mgd-php@1.0.0 scan-classes@1.0.0 + CRM_Afform_Upgrader From 597e807091d835fba28a636ea8f9da76bf63b1a0 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 1 Jan 2023 17:57:47 +1300 Subject: [PATCH 007/106] Unconditionally assign registerClosed on event info page --- CRM/Event/Page/EventInfo.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CRM/Event/Page/EventInfo.php b/CRM/Event/Page/EventInfo.php index 58681f7177bf..8790c171bf5e 100644 --- a/CRM/Event/Page/EventInfo.php +++ b/CRM/Event/Page/EventInfo.php @@ -280,10 +280,8 @@ public function run() { $this->assign('registerURL', $url); } } - elseif (CRM_Core_Permission::check('register for events')) { - $this->assign('registerClosed', TRUE); - } } + $this->assign('registerClosed', !empty($values['event']['is_online_registration']) && !$isEventOpenForRegistration); $this->assign('allowRegistration', $allowRegistration); From 34adfbd1a8a45f891af3069b00a52027602f84de Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 2 Jan 2023 18:27:36 +1300 Subject: [PATCH 008/106] Remove code deprecated in 2019 --- CRM/Contact/BAO/Query.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 3200224475c8..054de8adbf88 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -5298,10 +5298,6 @@ public function dateQueryBuilder( ) { // @todo - remove dateFormat - pretty sure it's never passed in... [$name, $op, $value, $grouping, $wildcard] = $values; - if ($name !== $fieldName && $name !== "{$fieldName}_low" && $name !== "{$fieldName}_high") { - CRM_Core_Error::deprecatedFunctionWarning('Date query builder called unexpectedly'); - return; - } if ($tableName === 'civicrm_contact') { // Special handling for contact table as it has a known alias in advanced search. $tableName = 'contact_a'; From 9063eca3ff64304075a5e7c4e164ee62b41d48ce Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 2 Jan 2023 18:30:43 +1300 Subject: [PATCH 009/106] Remove code deprecated in 2019 --- CRM/Contact/BAO/Query.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 054de8adbf88..86c6ae86fc5d 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -6747,8 +6747,6 @@ protected function addBasicCancelStatsToSummary(&$summary, $where, $from) { * @param string $additionalFromClause * Should be clause with proper joins, effective to reduce where clause load. * - * @param bool $skipOrderAndLimit - * * @return string * * @throws \CRM_Core_Exception @@ -6758,23 +6756,10 @@ public function getSearchSQL( $count = FALSE, $includeContactIds = FALSE, $sortByChar = FALSE, $groupContacts = FALSE, $additionalWhereClause = NULL, $sortOrder = NULL, - $additionalFromClause = NULL, $skipOrderAndLimit = FALSE) { + $additionalFromClause = NULL) { $sqlParts = $this->getSearchSQLParts($offset, $rowCount, $sort, $count, $includeContactIds, $sortByChar, $groupContacts, $additionalWhereClause, $sortOrder, $additionalFromClause); - - if ($sortByChar) { - CRM_Core_Error::deprecatedFunctionWarning('sort by char is deprecated - use alphabetQuery method'); - $sqlParts['order_by'] = 'ORDER BY sort_name asc'; - } - - if ($skipOrderAndLimit) { - CRM_Core_Error::deprecatedFunctionWarning('skipOrderAndLimit is deprected - call getSearchSQLParts & construct it in the calling function'); - $query = "{$sqlParts['select']} {$sqlParts['from']} {$sqlParts['where']} {$sqlParts['having']} {$sqlParts['group_by']}"; - } - else { - $query = "{$sqlParts['select']} {$sqlParts['from']} {$sqlParts['where']} {$sqlParts['having']} {$sqlParts['group_by']} {$sqlParts['order_by']} {$sqlParts['limit']}"; - } - return $query; + return "{$sqlParts['select']} {$sqlParts['from']} {$sqlParts['where']} {$sqlParts['having']} {$sqlParts['group_by']} {$sqlParts['order_by']} {$sqlParts['limit']}"; } /** From 8e454e9ae7ae3fe0f62cd7037fb3e2f9bb436d0f Mon Sep 17 00:00:00 2001 From: John Kingsnorth Date: Fri, 23 Dec 2022 00:29:40 +0000 Subject: [PATCH 010/106] dev/core#2559 Support tenancy in OAuth providers --- .../CRM/OAuth/DAO/OAuthClient.php | 32 +++- .../CRM/OAuth/DAO/OAuthContactToken.php | 2 +- .../CRM/OAuth/DAO/OAuthSysToken.php | 2 +- ext/oauth-client/CRM/OAuth/Upgrader.php | 12 ++ .../Civi/OAuth/CiviGenericProvider.php | 47 ++++++ .../Civi/OAuth/OAuthLeagueFacade.php | 1 + .../ang/oauthClientCreateHelp.aff.html | 4 +- .../ang/oauthClientCreator.aff.html | 13 +- .../ang/oauthClientEditor.aff.html | 13 +- ext/oauth-client/oauth_client.civix.php | 10 +- .../providers/ms-exchange.dist.json | 7 +- ext/oauth-client/sql/auto_install.sql | 146 +++++++----------- ext/oauth-client/sql/auto_uninstall.sql | 6 +- .../Civi/OAuth/CiviGenericProviderTest.php | 98 ++++++++++++ .../xml/schema/CRM/OAuth/OAuthClient.xml | 12 ++ 15 files changed, 291 insertions(+), 114 deletions(-) create mode 100644 ext/oauth-client/tests/phpunit/Civi/OAuth/CiviGenericProviderTest.php diff --git a/ext/oauth-client/CRM/OAuth/DAO/OAuthClient.php b/ext/oauth-client/CRM/OAuth/DAO/OAuthClient.php index 8ef1e32107b7..eb8826a22f25 100644 --- a/ext/oauth-client/CRM/OAuth/DAO/OAuthClient.php +++ b/ext/oauth-client/CRM/OAuth/DAO/OAuthClient.php @@ -6,7 +6,7 @@ * * Generated from oauth-client/xml/schema/CRM/OAuth/OAuthClient.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:6d11e5e77e49b52267e60124c13d9fa4) + * (GenCodeChecksum:547088257f723e251fbec42e97c710bb) */ use CRM_OAuth_ExtensionUtil as E; @@ -58,6 +58,15 @@ class CRM_OAuth_DAO_OAuthClient extends CRM_Core_DAO { */ public $guid; + /** + * Tenant ID + * + * @var string|null + * (SQL type: varchar(128)) + * Note that values will be retrieved from the database as a string. + */ + public $tenant; + /** * Client Secret * @@ -175,6 +184,23 @@ public static function &fields() { 'localizable' => 0, 'add' => '5.32', ], + 'tenant' => [ + 'name' => 'tenant', + 'type' => CRM_Utils_Type::T_STRING, + 'title' => E::ts('Tenant ID'), + 'description' => E::ts('Tenant ID'), + 'maxlength' => 128, + 'size' => CRM_Utils_Type::HUGE, + 'where' => 'civicrm_oauth_client.tenant', + 'permission' => [ + 'manage OAuth client', + ], + 'table_name' => 'civicrm_oauth_client', + 'entity' => 'OAuthClient', + 'bao' => 'CRM_OAuth_DAO_OAuthClient', + 'localizable' => 0, + 'add' => '5.57', + ], 'secret' => [ 'name' => 'secret', 'type' => CRM_Utils_Type::T_TEXT, @@ -218,6 +244,10 @@ public static function &fields() { 'entity' => 'OAuthClient', 'bao' => 'CRM_OAuth_DAO_OAuthClient', 'localizable' => 0, + 'html' => [ + 'type' => 'CheckBox', + 'label' => E::ts("Enabled"), + ], 'add' => '5.32', ], 'created_date' => [ diff --git a/ext/oauth-client/CRM/OAuth/DAO/OAuthContactToken.php b/ext/oauth-client/CRM/OAuth/DAO/OAuthContactToken.php index 65305eb68ea4..1031036c9e51 100644 --- a/ext/oauth-client/CRM/OAuth/DAO/OAuthContactToken.php +++ b/ext/oauth-client/CRM/OAuth/DAO/OAuthContactToken.php @@ -6,7 +6,7 @@ * * Generated from oauth-client/xml/schema/CRM/OAuth/OAuthContactToken.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:1246756a94c72807dc6cb4bc2c70bb7e) + * (GenCodeChecksum:e94388515cadc3bb149a0339ef42acdb) */ use CRM_OAuth_ExtensionUtil as E; diff --git a/ext/oauth-client/CRM/OAuth/DAO/OAuthSysToken.php b/ext/oauth-client/CRM/OAuth/DAO/OAuthSysToken.php index ee08c34adaf9..9d3070cbf5e3 100644 --- a/ext/oauth-client/CRM/OAuth/DAO/OAuthSysToken.php +++ b/ext/oauth-client/CRM/OAuth/DAO/OAuthSysToken.php @@ -6,7 +6,7 @@ * * Generated from oauth-client/xml/schema/CRM/OAuth/OAuthSysToken.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:14387fad3c51ab994575b3cd759e6229) + * (GenCodeChecksum:5e1f78f265ffdd9101b9c5f76ed947f2) */ use CRM_OAuth_ExtensionUtil as E; diff --git a/ext/oauth-client/CRM/OAuth/Upgrader.php b/ext/oauth-client/CRM/OAuth/Upgrader.php index 9b38f5c40e4c..df5fdd0eb55e 100644 --- a/ext/oauth-client/CRM/OAuth/Upgrader.php +++ b/ext/oauth-client/CRM/OAuth/Upgrader.php @@ -36,4 +36,16 @@ public function upgrade_0001(): bool { return TRUE; } + /** + * Add support for tenancy + * + * @return bool + * @throws Exception + */ + public function upgrade_5581(): bool { + $this->ctx->log->info('Applying oauth-client update 5581. Adding tenant column to the civicrm_oauth_client table.'); + $this->addTask('Add Tenant ID to civicrm_oauth_client', 'addColumn', 'civicrm_oauth_client', 'tenant', 'varchar(128) NULL COMMENT "Tenant ID" AFTER guid'); + return TRUE; + } + } diff --git a/ext/oauth-client/Civi/OAuth/CiviGenericProvider.php b/ext/oauth-client/Civi/OAuth/CiviGenericProvider.php index 8bff0ffb38d2..6edd596a0b73 100644 --- a/ext/oauth-client/Civi/OAuth/CiviGenericProvider.php +++ b/ext/oauth-client/Civi/OAuth/CiviGenericProvider.php @@ -17,9 +17,16 @@ * and proprietary scopes+URLs. To use this, set the the option: * * "urlResourceOwnerDetails": "{{use_id_token}}", + * - Allow support for {{tenant}} token in provider URLs, if the provider has + * the 'tenancy' option set to TRUE (eg: ms-exchange). */ class CiviGenericProvider extends \League\OAuth2\Client\Provider\GenericProvider { + /** + * @var string + */ + protected $tenant; + protected function getAuthorizationParameters(array $options) { $newOptions = parent::getAuthorizationParameters($options); if (!isset($options['approval_prompt'])) { @@ -30,6 +37,46 @@ protected function getAuthorizationParameters(array $options) { return $newOptions; } + /** + * Returns the base URL for authorizing a client. + * + * Eg. https://oauth.service.com/authorize + * + * @return string + */ + public function getBaseAuthorizationUrl() { + $url = parent::getBaseAuthorizationUrl(); + return $this->replaceTenantToken($url); + } + + /** + * Returns the base URL for requesting an access token. + * + * Eg. https://oauth.service.com/token + * + * @param array $params + * @return string + */ + public function getBaseAccessTokenUrl(array $params) { + $url = parent::getBaseAccessTokenUrl($params); + return $this->replaceTenantToken($url); + } + + /** + * Replace {{tenant}} in the endpoint URLs with 'common' for consumer accounts + * or the tenancy ID for dedicated services. + * + * @param string $str URL to replace + * @return string + */ + private function replaceTenantToken($str) { + if (strpos($str, '{{tenant}}') !== FALSE) { + $tenant = !empty($this->tenant) ? $this->tenant : 'common'; + $str = str_replace('{{tenant}}', $tenant, $str); + } + return $str; + } + /** * Requests resource owner details. * diff --git a/ext/oauth-client/Civi/OAuth/OAuthLeagueFacade.php b/ext/oauth-client/Civi/OAuth/OAuthLeagueFacade.php index 01fd7d406480..27d0c18fcbe6 100644 --- a/ext/oauth-client/Civi/OAuth/OAuthLeagueFacade.php +++ b/ext/oauth-client/Civi/OAuth/OAuthLeagueFacade.php @@ -34,6 +34,7 @@ public function createProviderOptions($clientDef) { $localOptions = []; $localOptions['clientId'] = $clientDef['guid']; + $localOptions['tenant'] = !empty($clientDef['tenant']) ? $clientDef['tenant'] : ''; $localOptions['clientSecret'] = $clientDef['secret']; // NOTE: If we ever have frontend users, this may need to change. $localOptions['redirectUri'] = \CRM_OAuth_BAO_OAuthClient::getRedirectUri(); diff --git a/ext/oauth-client/ang/oauthClientCreateHelp.aff.html b/ext/oauth-client/ang/oauthClientCreateHelp.aff.html index ab9a8b19d248..bf774c7b9969 100644 --- a/ext/oauth-client/ang/oauthClientCreateHelp.aff.html +++ b/ext/oauth-client/ang/oauthClientCreateHelp.aff.html @@ -25,8 +25,8 @@
  • - {{ts('Determine the client credentials ("Client ID" and "Client Secret").')}} + {{ts('Determine the client credentials, including a client ID and secret.')}}
  • -

    {{ts('Finally, copy the client credentials below:')}}

    +

    {{ts('Finally, enter the client credentials below.')}}

    diff --git a/ext/oauth-client/ang/oauthClientCreator.aff.html b/ext/oauth-client/ang/oauthClientCreator.aff.html index 15e7443575a4..810cfd9ee397 100644 --- a/ext/oauth-client/ang/oauthClientCreator.aff.html +++ b/ext/oauth-client/ang/oauthClientCreator.aff.html @@ -3,12 +3,17 @@
    - - + + +
    +
    + + +
    {{ts('Optional. Leave blank for consumer accounts. If you have a dedicated instance of Microsoft 365, and your application is not multi-tenancy, then enter your tenant ID here.')}}
    - - + +
    diff --git a/ext/oauth-client/ang/oauthClientEditor.aff.html b/ext/oauth-client/ang/oauthClientEditor.aff.html index 7588460ebc53..359a24cda0e4 100644 --- a/ext/oauth-client/ang/oauthClientEditor.aff.html +++ b/ext/oauth-client/ang/oauthClientEditor.aff.html @@ -11,12 +11,17 @@
    - - + + +
    +
    + + +

    {{ts('Optional. Leave blank for consumer accounts. If you have a dedicated instance of Microsoft 365, and your application is not multi-tenancy, then enter your tenant ID here.')}}

    - - + +
    diff --git a/ext/oauth-client/oauth_client.civix.php b/ext/oauth-client/oauth_client.civix.php index e83d3f14ba52..3d9ae5d3f523 100644 --- a/ext/oauth-client/oauth_client.civix.php +++ b/ext/oauth-client/oauth_client.civix.php @@ -24,7 +24,7 @@ class CRM_OAuth_ExtensionUtil { * Translated text. * @see ts */ - public static function ts($text, $params = []): string { + public static function ts($text, $params = []) { if (!array_key_exists('domain', $params)) { $params['domain'] = [self::LONG_NAME, NULL]; } @@ -41,7 +41,7 @@ public static function ts($text, $params = []): string { * Ex: 'http://example.org/sites/default/ext/org.example.foo'. * Ex: 'http://example.org/sites/default/ext/org.example.foo/css/foo.css'. */ - public static function url($file = NULL): string { + public static function url($file = NULL) { if ($file === NULL) { return rtrim(CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME), '/'); } @@ -138,7 +138,7 @@ function _oauth_client_civix_civicrm_postInstall() { * * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall */ -function _oauth_client_civix_civicrm_uninstall(): void { +function _oauth_client_civix_civicrm_uninstall() { _oauth_client_civix_civicrm_config(); if ($upgrader = _oauth_client_civix_upgrader()) { $upgrader->onUninstall(); @@ -150,7 +150,7 @@ function _oauth_client_civix_civicrm_uninstall(): void { * * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable */ -function _oauth_client_civix_civicrm_enable(): void { +function _oauth_client_civix_civicrm_enable() { _oauth_client_civix_civicrm_config(); if ($upgrader = _oauth_client_civix_upgrader()) { if (is_callable([$upgrader, 'onEnable'])) { @@ -165,7 +165,7 @@ function _oauth_client_civix_civicrm_enable(): void { * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable * @return mixed */ -function _oauth_client_civix_civicrm_disable(): void { +function _oauth_client_civix_civicrm_disable() { _oauth_client_civix_civicrm_config(); if ($upgrader = _oauth_client_civix_upgrader()) { if (is_callable([$upgrader, 'onDisable'])) { diff --git a/ext/oauth-client/providers/ms-exchange.dist.json b/ext/oauth-client/providers/ms-exchange.dist.json index b496c5cb01a1..9065e2cbe924 100644 --- a/ext/oauth-client/providers/ms-exchange.dist.json +++ b/ext/oauth-client/providers/ms-exchange.dist.json @@ -1,8 +1,8 @@ { "title": "Microsoft Exchange Online", "options": { - "urlAuthorize": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize", - "urlAccessToken": "https://login.microsoftonline.com/common/oauth2/v2.0/token", + "urlAuthorize": "https://login.microsoftonline.com/{{tenant}}/oauth2/v2.0/authorize", + "urlAccessToken": "https://login.microsoftonline.com/{{tenant}}/oauth2/v2.0/token", "urlResourceOwnerDetails": "{{use_id_token}}", "scopeSeparator": " ", "scopes": [ @@ -12,7 +12,8 @@ "openid", "email", "offline_access" - ] + ], + "tenancy": true }, "mailSettingsTemplate": { "name": "{{token.resource_owner.email}}", diff --git a/ext/oauth-client/sql/auto_install.sql b/ext/oauth-client/sql/auto_install.sql index dbb478e5c089..7c27e6ce5532 100644 --- a/ext/oauth-client/sql/auto_install.sql +++ b/ext/oauth-client/sql/auto_install.sql @@ -9,21 +9,9 @@ -- Generated from schema.tpl -- DO NOT EDIT. Generated by CRM_Core_CodeGen -- - --- +--------------------------------------------------------------------+ --- | Copyright CiviCRM LLC. All rights reserved. | --- | | --- | This work is published under the GNU AGPLv3 license with some | --- | permitted exceptions and without any warranty. For full license | --- | and copyright information, see https://civicrm.org/licensing | --- +--------------------------------------------------------------------+ --- --- Generated from drop.tpl --- DO NOT EDIT. Generated by CRM_Core_CodeGen --- -- /******************************************************* -- * --- * Clean up the existing tables +-- * Clean up the existing tables - this section generated from drop.tpl -- * -- *******************************************************/ @@ -46,28 +34,20 @@ SET FOREIGN_KEY_CHECKS=1; -- * -- *******************************************************/ CREATE TABLE `civicrm_oauth_client` ( - - - `id` int unsigned AUTO_INCREMENT COMMENT 'Internal Client ID', - `provider` varchar(128) NOT NULL COMMENT 'Provider', - `guid` varchar(128) NOT NULL COMMENT 'Client ID', - `secret` text COMMENT 'Client Secret', - `options` text COMMENT 'Extra override options for the service (JSON)', - `is_active` tinyint NOT NULL DEFAULT 1 COMMENT 'Is the client currently enabled?', - `created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the client was created.', - `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When the client was created or modified.' -, - PRIMARY KEY (`id`) - - , INDEX `UI_provider`( - provider - ) - , INDEX `UI_guid`( - guid - ) - - -) ENGINE=InnoDB ; + `id` int unsigned AUTO_INCREMENT COMMENT 'Internal Client ID', + `provider` varchar(128) NOT NULL COMMENT 'Provider', + `guid` varchar(128) NOT NULL COMMENT 'Client ID', + `tenant` varchar(128) COMMENT 'Tenant ID', + `secret` text COMMENT 'Client Secret', + `options` text COMMENT 'Extra override options for the service (JSON)', + `is_active` tinyint NOT NULL DEFAULT 1 COMMENT 'Is the client currently enabled?', + `created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the client was created.', + `modified_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When the client was created or modified.', + PRIMARY KEY (`id`), + INDEX `UI_provider`(provider), + INDEX `UI_guid`(guid) +) +ENGINE=InnoDB; -- /******************************************************* -- * @@ -75,33 +55,28 @@ CREATE TABLE `civicrm_oauth_client` ( -- * -- *******************************************************/ CREATE TABLE `civicrm_oauth_contact_token` ( - - - `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Token ID', - `tag` varchar(128) COMMENT 'The tag specifies how this token will be used.', - `client_id` int unsigned COMMENT 'Client ID', - `contact_id` int unsigned COMMENT 'Contact ID', - `grant_type` varchar(31) COMMENT 'Ex: authorization_code', - `scopes` text COMMENT 'List of scopes addressed by this token', - `token_type` varchar(128) COMMENT 'Ex: Bearer or MAC', - `access_token` text COMMENT 'Token to present when accessing resources', - `expires` int unsigned DEFAULT 0 COMMENT 'Expiration time for the access_token (seconds since epoch)', - `refresh_token` text COMMENT 'Token to present when refreshing the access_token', - `resource_owner_name` varchar(128) COMMENT 'Identifier for the resource owner. Structure varies by service.', - `resource_owner` text COMMENT 'Cached details describing the resource owner', - `error` text COMMENT '?? copied from OAuthSysToken', - `raw` text COMMENT 'The token response data, per AccessToken::jsonSerialize', - `created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the token was created.', - `modified_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When the token was created or modified.' -, - PRIMARY KEY (`id`) - - , INDEX `UI_tag`( - tag - ) - -, CONSTRAINT FK_civicrm_oauth_contact_token_client_id FOREIGN KEY (`client_id`) REFERENCES `civicrm_oauth_client`(`id`) ON DELETE CASCADE, CONSTRAINT FK_civicrm_oauth_contact_token_contact_id FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB ; + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Token ID', + `tag` varchar(128) COMMENT 'The tag specifies how this token will be used.', + `client_id` int unsigned COMMENT 'Client ID', + `contact_id` int unsigned COMMENT 'Contact ID', + `grant_type` varchar(31) COMMENT 'Ex: authorization_code', + `scopes` text COMMENT 'List of scopes addressed by this token', + `token_type` varchar(128) COMMENT 'Ex: Bearer or MAC', + `access_token` text COMMENT 'Token to present when accessing resources', + `expires` int unsigned DEFAULT 0 COMMENT 'Expiration time for the access_token (seconds since epoch)', + `refresh_token` text COMMENT 'Token to present when refreshing the access_token', + `resource_owner_name` varchar(128) COMMENT 'Identifier for the resource owner. Structure varies by service.', + `resource_owner` text COMMENT 'Cached details describing the resource owner', + `error` text COMMENT '?? copied from OAuthSysToken', + `raw` text COMMENT 'The token response data, per AccessToken::jsonSerialize', + `created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the token was created.', + `modified_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When the token was created or modified.', + PRIMARY KEY (`id`), + INDEX `UI_tag`(tag), + CONSTRAINT FK_civicrm_oauth_contact_token_client_id FOREIGN KEY (`client_id`) REFERENCES `civicrm_oauth_client`(`id`) ON DELETE CASCADE, + CONSTRAINT FK_civicrm_oauth_contact_token_contact_id FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE CASCADE +) +ENGINE=InnoDB; -- /******************************************************* -- * @@ -109,30 +84,23 @@ CREATE TABLE `civicrm_oauth_contact_token` ( -- * -- *******************************************************/ CREATE TABLE `civicrm_oauth_systoken` ( - - - `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Token ID', - `tag` varchar(128) COMMENT 'The tag specifies how this token will be used.', - `client_id` int unsigned COMMENT 'Client ID', - `grant_type` varchar(31) COMMENT 'Ex: authorization_code', - `scopes` text COMMENT 'List of scopes addressed by this token', - `token_type` varchar(128) COMMENT 'Ex: Bearer or MAC', - `access_token` text COMMENT 'Token to present when accessing resources', - `expires` int unsigned DEFAULT 0 COMMENT 'Expiration time for the access_token (seconds since epoch)', - `refresh_token` text COMMENT 'Token to present when refreshing the access_token', - `resource_owner_name` varchar(128) COMMENT 'Identifier for the resource owner. Structure varies by service.', - `resource_owner` text COMMENT 'Cached details describing the resource owner', - `error` text COMMENT 'List of scopes addressed by this token', - `raw` text COMMENT 'The token response data, per AccessToken::jsonSerialize', - `created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the token was created.', - `modified_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When the token was created or modified.' -, - PRIMARY KEY (`id`) - - , INDEX `UI_tag`( - tag - ) - -, CONSTRAINT FK_civicrm_oauth_systoken_client_id FOREIGN KEY (`client_id`) REFERENCES `civicrm_oauth_client`(`id`) ON DELETE CASCADE -) ENGINE=InnoDB ; - + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Token ID', + `tag` varchar(128) COMMENT 'The tag specifies how this token will be used.', + `client_id` int unsigned COMMENT 'Client ID', + `grant_type` varchar(31) COMMENT 'Ex: authorization_code', + `scopes` text COMMENT 'List of scopes addressed by this token', + `token_type` varchar(128) COMMENT 'Ex: Bearer or MAC', + `access_token` text COMMENT 'Token to present when accessing resources', + `expires` int unsigned DEFAULT 0 COMMENT 'Expiration time for the access_token (seconds since epoch)', + `refresh_token` text COMMENT 'Token to present when refreshing the access_token', + `resource_owner_name` varchar(128) COMMENT 'Identifier for the resource owner. Structure varies by service.', + `resource_owner` text COMMENT 'Cached details describing the resource owner', + `error` text COMMENT 'List of scopes addressed by this token', + `raw` text COMMENT 'The token response data, per AccessToken::jsonSerialize', + `created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the token was created.', + `modified_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When the token was created or modified.', + PRIMARY KEY (`id`), + INDEX `UI_tag`(tag), + CONSTRAINT FK_civicrm_oauth_systoken_client_id FOREIGN KEY (`client_id`) REFERENCES `civicrm_oauth_client`(`id`) ON DELETE CASCADE +) +ENGINE=InnoDB; diff --git a/ext/oauth-client/sql/auto_uninstall.sql b/ext/oauth-client/sql/auto_uninstall.sql index a3c96fd5662d..dac2c6f766db 100644 --- a/ext/oauth-client/sql/auto_uninstall.sql +++ b/ext/oauth-client/sql/auto_uninstall.sql @@ -8,11 +8,9 @@ -- -- Generated from drop.tpl -- DO NOT EDIT. Generated by CRM_Core_CodeGen --- --- /******************************************************* --- * --- * Clean up the existing tables +---- /******************************************************* -- * +-- * Clean up the existing tables-- * -- *******************************************************/ SET FOREIGN_KEY_CHECKS=0; diff --git a/ext/oauth-client/tests/phpunit/Civi/OAuth/CiviGenericProviderTest.php b/ext/oauth-client/tests/phpunit/Civi/OAuth/CiviGenericProviderTest.php new file mode 100644 index 000000000000..c9114b68e577 --- /dev/null +++ b/ext/oauth-client/tests/phpunit/Civi/OAuth/CiviGenericProviderTest.php @@ -0,0 +1,98 @@ +install('oauth-client')->apply(); + } + + public function setUp(): void { + $this->makeDummyProviders(); + $this->makeDummyClients(); + parent::setUp(); + } + + public function tearDown(): void { + parent::tearDown(); + } + + public function hook_civicrm_oauthProviders(&$providers) { + $providers = array_merge($providers, $this->providers); + } + + public function makeDummyProviders() { + $this->providers['no-tenancy'] = [ + 'name' => 'no-tenancy', + 'title' => 'Provider without tenancy', + 'options' => [ + 'urlAuthorize' => 'https://dummy/authorize', + 'urlAccessToken' => 'https://dummy/token', + 'urlResourceOwnerDetails' => '{{use_id_token}}', + 'scopes' => ['foo'], + ], + ]; + $this->providers['with-tenancy'] = [ + 'name' => 'with-tenancy', + 'title' => 'Provider with tenancy', + 'options' => [ + 'urlAuthorize' => 'https://dummy/{{tenant}}/authorize', + 'urlAccessToken' => 'https://dummy/{{tenant}}/token', + 'urlResourceOwnerDetails' => '{{use_id_token}}', + 'scopes' => ['foo'], + 'tenancy' => TRUE, + ], + ]; + } + + private function makeDummyClients() { + $this->clients['no-tenancy'] = \Civi\Api4\OAuthClient::create(FALSE)->setValues( + [ + 'provider' => 'no-tenancy', + 'guid' => 'example-client-guid-no-tenancy', + 'secret' => 'example-secret', + ] + )->execute()->single(); + $this->clients['with-tenancy'] = \Civi\Api4\OAuthClient::create(FALSE)->setValues( + [ + 'provider' => 'with-tenancy', + 'guid' => 'example-client-guid-with-tenancy', + 'secret' => 'example-secret', + 'tenant' => '123-456-789', + ] + )->execute()->single(); + } + + public function testTenancyInURLs() { + + // Test no tenancy settings + $provider = \Civi::service('oauth2.league')->createProvider($this->clients['no-tenancy']); + $computedAuthorizationURL = $provider->getBaseAuthorizationUrl(); + $this->assertEquals($this->providers['no-tenancy']['options']['urlAuthorize'], $computedAuthorizationURL); + $computedTokenURL = $provider->getBaseAccessTokenUrl([]); + $this->assertEquals($this->providers['no-tenancy']['options']['urlAccessToken'], $computedTokenURL); + + // Test tenancy token rewrite + $provider = \Civi::service('oauth2.league')->createProvider($this->clients['with-tenancy']); + $computedAuthorizationURL = $provider->getBaseAuthorizationUrl(); + $this->assertEquals('https://dummy/123-456-789/authorize', $computedAuthorizationURL); + $computedTokenURL = $provider->getBaseAccessTokenUrl([]); + $this->assertEquals('https://dummy/123-456-789/token', $computedTokenURL); + + } + +} diff --git a/ext/oauth-client/xml/schema/CRM/OAuth/OAuthClient.xml b/ext/oauth-client/xml/schema/CRM/OAuth/OAuthClient.xml index 467c1e4ecd69..59864cca0c98 100644 --- a/ext/oauth-client/xml/schema/CRM/OAuth/OAuthClient.xml +++ b/ext/oauth-client/xml/schema/CRM/OAuth/OAuthClient.xml @@ -48,6 +48,18 @@ 5.32 + + tenant + Tenant ID + varchar + 128 + Tenant ID + 5.57 + + manage OAuth client + + + secret Client Secret From 96f987e1c6b21cf1cfe61f5aae05f67bc16c3cca Mon Sep 17 00:00:00 2001 From: Jamie McClelland Date: Wed, 4 Jan 2023 11:31:05 -0500 Subject: [PATCH 011/106] avoid empty error message when submitting PCP page. --- CRM/PCP/Page/PCPInfo.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/CRM/PCP/Page/PCPInfo.php b/CRM/PCP/Page/PCPInfo.php index 2a3cf3762ee9..53711f255e04 100644 --- a/CRM/PCP/Page/PCPInfo.php +++ b/CRM/PCP/Page/PCPInfo.php @@ -62,17 +62,6 @@ public function run() { $pcpStatus = CRM_Core_OptionGroup::values("pcp_status"); $approvedId = CRM_Core_PseudoConstant::getKey('CRM_PCP_BAO_PCP', 'status_id', 'Approved'); - // check if PCP is created by anonymous user - $anonymousPCP = CRM_Utils_Request::retrieve('ap', 'Boolean', $this); - if ($anonymousPCP) { - $loginURL = $config->userSystem->getLoginURL(); - $anonMessage = ts('Once you\'ve received your new account welcome email, you can click here to login and promote your campaign page.', [1 => $loginURL]); - CRM_Core_Session::setStatus($anonMessage, ts('Success'), 'success'); - } - else { - $statusMessage = ts('The personal campaign page you requested is currently unavailable. However you can still support the campaign by making a contribution here.'); - } - $pcpBlock = new CRM_PCP_DAO_PCPBlock(); $pcpBlock->entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($pcpInfo['page_type']); $pcpBlock->entity_id = $pcpInfo['page_id']; @@ -86,6 +75,21 @@ public function run() { $urlBase = 'civicrm/event/register'; } + // check if PCP is created by anonymous user + $anonymousPCP = CRM_Utils_Request::retrieve('ap', 'Boolean', $this); + if ($anonymousPCP) { + $loginURL = $config->userSystem->getLoginURL(); + $anonMessage = ts('Once you\'ve received your new account welcome email, you can click here to login and promote your campaign page.', [1 => $loginURL]); + CRM_Core_Session::setStatus($anonMessage, ts('Success'), 'success'); + CRM_Utils_System::redirect(CRM_Utils_System::url($urlBase, + "reset=1&id=" . $pcpInfo['page_id'], + FALSE, NULL, FALSE, TRUE + )); + } + else { + $statusMessage = ts('The personal campaign page you requested is currently unavailable. However you can still support the campaign by making a contribution here.'); + } + if ($pcpInfo['status_id'] != $approvedId || !$pcpInfo['is_active']) { if ($pcpInfo['contact_id'] != $session->get('userID') && !$permissionCheck) { CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url($urlBase, From 73195cb46d02cbc46bde30b8daa35d4b5f70e9f8 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Wed, 4 Jan 2023 16:31:44 -0500 Subject: [PATCH 012/106] remove broken test --- .../Event/Import/Parser/ParticipantTest.php | 67 +------------------ 1 file changed, 1 insertion(+), 66 deletions(-) diff --git a/tests/phpunit/CRM/Event/Import/Parser/ParticipantTest.php b/tests/phpunit/CRM/Event/Import/Parser/ParticipantTest.php index d9623d256427..3a7c2fb47c4e 100644 --- a/tests/phpunit/CRM/Event/Import/Parser/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/Import/Parser/ParticipantTest.php @@ -2,29 +2,8 @@ /** * File for the Participant import class - * - * (PHP 5) - * - * @package CiviCRM - * - * This file is part of CiviCRM - * - * CiviCRM is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation; either version 3 of - * the License, or (at your option) any later version. - * - * CiviCRM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with this program. If not, see - * . */ -use Civi\Api4\Mapping; use Civi\Api4\UserJob; /** @@ -32,7 +11,7 @@ * @group headless * @group import */ -class CRM_Participant_Import_Parser_ParticipantTest extends CiviUnitTestCase { +class CRM_Event_Import_Parser_ParticipantTest extends CiviUnitTestCase { use CRMTraits_Custom_CustomDataTrait; @@ -129,49 +108,6 @@ protected function getMapperFromFieldMappings(array $mappings): array { return $mapper; } - /** - * Test the full form-flow import. - * - * @dataProvider importData - */ - public function testImportCSV($csv, $mapper) :void { - $this->campaignCreate(['name' => 'Soccer cup']); - $this->eventCreate(['title' => 'Rain-forest Cup Youth Soccer Tournament']); - $this->individualCreate(['email' => 'mum@example.com']); - $this->importCSV($csv, $mapper); - $dataSource = new CRM_Import_DataSource_CSV($this->userJobID); - $row = $dataSource->getRow(); - $this->assertEquals('IMPORTED', $row['_status']); - $this->callAPISuccessGetSingle('Participant', ['campaign_id' => 'Soccer Cup']); - $mapping = Mapping::get()->addWhere('mapping_type_id:name', '=', 'Import Participant')->execute()->first(); - $this->assertEquals('my mapping', $mapping['name']); - $this->assertEquals('new mapping', $mapping['description']); - } - - /** - * Data provider for importCSV. - */ - public function importData(): array { - $defaultMapper = [ - ['name' => 'event_id'], - ['name' => 'campaign_id'], - ['name' => 'email'], - ['name' => 'fee_amount'], - ['name' => 'fee_currency'], - ['name' => 'fee_level'], - ['name' => 'is_pay_later'], - ['name' => 'role_id'], - ['name' => 'source'], - ['name' => 'status_id'], - ['name' => 'register_date'], - ['name' => 'do_not_import'], - ]; - return [ - ['csv' => 'participant.csv', 'mapper' => $defaultMapper], - ['csv' => 'participant_with_event_id.csv', 'mapper' => $defaultMapper], - ]; - } - /** * Test that an external id will not match to a deleted contact.. */ @@ -201,7 +137,6 @@ public function testImportWithExternalID() :void { * @param array $submittedValues * * @return int - * @noinspection PhpDocMissingThrowsInspection */ protected function getUserJobID(array $submittedValues = []): int { $userJobID = UserJob::create()->setValues([ From 06d5e20133d7db7759be23d5f92de01a15c793c2 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Thu, 5 Jan 2023 00:01:53 -0500 Subject: [PATCH 013/106] classname should match filename --- tests/phpunit/api/v4/Entity/SystemRotateKeyTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/api/v4/Entity/SystemRotateKeyTest.php b/tests/phpunit/api/v4/Entity/SystemRotateKeyTest.php index 0c62c720a9d7..c2022d366640 100644 --- a/tests/phpunit/api/v4/Entity/SystemRotateKeyTest.php +++ b/tests/phpunit/api/v4/Entity/SystemRotateKeyTest.php @@ -27,7 +27,7 @@ /** * @group headless */ -class RotateKeyTest extends Api4TestBase implements TransactionalInterface { +class SystemRotateKeyTest extends Api4TestBase implements TransactionalInterface { use CryptoTestTrait; From f9b822682814533ce1520d797a12dcde02e7d323 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 4 Jan 2023 21:57:18 -0800 Subject: [PATCH 014/106] Set version to 5.59.alpha1 --- CRM/Upgrade/Incremental/php/FiveFiftyNine.php | 34 +++++++++++++++++++ .../Incremental/sql/5.59.alpha1.mysql.tpl | 1 + ext/afform/admin/info.xml | 4 +-- ext/afform/core/info.xml | 4 +-- ext/afform/html/info.xml | 4 +-- ext/afform/mock/info.xml | 4 +-- ext/authx/info.xml | 4 +-- ext/civicrm_admin_ui/info.xml | 4 +-- ext/civigrant/info.xml | 4 +-- ext/civiimport/info.xml | 4 +-- ext/ckeditor4/info.xml | 4 +-- ext/contributioncancelactions/info.xml | 4 +-- ext/elavon/info.xml | 4 +-- ext/eventcart/info.xml | 4 +-- ext/ewaysingle/info.xml | 4 +-- ext/financialacls/info.xml | 4 +-- ext/flexmailer/info.xml | 4 +-- ext/greenwich/info.xml | 4 +-- ext/legacycustomsearches/info.xml | 4 +-- ext/message_admin/info.xml | 4 +-- ext/oauth-client/info.xml | 4 +-- ext/payflowpro/info.xml | 4 +-- ext/recaptcha/info.xml | 4 +-- ext/search_kit/info.xml | 4 +-- ext/sequentialcreditnotes/info.xml | 4 +-- sql/civicrm_generated.mysql | 2 +- sql/test_data_second_domain.mysql | 2 +- xml/version.xml | 2 +- 28 files changed, 84 insertions(+), 49 deletions(-) create mode 100644 CRM/Upgrade/Incremental/php/FiveFiftyNine.php create mode 100644 CRM/Upgrade/Incremental/sql/5.59.alpha1.mysql.tpl diff --git a/CRM/Upgrade/Incremental/php/FiveFiftyNine.php b/CRM/Upgrade/Incremental/php/FiveFiftyNine.php new file mode 100644 index 000000000000..b084959644c9 --- /dev/null +++ b/CRM/Upgrade/Incremental/php/FiveFiftyNine.php @@ -0,0 +1,34 @@ +addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); + } + +} diff --git a/CRM/Upgrade/Incremental/sql/5.59.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.59.alpha1.mysql.tpl new file mode 100644 index 000000000000..c9bef4a8485e --- /dev/null +++ b/CRM/Upgrade/Incremental/sql/5.59.alpha1.mysql.tpl @@ -0,0 +1 @@ +{* file to handle db changes in 5.59.alpha1 during upgrade *} diff --git a/ext/afform/admin/info.xml b/ext/afform/admin/info.xml index cb0a87029aa1..945d3c3d6b6f 100644 --- a/ext/afform/admin/info.xml +++ b/ext/afform/admin/info.xml @@ -13,10 +13,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2020-01-09 - 5.58.beta1 + 5.59.alpha1 beta - 5.58 + 5.59 FormBuilder provides a UI to administer and edit forms. It is an optional admin tool and not required for the forms to function. diff --git a/ext/afform/core/info.xml b/ext/afform/core/info.xml index 177d029dbe98..999a8a2ce95f 100644 --- a/ext/afform/core/info.xml +++ b/ext/afform/core/info.xml @@ -13,10 +13,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2020-01-09 - 5.58.beta1 + 5.59.alpha1 beta - 5.58 + 5.59 The Form Core extension is required to use any dynamic form. To administer and edit forms, also install the FormBuilder extension. diff --git a/ext/afform/html/info.xml b/ext/afform/html/info.xml index 04d3720ab8ee..311f97f1559c 100644 --- a/ext/afform/html/info.xml +++ b/ext/afform/html/info.xml @@ -13,10 +13,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2020-01-09 - 5.58.beta1 + 5.59.alpha1 alpha - 5.58 + 5.59 org.civicrm.afform diff --git a/ext/afform/mock/info.xml b/ext/afform/mock/info.xml index b04b3d3744d3..72f04564bf18 100644 --- a/ext/afform/mock/info.xml +++ b/ext/afform/mock/info.xml @@ -12,13 +12,13 @@ http://www.gnu.org/licenses/agpl-3.0.html 2020-01-09 - 5.58.beta1 + 5.59.alpha1 mgmt:hidden alpha - 5.58 + 5.59 org.civicrm.afform diff --git a/ext/authx/info.xml b/ext/authx/info.xml index 08eef43f5a5e..1004c0075bae 100644 --- a/ext/authx/info.xml +++ b/ext/authx/info.xml @@ -15,10 +15,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2021-02-11 - 5.58.beta1 + 5.59.alpha1 stable - 5.58 + 5.59 AuthX enables remote applications to connect to CiviCRM. Use it to enable and disable different forms of authentication (such as username-password, API key, and/or JWT). diff --git a/ext/civicrm_admin_ui/info.xml b/ext/civicrm_admin_ui/info.xml index 79981194fe15..b8d24ada0f6a 100644 --- a/ext/civicrm_admin_ui/info.xml +++ b/ext/civicrm_admin_ui/info.xml @@ -15,10 +15,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2022-01-02 - 5.58.beta1 + 5.59.alpha1 alpha - 5.58 + 5.59 org.civicrm.search_kit diff --git a/ext/civigrant/info.xml b/ext/civigrant/info.xml index 5bd8a7a9b054..f724f1f2b5c3 100644 --- a/ext/civigrant/info.xml +++ b/ext/civigrant/info.xml @@ -13,10 +13,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2021-11-11 - 5.58.beta1 + 5.59.alpha1 stable - 5.58 + 5.59 CiviGrant was originally a core component before migrating to an extension diff --git a/ext/civiimport/info.xml b/ext/civiimport/info.xml index b5c3cef2c2d8..65b005d892ea 100644 --- a/ext/civiimport/info.xml +++ b/ext/civiimport/info.xml @@ -15,10 +15,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2022-08-11 - 5.58.beta1 + 5.59.alpha1 alpha - 5.58 + 5.59 Core extension for us to start moving import logic into, has more functionality diff --git a/ext/ckeditor4/info.xml b/ext/ckeditor4/info.xml index cbf9f3d7a8a8..91efe1f5498a 100644 --- a/ext/ckeditor4/info.xml +++ b/ext/ckeditor4/info.xml @@ -15,10 +15,10 @@ https://www.gnu.org/licenses/agpl-3.0.html 2021-05-23 - 5.58.beta1 + 5.59.alpha1 stable - 5.58 + 5.59 This is the version of CKEditor that originally shipped with CiviCRM core diff --git a/ext/contributioncancelactions/info.xml b/ext/contributioncancelactions/info.xml index 8f33cb37da6d..b14739cdd962 100644 --- a/ext/contributioncancelactions/info.xml +++ b/ext/contributioncancelactions/info.xml @@ -15,10 +15,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2020-10-12 - 5.58.beta1 + 5.59.alpha1 stable - 5.58 + 5.59 This code has been moved from core to a separate extension in 5.32. Note that if you disable it failed or cancelled contributions will not cause related memberships and participant records to be updated diff --git a/ext/elavon/info.xml b/ext/elavon/info.xml index dd82b325bf5b..a2bd09442f6a 100644 --- a/ext/elavon/info.xml +++ b/ext/elavon/info.xml @@ -15,10 +15,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2022-08-05 - 5.58.beta1 + 5.59.alpha1 stable - 5.58 + 5.59 diff --git a/ext/eventcart/info.xml b/ext/eventcart/info.xml index 71c6937a7717..861003aeb843 100644 --- a/ext/eventcart/info.xml +++ b/ext/eventcart/info.xml @@ -13,13 +13,13 @@ http://www.gnu.org/licenses/agpl-3.0.html 2020-08-03 - 5.58.beta1 + 5.59.alpha1 mgmt:hidden stable - 5.58 + 5.59 diff --git a/ext/ewaysingle/info.xml b/ext/ewaysingle/info.xml index 0929f12cdc37..64654534716c 100644 --- a/ext/ewaysingle/info.xml +++ b/ext/ewaysingle/info.xml @@ -15,13 +15,13 @@ http://www.gnu.org/licenses/agpl-3.0.html 2020-10-07 - 5.58.beta1 + 5.59.alpha1 mgmt:hidden stable - 5.58 + 5.59 This is an extension to contain the eWAY Single Currency Payment Processor diff --git a/ext/financialacls/info.xml b/ext/financialacls/info.xml index bc8f8966cb6a..fe7845aac40a 100644 --- a/ext/financialacls/info.xml +++ b/ext/financialacls/info.xml @@ -15,10 +15,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2020-08-27 - 5.58.beta1 + 5.59.alpha1 stable - 5.58 + 5.59 mgmt:hidden diff --git a/ext/flexmailer/info.xml b/ext/flexmailer/info.xml index cfcd356bb0e8..9725fbf01640 100644 --- a/ext/flexmailer/info.xml +++ b/ext/flexmailer/info.xml @@ -15,7 +15,7 @@ http://www.gnu.org/licenses/agpl-3.0.html 2020-08-05 - 5.58.beta1 + 5.59.alpha1 stable FlexMailer is an email delivery engine which replaces the internal guts @@ -23,7 +23,7 @@ to provide richer email features. - 5.58 + 5.59 mgmt:required diff --git a/ext/greenwich/info.xml b/ext/greenwich/info.xml index a39c350eaa59..48d68344a5b7 100644 --- a/ext/greenwich/info.xml +++ b/ext/greenwich/info.xml @@ -15,13 +15,13 @@ http://www.gnu.org/licenses/agpl-3.0.html 2020-07-21 - 5.58.beta1 + 5.59.alpha1 mgmt:hidden stable - 5.58 + 5.59 diff --git a/ext/legacycustomsearches/info.xml b/ext/legacycustomsearches/info.xml index 9ec4ebc43c31..ce4dea35555c 100644 --- a/ext/legacycustomsearches/info.xml +++ b/ext/legacycustomsearches/info.xml @@ -15,13 +15,13 @@ http://www.gnu.org/licenses/agpl-3.0.html 2021-07-25 - 5.58.beta1 + 5.59.alpha1 stable mgmt:hidden - 5.58 + 5.59 This is hidden on install to give extensions that require it time to add it to their requires and to allow us to get it out of GroupContact load diff --git a/ext/message_admin/info.xml b/ext/message_admin/info.xml index d6ab338d5d56..802b24e46f1a 100644 --- a/ext/message_admin/info.xml +++ b/ext/message_admin/info.xml @@ -15,10 +15,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2021-06-12 - 5.58.beta1 + 5.59.alpha1 alpha - 5.58 + 5.59 org.civicrm.afform diff --git a/ext/oauth-client/info.xml b/ext/oauth-client/info.xml index 5d7eedfd28d7..895e05286e8c 100644 --- a/ext/oauth-client/info.xml +++ b/ext/oauth-client/info.xml @@ -15,10 +15,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2020-10-23 - 5.58.beta1 + 5.59.alpha1 stable - 5.58 + 5.59 org.civicrm.afform diff --git a/ext/payflowpro/info.xml b/ext/payflowpro/info.xml index 56338046c532..843840f6ac80 100644 --- a/ext/payflowpro/info.xml +++ b/ext/payflowpro/info.xml @@ -15,10 +15,10 @@ http://www.gnu.org/licenses/agpl-3.0.html 2021-04-13 - 5.58.beta1 + 5.59.alpha1 stable - 5.58 + 5.59 This extension is extraction of the original Core Payflow Pro Payment Processor diff --git a/ext/recaptcha/info.xml b/ext/recaptcha/info.xml index f139f6dea386..4af63a219f1b 100644 --- a/ext/recaptcha/info.xml +++ b/ext/recaptcha/info.xml @@ -13,13 +13,13 @@ http://www.gnu.org/licenses/agpl-3.0.html 2021-04-03 - 5.58.beta1 + 5.59.alpha1 mgmt:hidden stable - 5.58 + 5.59 diff --git a/ext/search_kit/info.xml b/ext/search_kit/info.xml index 5c68de416421..629172fbb77b 100644 --- a/ext/search_kit/info.xml +++ b/ext/search_kit/info.xml @@ -15,13 +15,13 @@ http://www.gnu.org/licenses/agpl-3.0.html 2021-01-06 - 5.58.beta1 + 5.59.alpha1 stable mgmt:required - 5.58 + 5.59 Click on the chat link above to discuss development, report problems or ask questions. diff --git a/ext/sequentialcreditnotes/info.xml b/ext/sequentialcreditnotes/info.xml index c50d1be116c8..04864d018874 100644 --- a/ext/sequentialcreditnotes/info.xml +++ b/ext/sequentialcreditnotes/info.xml @@ -15,13 +15,13 @@ http://www.gnu.org/licenses/agpl-3.0.html 2020-01-28 - 5.58.beta1 + 5.59.alpha1 mgmt:hidden stable - 5.58 + 5.59 setting-php@1.0.0 diff --git a/sql/civicrm_generated.mysql b/sql/civicrm_generated.mysql index 0a4d145f02ef..fff2e68a727a 100644 --- a/sql/civicrm_generated.mysql +++ b/sql/civicrm_generated.mysql @@ -3056,7 +3056,7 @@ UNLOCK TABLES; LOCK TABLES `civicrm_domain` WRITE; /*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */; INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES - (1,'Default Domain Name',NULL,'5.58.beta1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}'); + (1,'Default Domain Name',NULL,'5.59.alpha1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}'); /*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/test_data_second_domain.mysql b/sql/test_data_second_domain.mysql index 11cff5ff67c6..a0e10d9d1ab7 100644 --- a/sql/test_data_second_domain.mysql +++ b/sql/test_data_second_domain.mysql @@ -902,4 +902,4 @@ INSERT INTO civicrm_navigation VALUES ( @domainID, CONCAT('civicrm/report/instance/', @instanceID,'&reset=1'), 'Mailing Detail Report', 'Mailing Detail Report', 'administer CiviMail', 'OR', @reportlastID, '1', NULL, @instanceID+2 ); UPDATE civicrm_report_instance SET navigation_id = LAST_INSERT_ID() WHERE id = @instanceID; -UPDATE civicrm_domain SET version = '5.58.beta1'; +UPDATE civicrm_domain SET version = '5.59.alpha1'; diff --git a/xml/version.xml b/xml/version.xml index 8f9ab914b6ac..7248b22b8082 100644 --- a/xml/version.xml +++ b/xml/version.xml @@ -1,4 +1,4 @@ - 5.58.beta1 + 5.59.alpha1 From 0377f5b9f7044427e7d53d6ea578b07752cf5eee Mon Sep 17 00:00:00 2001 From: Rich Lott / Artful Robot Date: Fri, 6 Jan 2023 15:21:31 +0000 Subject: [PATCH 015/106] Fix Undefined index: name Notice in civicrm_api3_message_template_send --- api/v3/MessageTemplate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v3/MessageTemplate.php b/api/v3/MessageTemplate.php index 89b285e75d38..08c281f295a6 100644 --- a/api/v3/MessageTemplate.php +++ b/api/v3/MessageTemplate.php @@ -102,7 +102,7 @@ function civicrm_api3_message_template_send($params) { // the 'wrong' BAO ones. It works, it's tested & // we can do better in apiv4 once we get a suitable // api there. - if ($spec['name'] !== 'workflow' && isset($spec['api.aliases']) && array_key_exists($field, $params)) { + if (($spec['name'] ?? '') !== 'workflow' && isset($spec['api.aliases']) && array_key_exists($field, $params)) { $params[CRM_Utils_Array::first($spec['api.aliases'])] = $params[$field]; unset($params[$field]); } From 38d78030a843f584ddce9b2c10aabe362a3c9366 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Sat, 7 Jan 2023 17:23:04 +0000 Subject: [PATCH 016/106] [REF][PHP8.2] Avoid dynamic properties in CRM_Case_Form_CaseView --- CRM/Case/Form/CaseView.php | 51 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/CRM/Case/Form/CaseView.php b/CRM/Case/Form/CaseView.php index 75b35d48c8e1..61a8473f873d 100644 --- a/CRM/Case/Form/CaseView.php +++ b/CRM/Case/Form/CaseView.php @@ -25,11 +25,59 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { */ private $_mergeCases = FALSE; + /** + * Related case view + * + * @var bool + * @internal + */ + public $_showRelatedCases = FALSE; + + /** + * Does user have capabilities to access all cases and activities + * + * @var bool + * @internal + */ + public $_hasAccessToAllCases = FALSE; + + /** + * ID of contact being viewed + * + * @var int + * @internal + */ + public $_contactID; + + /** + * ID of case being viewed + * + * @var int + * @internal + */ + public $_caseID; + + /** + * Various case details, for use in the template + * + * @var array + * @internal + */ + public $_caseDetails = []; + + /** + * The name of the type associated with the current case + * + * @var string + * @internal + */ + public $_caseType; + /** * Set variables up before form is built. */ public function preProcess() { - $this->_showRelatedCases = $_GET['relatedCases'] ?? NULL; + $this->_showRelatedCases = (bool) ($_GET['relatedCases'] ?? FALSE); $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process(); $isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients(); @@ -40,7 +88,6 @@ public function preProcess() { if ($this->_showRelatedCases) { $relatedCases = $this->get('relatedCases'); if (!isset($relatedCases)) { - $cId = CRM_Utils_Request::retrieve('cid', 'Integer'); $caseId = CRM_Utils_Request::retrieve('id', 'Integer'); $relatedCases = CRM_Case_BAO_Case::getRelatedCases($caseId); } From 113a980d3ab86aa663b178f97b84d84cbe25b4e8 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Sat, 7 Jan 2023 17:42:36 +0000 Subject: [PATCH 017/106] (REF) Remove _prefElement dynamic property --- CRM/Contact/Form/Task/AlterPreferences.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Contact/Form/Task/AlterPreferences.php b/CRM/Contact/Form/Task/AlterPreferences.php index fd3a239dd03e..0e650ad480cf 100644 --- a/CRM/Contact/Form/Task/AlterPreferences.php +++ b/CRM/Contact/Form/Task/AlterPreferences.php @@ -34,7 +34,7 @@ public function buildQuickForm() { $privacyOptions = CRM_Core_SelectValues::privacy(); foreach ($privacyOptions as $prefID => $prefName) { - $this->_prefElement = &$this->addElement('checkbox', "pref[$prefID]", NULL, $prefName); + $this->addElement('checkbox', "pref[$prefID]", NULL, $prefName); } $this->addDefaultButtons(ts('Set Privacy Options')); From 78c2e7c669641c293634cbd1fef5dd0db81dc7e0 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Sun, 8 Jan 2023 17:51:51 +0000 Subject: [PATCH 018/106] (NFC) Reference classes with correct case --- CRM/Core/BAO/CustomField.php | 2 +- CRM/Core/Form.php | 12 ++++++------ CRM/Event/BAO/Event.php | 4 ++-- CRM/Event/Import/Parser/Participant.php | 2 +- CRM/Extension/Downloader.php | 2 +- CRM/Member/Import/Parser/Membership.php | 2 +- CRM/Report/Form.php | 2 +- CRM/Utils/Date.php | 8 ++++---- CRM/Utils/Mail/Incoming.php | 10 +++++----- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 9b03aef76d04..b84d24525713 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -752,7 +752,7 @@ public static function getFieldObject($fieldID) { * True if used for search else false. * @param string $label * Label for custom field. - * @return \HTML_QuickForm_Element|null + * @return \HTML_QuickForm_element|null * @throws \CRM_Core_Exception */ public static function addQuickFormElement( diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 95834816b6d5..d6c526711fc6 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -416,7 +416,7 @@ public function registerRules() { * For datepicker elements this is consistent with the data * from CRM_Utils_Date::getDatePickerExtra * - * @return HTML_QuickForm_Element + * @return HTML_QuickForm_element * Could be an error object * * @throws \CRM_Core_Exception @@ -1598,7 +1598,7 @@ public function getDefaultContext() { * - context - @see CRM_Core_DAO::buildOptionsContext * @param bool $required * @throws CRM_Core_Exception - * @return HTML_QuickForm_Element + * @return HTML_QuickForm_element */ public function addSelect($name, $props = [], $required = FALSE) { if (!isset($props['entity'])) { @@ -1713,7 +1713,7 @@ private static function selectOrAnyPlaceholder($props, $required, $title = NULL) * @throws \CRM_Core_Exception * @throws \Exception * @return mixed - * HTML_QuickForm_Element + * HTML_QuickForm_element * void */ public function addField($name, $props = [], $required = FALSE, $legacyDate = TRUE) { @@ -2138,7 +2138,7 @@ public function addDateTime($name, $label, $required = FALSE, $attributes = NULL * @param string $defaultCurrency * @param bool $freezeCurrency * - * @return \HTML_QuickForm_Element + * @return HTML_QuickForm_element */ public function addMoney( $name, @@ -2222,7 +2222,7 @@ public function addCurrency( * - class, etc. - other html properties * @param bool $required * - * @return HTML_QuickForm_Element + * @return HTML_QuickForm_element */ public function addEntityRef($name, $label = '', $props = [], $required = FALSE) { // Default properties @@ -2538,7 +2538,7 @@ public function setPageTitle($entityLabel) { * @param string $elementName * @param array $settings * - * @return HTML_QuickForm_Element + * @return HTML_QuickForm_element */ public function addChainSelect($elementName, $settings = []) { $required = $settings['required'] ?? FALSE; diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index d49e9d15482c..ba87473d1821 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -722,13 +722,13 @@ public static function &getMapInfo(&$id) { /** * Get the complete information for one or more events. * - * @param date $start + * @param Date $start * Get events with start date >= this date. * @param int $type Get events on the a specific event type (by event_type_id). * Get events on the a specific event type (by event_type_id). * @param int $eventId Return a single event - by event id. * Return a single event - by event id. - * @param date $end + * @param Date $end * Also get events with end date >= this date. * @param bool $onlyPublic Include public events only, default TRUE. * Include public events only, default TRUE. diff --git a/CRM/Event/Import/Parser/Participant.php b/CRM/Event/Import/Parser/Participant.php index 4f4ab4c27729..86bc1f0a4bfa 100644 --- a/CRM/Event/Import/Parser/Participant.php +++ b/CRM/Event/Import/Parser/Participant.php @@ -187,7 +187,7 @@ public function import(array $values): void { if (empty($params['contact_id'])) { $error = $this->checkContactDuplicate($formatValues); - if (CRM_Core_Error::isAPIError($error, CRM_Core_ERROR::DUPLICATE_CONTACT)) { + if (CRM_Core_Error::isAPIError($error, CRM_Core_Error::DUPLICATE_CONTACT)) { $matchedIDs = (array) $error['error_message']['params']; if (count($matchedIDs) >= 1) { foreach ($matchedIDs as $contactId) { diff --git a/CRM/Extension/Downloader.php b/CRM/Extension/Downloader.php index 05e871f368e3..dbf689a807d7 100644 --- a/CRM/Extension/Downloader.php +++ b/CRM/Extension/Downloader.php @@ -73,7 +73,7 @@ public function setGuzzleClient(\GuzzleHttp\Client $guzzleClient) { /** * Determine whether downloading is supported. * - * @param \CRM_EXtension_Info $extensionInfo Optional info for (updated) extension + * @param \CRM_Extension_Info $extensionInfo Optional info for (updated) extension * * @return array * list of error messages; empty if OK diff --git a/CRM/Member/Import/Parser/Membership.php b/CRM/Member/Import/Parser/Membership.php index 3a29c4bc573a..92cb027c6da2 100644 --- a/CRM/Member/Import/Parser/Membership.php +++ b/CRM/Member/Import/Parser/Membership.php @@ -204,7 +204,7 @@ public function import($values) { if (empty($formatValues['id']) && empty($formatValues['contact_id'])) { $error = $this->checkContactDuplicate($formatValues); - if (CRM_Core_Error::isAPIError($error, CRM_Core_ERROR::DUPLICATE_CONTACT)) { + if (CRM_Core_Error::isAPIError($error, CRM_Core_Error::DUPLICATE_CONTACT)) { $matchedIDs = (array) $error['error_message']['params']; if (count($matchedIDs) > 1) { throw new CRM_Core_Exception('Multiple matching contact records detected for this row. The membership was not imported', CRM_Import_Parser::ERROR); diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 37a08a2e418d..e74c355a0c86 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -2695,7 +2695,7 @@ protected function alterCommunicationtMethod($value, &$row, $fieldname) { $communicationMethods = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); // Explode padded values. - $values = CRM_utils_array::explodePadded($value); + $values = CRM_Utils_Array::explodePadded($value); // Flip values, compute intersection with $communicationMethods, and implode with commas. $value = implode(', ', array_intersect_key($communicationMethods, array_flip($values))); return $value; diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index f97951a1ba54..409833e470a6 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -850,9 +850,9 @@ public static function getToday($dayParams = NULL, $format = "Y-m-d") { * Find whether today's date lies in * the given range * - * @param date $startDate + * @param Date $startDate * Start date for the range. - * @param date $endDate + * @param Date $endDate * End date for the range. * * @return bool @@ -915,9 +915,9 @@ public static function getFromTo($relative, $from = NULL, $to = NULL, $fromTime /** * Calculate Age in Years if greater than one year else in months. * - * @param date $birthDate + * @param Date $birthDate * Birth Date. - * @param date $targetDate + * @param Date $targetDate * Target Date. (show age on specific date) * * @return array diff --git a/CRM/Utils/Mail/Incoming.php b/CRM/Utils/Mail/Incoming.php index c53e66fe6b0a..ff539d2bd632 100644 --- a/CRM/Utils/Mail/Incoming.php +++ b/CRM/Utils/Mail/Incoming.php @@ -63,7 +63,7 @@ public static function formatMailPart($part, &$attachments) { return self::formatMailRfc822Digest($part, $attachments); } - if ($part instanceof ezcMailMultiPart) { + if ($part instanceof ezcMailMultipart) { return self::formatMailMultipart($part, $attachments); } @@ -86,19 +86,19 @@ public static function formatMailPart($part, &$attachments) { * @throws Exception */ public static function formatMailMultipart($part, &$attachments) { - if ($part instanceof ezcMailMultiPartAlternative) { + if ($part instanceof ezcMailMultipartAlternative) { return self::formatMailMultipartAlternative($part, $attachments); } - if ($part instanceof ezcMailMultiPartDigest) { + if ($part instanceof ezcMailMultipartDigest) { return self::formatMailMultipartDigest($part, $attachments); } - if ($part instanceof ezcMailMultiPartRelated) { + if ($part instanceof ezcMailMultipartRelated) { return self::formatMailMultipartRelated($part, $attachments); } - if ($part instanceof ezcMailMultiPartMixed) { + if ($part instanceof ezcMailMultipartMixed) { return self::formatMailMultipartMixed($part, $attachments); } From b04a5cdfda6f1679bc0ee2ea98c22e78e2cfdfb0 Mon Sep 17 00:00:00 2001 From: yashodha Date: Thu, 5 Jan 2023 12:41:54 +0530 Subject: [PATCH 019/106] (dev/core#3844) Dummy payment processor should be flagged as such on LIVE page --- CRM/Contribute/Form/Contribution/Main.php | 9 +++++++++ templates/CRM/Contribute/Form/Contribution/Main.tpl | 2 +- .../Contribute/Form/Contribution/PreviewHeader.tpl | 12 ++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 0056d1f72706..d09ea9c2533d 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -1406,6 +1406,15 @@ protected function skipToThankYouPage() { * Set form variables if contribution ID is found */ public function assignFormVariablesByContributionID() { + $dummyTitle = 0; + foreach ($this->_paymentProcessors as $pp) { + if ($pp['class_name'] == 'Payment_Dummy') { + $dummyTitle = $pp['name']; + break; + } + } + $this->assign('dummyTitle', $dummyTitle); + if (empty($this->_ccid)) { return; } diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index cbdf2cbc2a34..0c46bda3780c 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -46,7 +46,7 @@ {/literal} - {if $action & 1024} + {if ($action & 1024) or $dummyTitle} {include file="CRM/Contribute/Form/Contribution/PreviewHeader.tpl"} {/if} diff --git a/templates/CRM/Contribute/Form/Contribution/PreviewHeader.tpl b/templates/CRM/Contribute/Form/Contribution/PreviewHeader.tpl index fe160753f418..5570e26d88b1 100644 --- a/templates/CRM/Contribute/Form/Contribution/PreviewHeader.tpl +++ b/templates/CRM/Contribute/Form/Contribution/PreviewHeader.tpl @@ -8,8 +8,16 @@ +--------------------------------------------------------------------+ *} {* Displays Test-drive mode header for Contribution pages. *} -
    +{if $action & 1024} +
    {ts}Test-drive Your Contribution Page{/ts}

    {ts}This page is currently running in test-drive mode. Transactions will be sent to your payment processor's test server. No live financial transactions will be submitted. However, a contact record will be created or updated and a test contribution record will be saved to the database. Use obvious test contact names so you can review and delete these records as needed. Test contributions are not visible on the Contributions tab, but can be viewed by searching for 'Test Contributions' in the CiviContribute search form. Refer to your payment processor's documentation for information on values to use for test credit card number, security code, postal code, etc.{/ts}

    -
    +
    +{else} +
    + + {ts}Test payment processor on Your Contribution Page{/ts} +

    {ts 1=$dummyTitle|escape}This page is currently configured to use the %1 payment processor. No live financial transactions will be submitted if %1 payment processor is selected. However, a contact record will be created or updated and a live contribution record will be saved to the database with no actual financial transaction. Remove %1 payment processor before going live.{/ts}

    +
    +{/if} \ No newline at end of file From 86c0ec7e923396fdb70220f7dc1f51529abe7267 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Mon, 9 Jan 2023 18:36:37 +0000 Subject: [PATCH 020/106] [REF][PHP8.2] Avoid dynamic properties in CRM_Core_I18n_Form --- CRM/Core/I18n/Form.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CRM/Core/I18n/Form.php b/CRM/Core/I18n/Form.php index f17c019e0653..0dc8643f6601 100644 --- a/CRM/Core/I18n/Form.php +++ b/CRM/Core/I18n/Form.php @@ -16,6 +16,22 @@ */ class CRM_Core_I18n_Form extends CRM_Core_Form { + /** + * List of available locales + * + * @var array + * @internal + */ + public $_locales = []; + + /** + * Database structure of translatable columns + * + * @var array + * @internal + */ + public $_structure = []; + public function buildQuickForm() { $config = CRM_Core_Config::singleton(); $tsLocale = CRM_Core_I18n::getLocale(); From 3ea3989c94ded000f11e0f50c9180e081a8056fa Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Mon, 9 Jan 2023 19:38:52 +0000 Subject: [PATCH 021/106] [REF][PHP8.2] Avoid dynamic properties in queue tests --- tests/phpunit/CRM/Queue/Queue/SqlTest.php | 10 ++++++++++ tests/phpunit/CRM/Queue/QueueTest.php | 10 ++++++++++ tests/phpunit/CRM/Queue/RunnerTest.php | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/tests/phpunit/CRM/Queue/Queue/SqlTest.php b/tests/phpunit/CRM/Queue/Queue/SqlTest.php index 6de10ed62213..a2eaa05ed24c 100644 --- a/tests/phpunit/CRM/Queue/Queue/SqlTest.php +++ b/tests/phpunit/CRM/Queue/Queue/SqlTest.php @@ -20,6 +20,16 @@ class CRM_Queue_Queue_SqlTest extends CiviUnitTestCase { use \Civi\Test\QueueTestTrait; + /** + * @var CRM_Queue_Service + */ + private $queueService; + + /** + * @var CRM_Queue_Queue + */ + private $queue; + /* ----------------------- Queue providers ----------------------- */ /* Define a list of queue providers which should be tested */ diff --git a/tests/phpunit/CRM/Queue/QueueTest.php b/tests/phpunit/CRM/Queue/QueueTest.php index 426687c98bcc..1ec3c33cd580 100644 --- a/tests/phpunit/CRM/Queue/QueueTest.php +++ b/tests/phpunit/CRM/Queue/QueueTest.php @@ -18,6 +18,16 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase { use \Civi\Test\QueueTestTrait; + /** + * @var CRM_Queue_Service + */ + private $queueService; + + /** + * @var CRM_Queue_Queue + */ + private $queue; + /* ----------------------- Queue providers ----------------------- */ /* Define a list of queue providers which should be tested */ diff --git a/tests/phpunit/CRM/Queue/RunnerTest.php b/tests/phpunit/CRM/Queue/RunnerTest.php index a179fa9d51b9..20c538bae0ec 100644 --- a/tests/phpunit/CRM/Queue/RunnerTest.php +++ b/tests/phpunit/CRM/Queue/RunnerTest.php @@ -18,6 +18,16 @@ class CRM_Queue_RunnerTest extends CiviUnitTestCase { use \Civi\Test\QueueTestTrait; + /** + * @var CRM_Queue_Service + */ + private $queueService; + + /** + * @var CRM_Queue_Queue + */ + private $queue; + public function setUp(): void { parent::setUp(); $this->queueService = CRM_Queue_Service::singleton(TRUE); From 8dad76f8feee78a1a1f8ca30352a5045d97736c6 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Mon, 9 Jan 2023 19:49:15 +0000 Subject: [PATCH 022/106] [REF][PHP8.2] Avoid dynamic properties in CRM_Contact_Page_DedupeException --- CRM/Contact/Page/DedupeException.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CRM/Contact/Page/DedupeException.php b/CRM/Contact/Page/DedupeException.php index c1931202753e..091f0550d0a5 100644 --- a/CRM/Contact/Page/DedupeException.php +++ b/CRM/Contact/Page/DedupeException.php @@ -20,6 +20,12 @@ */ class CRM_Contact_Page_DedupeException extends CRM_Core_Page { + /** + * @var CRM_Utils_Pager + * @internal + */ + public $_pager; + /** * the main function that is called when the page loads, * it decides the which action has to be taken for the page. From 90444c0a5f81c296c0632fa29052e57b5bbecc03 Mon Sep 17 00:00:00 2001 From: Jo Franz Date: Tue, 10 Jan 2023 17:19:13 +0100 Subject: [PATCH 023/106] email warning if runInNonProductionEnvironment=TRUE --- CRM/Admin/Page/Job.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Admin/Page/Job.php b/CRM/Admin/Page/Job.php index a521989ae254..4808d676e245 100644 --- a/CRM/Admin/Page/Job.php +++ b/CRM/Admin/Page/Job.php @@ -143,7 +143,7 @@ public function run() { public function browse() { // check if non-prod mode is enabled. if (CRM_Core_Config::environment() != 'Production') { - CRM_Core_Session::setStatus(ts('Execution of scheduled jobs has been turned off by default since this is a non-production environment. You can override this for particular jobs by adding runInNonProductionEnvironment=TRUE as a parameter.'), ts("Non-production Environment"), "warning", array('expires' => 0)); + CRM_Core_Session::setStatus(ts('Execution of scheduled jobs has been turned off by default since this is a non-production environment. You can override this for particular jobs by adding runInNonProductionEnvironment=TRUE as a parameter. This will ignore email settings for this job and will send actual emails if this job is sending mails!'), ts("Non-production Environment"), "warning", array('expires' => 0)); } else { $cronError = Civi\Api4\System::check(FALSE) From a5220b704fb35b4cc9dfd7909b1b0cddadf3cc5e Mon Sep 17 00:00:00 2001 From: Jo Franz Date: Tue, 10 Jan 2023 18:01:35 +0100 Subject: [PATCH 024/106] typo: dlass --> class --- templates/CRM/Admin/Form/Job.tpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/CRM/Admin/Form/Job.tpl b/templates/CRM/Admin/Form/Job.tpl index a4b78dda1d5f..b6f8215a11d1 100644 --- a/templates/CRM/Admin/Form/Job.tpl +++ b/templates/CRM/Admin/Form/Job.tpl @@ -92,7 +92,8 @@ CRM.$(function($) { {$form.scheduled_run_date.label} {$form.scheduled_run_date.html}
    -
    {ts}Do not run this job before this date / time. The run frequency selected above will apply thereafter.{/ts}
    +
    {ts}Do not run this job before this date / time. The run frequency selected + above will apply thereafter.{/ts}
    {if $action eq 1}{ts}Leave blank to run as soon as possible.{/ts}{else}{ts}Leave blank to run at next run frequency.{/ts}{/if}
    From 499b43964ca555761f0d6160d5e00e88f35204ab Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Tue, 10 Jan 2023 19:07:49 +0000 Subject: [PATCH 025/106] [REF][PHP8.2] Avoid dynamic properties in api_v3_NoteTest --- tests/phpunit/api/v3/NoteTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/api/v3/NoteTest.php b/tests/phpunit/api/v3/NoteTest.php index 9f217e09027f..1de5dcd7bd5c 100644 --- a/tests/phpunit/api/v3/NoteTest.php +++ b/tests/phpunit/api/v3/NoteTest.php @@ -19,6 +19,7 @@ class api_v3_NoteTest extends CiviUnitTestCase { protected $_params; protected $_noteID; protected $_note; + protected $_createdDate; public function setUp(): void { From dd05f7732da947ec90ea6964a6e943a117a37385 Mon Sep 17 00:00:00 2001 From: Jo Franz Date: Tue, 10 Jan 2023 20:44:03 +0100 Subject: [PATCH 026/106] fixed line break --- templates/CRM/Admin/Form/Job.tpl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/templates/CRM/Admin/Form/Job.tpl b/templates/CRM/Admin/Form/Job.tpl index b6f8215a11d1..8cd1dd1d5dfc 100644 --- a/templates/CRM/Admin/Form/Job.tpl +++ b/templates/CRM/Admin/Form/Job.tpl @@ -92,8 +92,7 @@ CRM.$(function($) { {$form.scheduled_run_date.label} {$form.scheduled_run_date.html}
    -
    {ts}Do not run this job before this date / time. The run frequency selected - above will apply thereafter.{/ts}
    +
    {ts}Do not run this job before this date / time. The run frequency selected above will apply thereafter.{/ts}
    {if $action eq 1}{ts}Leave blank to run as soon as possible.{/ts}{else}{ts}Leave blank to run at next run frequency.{/ts}{/if}
    From 876fa70a7f391f387197bbc51492237f90d7018d Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Tue, 10 Jan 2023 19:44:45 +0000 Subject: [PATCH 027/106] [REF][PHP8.2] Avoid dynamic properties in CRM_Extension_Container_Static --- CRM/Extension/Container/Static.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CRM/Extension/Container/Static.php b/CRM/Extension/Container/Static.php index 3ebb70888739..07a2ddca1966 100644 --- a/CRM/Extension/Container/Static.php +++ b/CRM/Extension/Container/Static.php @@ -20,6 +20,11 @@ */ class CRM_Extension_Container_Static implements CRM_Extension_Container_Interface { + /** + * @var array + */ + protected $exts = []; + /** * @param array $exts * Array(string $key => array $spec) List of extensions. From bb2b2399ac7f0c3ab4ca69bf6c79f6d874b24e00 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 11 Jan 2023 09:18:41 +1300 Subject: [PATCH 028/106] Fix undefined property, general test cleanup --- tests/phpunit/api/v3/ProfileTest.php | 114 +++++++++------------------ 1 file changed, 38 insertions(+), 76 deletions(-) diff --git a/tests/phpunit/api/v3/ProfileTest.php b/tests/phpunit/api/v3/ProfileTest.php index 0a051c9f9f68..44dc57c1fb43 100644 --- a/tests/phpunit/api/v3/ProfileTest.php +++ b/tests/phpunit/api/v3/ProfileTest.php @@ -26,8 +26,6 @@ class api_v3_ProfileTest extends CiviUnitTestCase { /** * Set up for test. - * - * @throws \CRM_Core_Exception */ public function setUp(): void { parent::setUp(); @@ -41,8 +39,6 @@ public function setUp(): void { /** * Cleanup after test. - * - * @throws \CRM_Core_Exception */ public function tearDown(): void { $this->quickCleanUpFinancialEntities(); @@ -77,11 +73,9 @@ public function testProfileGetInvalidProfileId(): void { /** * Check with success. - * - * @throws \CRM_Core_Exception */ public function testProfileGet(): void { - $profileFieldValues = $this->_createIndividualContact(); + $profileFieldValues = $this->createIndividualContact(); $expected = reset($profileFieldValues); $contactId = key($profileFieldValues); $params = [ @@ -99,20 +93,18 @@ public function testProfileGet(): void { * * We are checking that there is no error. * - * @throws \CRM_Core_Exception */ public function testProfileGetWithAddressCustomData(): void { - $this->_createIndividualContact(); - $this->entity = 'Address'; + $this->createIndividualContact(); $this->createCustomGroupWithFieldOfType(['extends' => 'Address']); $this->callAPISuccess('UFField', 'create', [ 'uf_group_id' => $this->_profileID, - 'field_name' => $this->getCustomFieldName('text'), + 'field_name' => $this->getCustomFieldName(), 'visibility' => 'Public Pages and Listings', 'label' => 'My custom field', 'field_type' => 'Contact', ]); - $this->callAPISuccess('Address', 'get', ['contact_id' => $this->_contactID, 'api.Address.create' => [$this->getCustomFieldName('text') => 'my field']]); + $this->callAPISuccess('Address', 'get', ['contact_id' => $this->_contactID, 'api.Address.create' => [$this->getCustomFieldName() => 'my field']]); $this->callAPISuccess('Profile', 'get', ['profile_id' => $this->_profileID, 'contact_id' => $this->_contactID])['values']; } @@ -120,7 +112,7 @@ public function testProfileGetWithAddressCustomData(): void { * Test getting multiple profiles. */ public function testProfileGetMultiple(): void { - $profileFieldValues = $this->_createIndividualContact(); + $profileFieldValues = $this->createIndividualContact(); $expected = reset($profileFieldValues); $contactId = key($profileFieldValues); $params = [ @@ -150,11 +142,9 @@ public function testProfileGetMultiple(): void { /** * Test getting billing profile filled using is_billing. - * - * @throws \CRM_Core_Exception */ public function testProfileGetBillingUseIsBillingLocation(): void { - $individual = $this->_createIndividualContact(); + $individual = $this->createIndividualContact(); $contactId = key($individual); $this->callAPISuccess('address', 'create', [ 'is_billing' => 1, @@ -186,11 +176,9 @@ public function testProfileGetBillingUseIsBillingLocation(): void { /** * Test getting multiple profiles, including billing. - * - * @throws \CRM_Core_Exception */ public function testProfileGetMultipleHasBillingLocation(): void { - $individual = $this->_createIndividualContact(); + $individual = $this->createIndividualContact(); $contactId = key($individual); $this->callAPISuccess('address', 'create', [ 'contact_id' => $contactId, @@ -229,7 +217,6 @@ public function testProfileGetMultipleHasBillingLocation(): void { /** * Get Billing empty contact - this will return generic defaults. * - * @throws \CRM_Core_Exception */ public function testProfileGetBillingEmptyContact(): void { $this->callAPISuccess('Setting', 'create', ['defaultContactCountry' => 1228]); @@ -256,7 +243,7 @@ public function testProfileGetBillingEmptyContact(): void { * Check contact activity profile without activity id. */ public function testContactActivityGetWithoutActivityId(): void { - [$params] = $this->_createContactWithActivity(); + [$params] = $this->createContactWithActivity(); unset($params['activity_id']); $this->callAPIFailure('profile', 'get', $params, 'Mandatory key(s) missing from params array: activity_id'); @@ -266,7 +253,7 @@ public function testContactActivityGetWithoutActivityId(): void { * Check contact activity profile wrong activity id. */ public function testContactActivityGetWrongActivityId(): void { - [$params] = $this->_createContactWithActivity(); + [$params] = $this->createContactWithActivity(); $params['activity_id'] = 100001; $this->callAPIFailure('profile', 'get', $params, 'Invalid Activity Id (aid).'); } @@ -291,7 +278,7 @@ public function testContactActivityGetWrongActivityType(): void { $activityValues = array_pop($activity); - [$params] = $this->_createContactWithActivity(); + [$params] = $this->createContactWithActivity(); $params['activity_id'] = $activityValues['id']; $this->callAPIFailure('profile', 'get', $params, 'This activity cannot be edited or viewed via this profile.'); @@ -299,11 +286,9 @@ public function testContactActivityGetWrongActivityType(): void { /** * Check contact activity profile with success. - * - * @throws \CRM_Core_Exception */ public function testContactActivityGetSuccess(): void { - [$params, $expected] = $this->_createContactWithActivity(); + [$params, $expected] = $this->createContactWithActivity(); $result = $this->callAPISuccess('profile', 'get', $params); @@ -317,8 +302,8 @@ public function testContactActivityGetSuccess(): void { * Check getfields works & gives us our fields */ public function testGetFields(): void { - $this->_createIndividualProfile(); - $this->_addCustomFieldToProfile($this->_profileID); + $this->createIndividualProfile(); + $this->addCustomFieldToProfile($this->_profileID); $result = $this->callAPIAndDocument('profile', 'getfields', [ 'action' => 'submit', 'profile_id' => $this->_profileID, @@ -333,9 +318,7 @@ public function testGetFields(): void { } /** - * Check getfields works & gives us our fields - participant profile - * - * @throws \CRM_Core_Exception + * Check getfields works & gives us our fields - participant profile. */ public function testGetFieldsParticipantProfile(): void { $result = $this->callAPISuccess('profile', 'getfields', [ @@ -350,9 +333,7 @@ public function testGetFieldsParticipantProfile(): void { /** * Check getfields works & gives us our fields - membership_batch_entry - * (getting to the end with no e-notices is pretty good evidence it's working) - * - * @throws \CRM_Core_Exception + * (getting to the end with no e-notices is pretty good evidence it's working). */ public function testGetFieldsMembershipBatchProfile(): void { $result = $this->callAPISuccess('profile', 'getfields', [ @@ -374,8 +355,6 @@ public function testGetFieldsMembershipBatchProfile(): void { /** * Check getfields works & gives us our fields - do them all * (getting to the end with no e-notices is pretty good evidence it's working) - * - * @throws \CRM_Core_Exception */ public function testGetFieldsAllProfiles(): void { $result = $this->callAPISuccess('uf_group', 'get', ['return' => 'id'])['values']; @@ -414,11 +393,9 @@ public function testProfileSubmitInvalidProfileId(): void { /** * Check with missing required field in profile. - * - * @throws \CRM_Core_Exception */ public function testProfileSubmitCheckProfileRequired(): void { - $profileFieldValues = $this->_createIndividualContact(); + $profileFieldValues = $this->createIndividualContact(); $contactId = key($profileFieldValues); $updateParams = [ 'first_name' => 'abc2', @@ -442,11 +419,9 @@ public function testProfileSubmitCheckProfileRequired(): void { /** * Check with success. - * - * @throws \CRM_Core_Exception */ public function testProfileSubmit(): void { - $profileFieldValues = $this->_createIndividualContact(); + $profileFieldValues = $this->createIndividualContact(); $contactId = key($profileFieldValues); $updateParams = [ @@ -486,8 +461,6 @@ public function testProfileSubmit(): void { * Ensure caches are being cleared so we don't get into a debugging trap * because of cached metadata First we delete & create to increment the * version & then check for caching problems. - * - * @throws \CRM_Core_Exception */ public function testProfileSubmitCheckCaching(): void { $this->callAPISuccess('membership_type', 'delete', ['id' => $this->_membershipTypeID]); @@ -511,8 +484,6 @@ public function testProfileSubmitCheckCaching(): void { /** * Test that the fields are returned in the right order despite the faffing * around that goes on. - * - * @throws \CRM_Core_Exception */ public function testMembershipGetFieldsOrder(): void { $result = $this->callAPISuccess('profile', 'getfields', [ @@ -530,9 +501,7 @@ public function testMembershipGetFieldsOrder(): void { } /** - * Check we can submit membership batch profiles (create mode) - * - * @throws \CRM_Core_Exception + * Check we can submit membership batch profiles (create mode). */ public function testProfileSubmitMembershipBatch(): void { // @todo - figure out why this doesn't pass validate financials @@ -552,11 +521,9 @@ public function testProfileSubmitMembershipBatch(): void { /** * Set is deprecated but we need to ensure it still works. - * - * @throws \CRM_Core_Exception */ public function testLegacySet(): void { - $profileFieldValues = $this->_createIndividualContact(); + $profileFieldValues = $this->createIndividualContact(); $contactId = key($profileFieldValues); $updateParams = [ @@ -591,7 +558,7 @@ public function testLegacySet(): void { * Check contact activity profile without activity id. */ public function testContactActivitySubmitWithoutActivityId(): void { - [$params, $expected] = $this->_createContactWithActivity(); + [$params, $expected] = $this->createContactWithActivity(); $params = array_merge($params, $expected); unset($params['activity_id']); @@ -602,7 +569,7 @@ public function testContactActivitySubmitWithoutActivityId(): void { * Check contact activity profile wrong activity id. */ public function testContactActivitySubmitWrongActivityId(): void { - [$params, $expected] = $this->_createContactWithActivity(); + [$params, $expected] = $this->createContactWithActivity(); $params = array_merge($params, $expected); $params['activity_id'] = 100001; $this->callAPIFailure('profile', 'submit', $params, 'Invalid Activity Id (aid).'); @@ -633,7 +600,7 @@ public function testContactActivitySubmitWrongActivityType(): void { $activityValues = array_pop($activity['values']); - [$params, $expected] = $this->_createContactWithActivity(); + [$params, $expected] = $this->createContactWithActivity(); $params = array_merge($params, $expected); $params['activity_id'] = $activityValues['id']; @@ -643,11 +610,9 @@ public function testContactActivitySubmitWrongActivityType(): void { /** * Check contact activity profile with success. - * - * @throws \CRM_Core_Exception */ public function testContactActivitySubmitSuccess(): void { - [$params] = $this->_createContactWithActivity(); + [$params] = $this->createContactWithActivity(); $updateParams = [ 'first_name' => 'abc2', @@ -695,7 +660,7 @@ public function testProfileApplyInvalidProfileId(): void { * Check with success. */ public function testProfileApply(): void { - $profileFieldValues = $this->_createIndividualContact(); + $profileFieldValues = $this->createIndividualContact(); $contactId = key($profileFieldValues); $params = [ @@ -753,11 +718,9 @@ public function testProfileApply(): void { /** * Check success with tags. - * - * @throws \CRM_Core_Exception */ public function testSubmitWithTags(): void { - $profileFieldValues = $this->_createIndividualContact(); + $profileFieldValues = $this->createIndividualContact(); $params = reset($profileFieldValues); $contactId = key($profileFieldValues); $params['profile_id'] = $this->_profileID; @@ -800,7 +763,7 @@ public function testSubmitWithTags(): void { * @throws \Exception */ public function testSubmitWithNote(): void { - $profileFieldValues = $this->_createIndividualContact(); + $profileFieldValues = $this->createIndividualContact(); $params = reset($profileFieldValues); $contactId = key($profileFieldValues); $params['profile_id'] = $this->_profileID; @@ -826,8 +789,8 @@ public function testSubmitWithNote(): void { * * @throws \CRM_Core_Exception */ - public function testSubmitGreetingFields() { - $profileFieldValues = $this->_createIndividualContact(); + public function testSubmitGreetingFields(): void { + $profileFieldValues = $this->createIndividualContact(); $params = reset($profileFieldValues); $contactId = key($profileFieldValues); $params['profile_id'] = $this->_profileID; @@ -841,7 +804,7 @@ public function testSubmitGreetingFields() { 'label' => 'Email Greeting', ]); - $emailGreetings = array_column(civicrm_api3('OptionValue', 'get', ['option_group_id' => "email_greeting"])['values'], NULL, 'name'); + $emailGreetings = array_column(civicrm_api3('OptionValue', 'get', ['option_group_id' => 'email_greeting'])['values'], NULL, 'name'); $params['email_greeting'] = $emailGreetings['Customized']['value']; // Custom greeting should be required @@ -853,7 +816,7 @@ public function testSubmitGreetingFields() { // Api3 will not return custom greeting field so resorting to this $greeting = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactId, 'email_greeting_custom'); - $this->assertEquals("Hello fool!", $greeting); + $this->assertEquals('Hello fool!', $greeting); } /** @@ -862,10 +825,9 @@ public function testSubmitGreetingFields() { * * @param array $params * - * @return mixed - * @throws \CRM_Core_Exception + * @return array */ - public function _createIndividualContact($params = []) { + public function createIndividualContact(array $params = []): array { $contactParams = array_merge([ 'first_name' => 'abc1', 'last_name' => 'xyz1', @@ -893,7 +855,7 @@ public function _createIndividualContact($params = []) { ], $params); $this->_contactID = $this->individualCreate($contactParams); - $this->_createIndividualProfile(); + $this->createIndividualProfile(); // expected result of above created profile with contact Id $contactId $profileData[$this->_contactID] = [ 'first_name' => 'abc1', @@ -910,7 +872,7 @@ public function _createIndividualContact($params = []) { /** * @return array */ - public function _createContactWithActivity() { + public function createContactWithActivity(): array { $ufGroupID = $this->callAPISuccess('UFGroup', 'create', [ 'group_type' => 'Individual,Contact,Activity', 'title' => 'Test Contact-Activity Profile', @@ -987,7 +949,7 @@ public function _createContactWithActivity() { ]); // hack: xml data set did not accept  (CRM_Core_DAO::VALUE_SEPARATOR) - should be possible - // to unhack now we use the api. + // to un-hack now we use the api. CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', $ufGroupID, 'group_type', 'Individual,Contact,Activity' . CRM_Core_DAO::VALUE_SEPARATOR . 'ActivityType:1'); $sourceContactId = $this->individualCreate(); @@ -1014,7 +976,7 @@ public function _createContactWithActivity() { $keys = array_keys($contact['values']); $contactId = array_pop($keys); - $this->assertEquals(0, $contact['values'][$contactId]['api.address.create']['is_error'], " error message: " . CRM_Utils_Array::value('error_message', $contact['values'][$contactId]['api.address.create']) + $this->assertEquals(0, $contact['values'][$contactId]['api.address.create']['is_error'], ' error message: ' . CRM_Utils_Array::value('error_message', $contact['values'][$contactId]['api.address.create']) ); $activityParams = [ @@ -1058,7 +1020,7 @@ public function _createContactWithActivity() { /** * Create a profile. */ - public function _createIndividualProfile() { + public function createIndividualProfile(): void { $ufGroupParams = [ 'group_type' => 'Individual,Contact', // really we should remove this & test the ufField create sets it @@ -1127,7 +1089,7 @@ public function _createIndividualProfile() { /** * @param int $profileID */ - public function _addCustomFieldToProfile($profileID) { + public function addCustomFieldToProfile(int $profileID): void { $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, ''); $this->uFFieldCreate([ 'uf_group_id' => $profileID, From 084c034236352224e8b2ab05006f1e3e0e2a304e Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 11 Jan 2023 10:47:18 +1300 Subject: [PATCH 029/106] Php 8.2 fix undefined property, move test to appropriate extension --- Civi/Test/ContactTestTrait.php | 7 ++ .../Contact/Form/Search/Custom/FullText.php | 69 ++++++++-------- .../phpunit/Civi/Searches/FullTextTest.php | 80 +++++++++++++++++++ .../Form/Search/Custom/FullTextTest.php | 63 --------------- 4 files changed, 124 insertions(+), 95 deletions(-) create mode 100644 ext/legacycustomsearches/tests/phpunit/Civi/Searches/FullTextTest.php delete mode 100644 tests/phpunit/CRM/Contact/Form/Search/Custom/FullTextTest.php diff --git a/Civi/Test/ContactTestTrait.php b/Civi/Test/ContactTestTrait.php index 80b3a5b48b0a..0242c8380122 100644 --- a/Civi/Test/ContactTestTrait.php +++ b/Civi/Test/ContactTestTrait.php @@ -15,6 +15,13 @@ */ trait ContactTestTrait { + /** + * API version to use for any api calls. + * + * @var int + */ + public $apiversion = 4; + /** * Emulate a logged in user since certain functions use that. * value to store a record in the DB (like activity) diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php index f3a9fd78daa5..286819413797 100644 --- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php +++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php @@ -29,9 +29,16 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu protected $_text = NULL; - protected $_table = NULL; + protected $_table; - protected $_tableName = NULL; + protected $tableName; + + /** + * @return mixed + */ + public function getTableName() { + return $this->tableName; + } protected $_entityIDTableName = NULL; @@ -53,7 +60,7 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu * * @var array|null */ - protected $_limitRowClause = NULL; + protected $_limitRowClause; /** * Limit detail clause. @@ -119,13 +126,15 @@ public function __construct(&$formValues) { /** * Get a value from $formValues. If missing, get it from the request. * - * @param $formValues - * @param $field + * @param array $formValues + * @param string $field * @param $type * @param null $default + * * @return mixed|null + * @throws \CRM_Core_Exception */ - public function getFieldValue($formValues, $field, $type, $default = NULL) { + public function getFieldValue(array $formValues, string $field, $type, $default = NULL) { $value = $formValues[$field] ?? NULL; if (!$value) { return CRM_Utils_Request::retrieve($field, $type, CRM_Core_DAO::$_nullObject, FALSE, $default); @@ -148,9 +157,9 @@ public function initialize() { } } - public function buildTempTable() { + public function buildTempTable(): void { $table = CRM_Utils_SQL_TempTable::build()->setCategory('custom')->setMemory(); - $this->_tableName = $table->getName(); + $this->tableName = $table->getName(); $this->_tableFields = [ 'id' => 'int unsigned NOT NULL AUTO_INCREMENT', @@ -209,33 +218,29 @@ public function buildTempTable() { $sql .= "$name $desc,\n"; } - $sql .= " + $sql .= ' PRIMARY KEY ( id ) -"; +'; $table->createWithColumns($sql); $entityIdTable = CRM_Utils_SQL_TempTable::build()->setCategory('custom')->setMemory(); $this->_entityIDTableName = $entityIdTable->getName(); - $sql = " + $sql = ' id int unsigned NOT NULL AUTO_INCREMENT, entity_id int unsigned NOT NULL, UNIQUE INDEX unique_entity_id ( entity_id ), PRIMARY KEY ( id ) -"; +'; $entityIdTable->createWithColumns($sql); - - if (!empty($this->_formValues['is_unit_test'])) { - $this->_tableNameForTest = $this->_tableName; - } } - public function fillTable() { + public function fillTable(): void { /** @var CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery $partialQuery */ foreach ($this->_partialQueries as $partialQuery) { if (!$this->_table || $this->_table == $partialQuery->getName()) { if ($partialQuery->isActive()) { - $result = $partialQuery->fillTempTable($this->_text, $this->_entityIDTableName, $this->_tableName, $this->_limitClause, $this->_limitDetailClause); + $result = $partialQuery->fillTempTable($this->_text, $this->_entityIDTableName, $this->tableName, $this->_limitClause, $this->_limitDetailClause); $this->_foundRows[$partialQuery->getName()] = $result['count']; } } @@ -244,9 +249,9 @@ public function fillTable() { $this->filterACLContacts(); } - public function filterACLContacts() { + public function filterACLContacts(): void { if (CRM_Core_Permission::check('view all contacts')) { - CRM_Core_DAO::executeQuery("DELETE FROM {$this->_tableName} WHERE contact_id IN (SELECT id FROM civicrm_contact WHERE is_deleted = 1)"); + CRM_Core_DAO::executeQuery("DELETE FROM {$this->tableName} WHERE contact_id IN (SELECT id FROM civicrm_contact WHERE is_deleted = 1)"); return; } @@ -262,7 +267,7 @@ public function filterACLContacts() { $sql = " DELETE t.* -FROM {$this->_tableName} t +FROM {$this->tableName} t WHERE NOT EXISTS ( SELECT c.contact_id FROM civicrm_acl_contact_cache c WHERE c.user_id = %1 AND t.contact_id = c.contact_id ) @@ -271,7 +276,7 @@ public function filterACLContacts() { $sql = " DELETE t.* -FROM {$this->_tableName} t +FROM {$this->tableName} t WHERE t.table_name = 'Activity' AND NOT EXISTS ( SELECT c.contact_id FROM civicrm_acl_contact_cache c @@ -281,7 +286,7 @@ public function filterACLContacts() { $sql = " DELETE t.* -FROM {$this->_tableName} t +FROM {$this->tableName} t WHERE t.table_name = 'Activity' AND NOT EXISTS ( SELECT c.contact_id FROM civicrm_acl_contact_cache c @@ -366,7 +371,7 @@ public function summary() { } // now iterate through the table and add entries to the relevant section - $sql = "SELECT * FROM {$this->_tableName}"; + $sql = "SELECT * FROM {$this->tableName}"; if ($this->_table) { $sql .= " {$this->toLimit($this->_limitRowClause)} "; } @@ -377,7 +382,7 @@ public function summary() { while ($dao->fetch()) { $row = []; foreach ($this->_tableFields as $name => $dontCare) { - if ($name != 'activity_type_id') { + if ($name !== 'activity_type_id') { $row[$name] = $dao->$name; } else { @@ -430,7 +435,7 @@ public function count() { return $this->_foundRows[$this->_table]; } else { - return CRM_Core_DAO::singleValueQuery("SELECT count(id) FROM {$this->_tableName}"); + return CRM_Core_DAO::singleValueQuery("SELECT count(id) FROM {$this->tableName}"); } } @@ -449,7 +454,7 @@ public function contactIDs($offset = 0, $rowcount = 0, $sort = NULL, $returnSQL return $this->all($offset, $rowcount, $sort, FALSE, TRUE); } else { - return CRM_Core_DAO::singleValueQuery("SELECT contact_id FROM {$this->_tableName}"); + return CRM_Core_DAO::singleValueQuery("SELECT contact_id FROM {$this->tableName}"); } } @@ -477,7 +482,7 @@ public function all($offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs $sql = " SELECT $select -FROM {$this->_tableName} contact_a +FROM {$this->tableName} contact_a {$this->toLimit($this->_limitRowClause)} "; return $sql; @@ -509,7 +514,7 @@ public function templateFile() { /** * @return array */ - public function setDefaultValues() { + public function setDefaultValues(): array { return []; } @@ -525,16 +530,16 @@ public function alterRow(&$row) { * SQL * @see CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery::toLimit */ - public function toLimit($limit) { + public function toLimit($limit): string { if (is_array($limit)) { - list ($limit, $offset) = $limit; + [$limit, $offset] = $limit; } if (empty($limit)) { return ''; } $result = "LIMIT {$limit}"; if ($offset) { - $result .= " OFFSET {$offset}"; + $result .= " OFFSET $offset"; } return $result; } diff --git a/ext/legacycustomsearches/tests/phpunit/Civi/Searches/FullTextTest.php b/ext/legacycustomsearches/tests/phpunit/Civi/Searches/FullTextTest.php new file mode 100644 index 000000000000..bf2e9cd78968 --- /dev/null +++ b/ext/legacycustomsearches/tests/phpunit/Civi/Searches/FullTextTest.php @@ -0,0 +1,80 @@ +install(['legacycustomsearches']) + ->apply(); + } + + /** + * Test ACL contacts are filtered properly. + */ + public function testFilterACLContacts(): void { + $userId = $this->createLoggedInUser(); + // remove all permissions + CRM_Core_Config::singleton()->userPermissionClass->permissions = []; + + for ($i = 1; $i <= 10; $i++) { + $contactId = $this->individualCreate([], $i); + if ($i <= 5) { + $queryParams = [ + 1 => [$userId, 'Integer'], + 2 => [$contactId, 'Integer'], + ]; + CRM_Core_DAO::executeQuery("INSERT INTO civicrm_acl_contact_cache ( user_id, contact_id, operation ) VALUES(%1, %2, 'View')", $queryParams); + } + $contactIDs[$i] = $contactId; + } + + $formValues = ['component_mode' => 1, 'operator' => 1, 'is_unit_test' => 1]; + $fullText = new CRM_Contact_Form_Search_Custom_FullText($formValues); + $fullText->initialize(); + + //Assert that ACL contacts are filtered. + $queryParams = [1 => [$userId, 'Integer']]; + $whereClause = 'WHERE NOT EXISTS (SELECT c.contact_id + FROM civicrm_acl_contact_cache c + WHERE c.user_id = %1 AND t.contact_id = c.contact_id )'; + + $count = CRM_Core_DAO::singleValueQuery('SELECT COUNT(*) FROM ' . $fullText->getTableName() . " t $whereClause", $queryParams); + $this->assertEmpty($count, 'ACL contacts are not removed.'); + } + +} diff --git a/tests/phpunit/CRM/Contact/Form/Search/Custom/FullTextTest.php b/tests/phpunit/CRM/Contact/Form/Search/Custom/FullTextTest.php deleted file mode 100644 index db7048ea3208..000000000000 --- a/tests/phpunit/CRM/Contact/Form/Search/Custom/FullTextTest.php +++ /dev/null @@ -1,63 +0,0 @@ -quickCleanup($this->_tablesToTruncate); - - $userId = $this->createLoggedInUser(); - // remove all permissions - $config = CRM_Core_Config::singleton(); - $config->userPermissionClass->permissions = []; - - for ($i = 1; $i <= 10; $i++) { - $contactId = $this->individualCreate([], $i); - if ($i <= 5) { - $queryParams = [ - 1 => [$userId, 'Integer'], - 2 => [$contactId, 'Integer'], - ]; - CRM_Core_DAO::executeQuery("INSERT INTO civicrm_acl_contact_cache ( user_id, contact_id, operation ) VALUES(%1, %2, 'View')", $queryParams); - } - $contactIDs[$i] = $contactId; - } - - $formValues = ['component_mode' => 1, 'operator' => 1, 'is_unit_test' => 1]; - $fullText = new CRM_Contact_Form_Search_Custom_FullText($formValues); - $fullText->initialize(); - - //Assert that ACL contacts are filtered. - $queryParams = [1 => [$userId, 'Integer']]; - $whereClause = "WHERE NOT EXISTS (SELECT c.contact_id - FROM civicrm_acl_contact_cache c - WHERE c.user_id = %1 AND t.contact_id = c.contact_id )"; - - $count = CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) FROM {$fullText->_tableNameForTest} t {$whereClause}", $queryParams); - $this->assertEmpty($count, 'ACL contacts are not removed.'); - } - -} From 5876791cbf7caa60e413a349e02bf2ebe3b8c8e9 Mon Sep 17 00:00:00 2001 From: Jo Franz Date: Tue, 10 Jan 2023 23:13:36 +0100 Subject: [PATCH 030/106] added myself to contributor-key.yml --- contributor-key.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contributor-key.yml b/contributor-key.yml index 366e1e5425d0..541fbaa6ebb6 100644 --- a/contributor-key.yml +++ b/contributor-key.yml @@ -1637,3 +1637,7 @@ - github : gellweiler name : Sebastian Gellweiler organization: craft-coders.de + +- github : jofranz + name : Johannes Franz + organization: SYSTOPIA From 8a7480f5f6b216f88343c20e6e760bbedc7a086c Mon Sep 17 00:00:00 2001 From: Herb v/d Dool Date: Tue, 10 Jan 2023 17:17:17 -0500 Subject: [PATCH 031/106] Core#2301 Add Drupal 8+ specific check and extract to CRM_Utils_System_Base --- CRM/Core/BAO/UFGroup.php | 10 +++++----- CRM/Utils/System/Base.php | 9 +++++++++ CRM/Utils/System/Drupal8.php | 14 ++++++++++++++ CRM/Utils/System/DrupalBase.php | 12 ++++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 0c9d57caa2f1..5cbb50cc7e53 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -916,11 +916,11 @@ public static function getEditHTML( $template = CRM_Core_Smarty::singleton(); - // Hide CRM error messages if they are displayed using drupal form_set_error. - if (!empty($_POST) && CRM_Core_Config::singleton()->userFramework == 'Drupal') { - if (arg(0) == 'user' || (arg(0) == 'admin' && arg(1) == 'people')) { - $template->assign('suppressForm', TRUE); - } + // Hide CRM error messages if they are set based on CMS + // criteria. + if (!empty($_POST)) { + $supressForm = CRM_Core_Config::singleton()->userSystem->suppressProfileFormErrors(); + $template->assign('suppressForm', $supressForm); } $templateFile = "CRM/Profile/Form/{$profileID}/Dynamic.tpl"; diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 9426bf28adee..553cb333bd20 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -1114,4 +1114,13 @@ public function checkCleanurls() { return []; } + /** + * Suppress profile form errors + * + * @return bool + */ + public function suppressProfileFormErrors() { + return FALSE; + } + } diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index c26f2b63b01d..445b4ebbb491 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -901,4 +901,18 @@ public function getVersion() { return 'Unknown'; } + /** + * @inheritdoc + */ + public function suppressProfileFormErrors() { + // Suppress the errors if they are displayed using + // drupal form_set_error. + $current_path = \Drupal::service('path.current')->getPath(); + $path_args = explode('/', $current_path); + if ($path_args[1] == 'user' || ($path_args[1] == 'admin' && $path_args[2] == 'people')) { + return TRUE; + } + return FALSE; + } + } diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index f5b916bf09fc..c0e567a4b2b4 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -721,4 +721,16 @@ public function getUfGroupTypes() { ]; } + /** + * @inheritdoc + */ + public function suppressProfileFormErrors() { + // Suppress the errors if they are displayed using + // drupal form_set_error. + if (arg(0) == 'user' || (arg(0) == 'admin' && arg(1) == 'people')) { + return TRUE; + } + return FALSE; + } + } From 7c6b2c8cd37aa0530c045a8c826338acd17ea911 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 10 Jan 2023 14:14:38 -0800 Subject: [PATCH 032/106] Disable extern/soap.php. Remove implementation and tests. --- CRM/Utils/SoapServer.php | 319 +------------------------- extern/soap.php | 31 +-- tests/phpunit/E2E/Extern/SoapTest.php | 98 -------- 3 files changed, 17 insertions(+), 431 deletions(-) delete mode 100644 tests/phpunit/E2E/Extern/SoapTest.php diff --git a/CRM/Utils/SoapServer.php b/CRM/Utils/SoapServer.php index 46c24b98b65f..4e1361057918 100644 --- a/CRM/Utils/SoapServer.php +++ b/CRM/Utils/SoapServer.php @@ -10,322 +10,21 @@ */ /** - * This class handles all SOAP client requests. + * (OBSOLETE) This class previously handled SOAP requests. * + * The class is still referenced in some other repos. A stub is preserved to avoid hard-crashes + * when scanning the codebase. + * + * @deprecated * @package CRM * @copyright CiviCRM LLC https://civicrm.org/licensing */ class CRM_Utils_SoapServer { - /** - * Number of seconds we should let a soap process idle - * @var int - */ - public static $soap_timeout = 0; - - /** - * Cache the actual UF Class - * @var string - */ - public $ufClass; - - /** - * Class constructor. This caches the real user framework class locally, - * so we can use it for authentication and validation. - * - * @internal param string $uf The userframework class - */ - public function __construct() { - // any external program which call SoapServer is responsible for - // creating and attaching the session - $args = func_get_args(); - $this->ufClass = array_shift($args); - } - - /** - * Simple ping function to test for liveness. - * - * @param string $var - * The string to be echoed. - * - * @return string - */ - public function ping($var) { - $session = CRM_Core_Session::singleton(); - $key = $session->get('key'); - $session->set('key', $var); - return "PONG: $var ($key)"; - } - - /** - * Verify a SOAP key. - * - * @param string $key - * The soap key generated by authenticate(). - * - * @throws SoapFault - */ - public function verify($key) { - $session = CRM_Core_Session::singleton(); - - $soap_key = $session->get('soap_key'); - $t = time(); - - if ($key !== sha1($soap_key)) { - throw new SoapFault('Client', 'Invalid key'); - } - - if (self::$soap_timeout && - $t > ($session->get('soap_time') + self::$soap_timeout) - ) { - throw new SoapFault('Client', 'Expired key'); - } - - // otherwise, we're ok. update the timestamp - - $session->set('soap_time', $t); - } - - /** - * Authentication wrapper to the UF Class. - * - * @param string $name - * Login name. - * @param string $pass - * Password. - * - * @param bool $loadCMSBootstrap - * - * @throws SoapFault - * @return string - * The SOAP Client key - */ - public function authenticate($name, $pass, $loadCMSBootstrap = FALSE) { - require_once str_replace('_', DIRECTORY_SEPARATOR, $this->ufClass) . '.php'; - - if ($this->ufClass == 'CRM_Utils_System_Joomla' - || $this->ufClass == 'CRM_Utils_System_WordPress') { - $loadCMSBootstrap = TRUE; - } - - $result = CRM_Utils_System::authenticate($name, $pass, $loadCMSBootstrap); - - if (empty($result)) { - throw new SoapFault('Client', 'Invalid login'); - } - - $session = CRM_Core_Session::singleton(); - $session->set('soap_key', $result[2]); - $session->set('soap_time', time()); - - return sha1($result[2]); - } - - /** - * MAILER API. - * - * @param string $key - * @param int $job - * @param int $queue - * @param string $hash - * @param string $body - * - * @return array|int - * @throws \SoapFault - */ - public function mailer_event_bounce($key, $job, $queue, $hash, $body) { - $this->verify($key); - $params = [ - 'job_id' => $job, - 'time_stamp' => date('YmdHis'), - 'event_queue_id' => $queue, - 'hash' => $hash, - 'body' => $body, - 'version' => 3, - ]; - $result = civicrm_api('Mailing', 'event_bounce', $params); - return CRM_Utils_Array::encode_items($result); - } - - /** - * Mailer event unsubscribe. - * - * @param string $key - * @param int $job - * @param int $queue - * @param string $hash - * - * @return array|int - * @throws SoapFault - */ - public function mailer_event_unsubscribe($key, $job, $queue, $hash) { - $this->verify($key); - $params = [ - 'job_id' => $job, - 'time_stamp' => date('YmdHis'), - 'org_unsubscribe' => 0, - 'event_queue_id' => $queue, - 'hash' => $hash, - 'version' => 3, - ]; - $result = civicrm_api('MailingGroup', 'event_unsubscribe', $params); - return CRM_Utils_Array::encode_items($result); - } - - /** - * @param $key - * @param $job - * @param $queue - * @param $hash - * - * @return array|int - * @throws SoapFault - */ - public function mailer_event_domain_unsubscribe($key, $job, $queue, $hash) { - $this->verify($key); - $params = [ - 'job_id' => $job, - 'time_stamp' => date('YmdHis'), - 'org_unsubscribe' => 1, - 'event_queue_id' => $queue, - 'hash' => $hash, - 'version' => 3, - ]; - $result = civicrm_api('MailingGroup', 'event_domain_unsubscribe', $params); - return CRM_Utils_Array::encode_items($result); - } - - /** - * @param $key - * @param $job - * @param $queue - * @param $hash - * - * @return array|int - * @throws SoapFault - */ - public function mailer_event_resubscribe($key, $job, $queue, $hash) { - $this->verify($key); - $params = [ - 'job_id' => $job, - 'time_stamp' => date('YmdHis'), - 'org_unsubscribe' => 0, - 'event_queue_id' => $queue, - 'hash' => $hash, - 'version' => 3, - ]; - $result = civicrm_api('MailingGroup', 'event_resubscribe', $params); - return CRM_Utils_Array::encode_items($result); - } - - /** - * @param $key - * @param $email - * @param $domain - * @param $group - * - * @return array|int - * @throws SoapFault - */ - public function mailer_event_subscribe($key, $email, $domain, $group) { - $this->verify($key); - $params = [ - 'email' => $email, - 'group_id' => $group, - 'version' => 3, - ]; - $result = civicrm_api('MailingGroup', 'event_subscribe', $params); - return CRM_Utils_Array::encode_items($result); - } - - /** - * @param $key - * @param $contact - * @param $subscribe - * @param $hash - * - * @return array|int - * @throws SoapFault - */ - public function mailer_event_confirm($key, $contact, $subscribe, $hash) { - $this->verify($key); - $params = [ - 'contact_id' => $contact, - 'subscribe_id' => $subscribe, - 'time_stamp' => date('YmdHis'), - 'event_subscribe_id' => $subscribe, - 'hash' => $hash, - 'version' => 3, - ]; - $result = civicrm_api('Mailing', 'event_confirm', $params); - return CRM_Utils_Array::encode_items($result); - } - - /** - * @param $key - * @param $job - * @param $queue - * @param $hash - * @param $bodyTxt - * @param $rt - * @param null $bodyHTML - * @param null $fullEmail - * - * @return array|int - * @throws SoapFault - */ - public function mailer_event_reply($key, $job, $queue, $hash, $bodyTxt, $rt, $bodyHTML = NULL, $fullEmail = NULL) { - $this->verify($key); - $params = [ - 'job_id' => $job, - 'event_queue_id' => $queue, - 'hash' => $hash, - 'bodyTxt' => $bodyTxt, - 'replyTo' => $rt, - 'bodyHTML' => $bodyHTML, - 'fullEmail' => $fullEmail, - 'time_stamp' => date('YmdHis'), - 'version' => 3, - ]; - $result = civicrm_api('Mailing', 'event_reply', $params); - return CRM_Utils_Array::encode_items($result); - } - - /** - * @param $key - * @param $job - * @param $queue - * @param $hash - * @param $email - * - * @return array|int - * @throws SoapFault - */ - public function mailer_event_forward($key, $job, $queue, $hash, $email) { - $this->verify($key); - $params = [ - 'job_id' => $job, - 'event_queue_id' => $queue, - 'hash' => $hash, - 'email' => $email, - 'version' => 3, - ]; - $result = civicrm_api('Mailing', 'event_forward', $params); - return CRM_Utils_Array::encode_items($result); - } - - /** - * @param $key - * @param array $params - * - * @return array|int - * @throws SoapFault - */ - public function get_contact($key, $params) { - $this->verify($key); - $params['version'] = 3; - $result = civicrm_api('contact', 'get', $params); - return CRM_Utils_Array::encode_items($result); + public function __call($name, $arguments) { + throw new \SoapFault('obsolete', 'SOAP support is no longer included with civicrm-core.'); + // It's removed because (a) the main consumer is no longer live, (b) it's awkward to maintain 'extern/' scripts, + // and (c) there's an extensionized version at https://lab.civicrm.org/extensions/civismtp/ } } diff --git a/extern/soap.php b/extern/soap.php index fcd2318d66ce..3da3f2ce58dd 100644 --- a/extern/soap.php +++ b/extern/soap.php @@ -14,26 +14,11 @@ } session_start(); -require_once '../civicrm.config.php'; -require_once 'CRM/Core/Config.php'; - -$server = new SoapServer(NULL, - array( - 'uri' => 'urn:civicrm', - 'soap_version' => SOAP_1_2, - ) -); - - -require_once 'CRM/Utils/SoapServer.php'; -$crm_soap = new CRM_Utils_SoapServer(); - -/* Cache the real UF, override it with the SOAP environment */ - -$civicrmConfig = CRM_Core_Config::singleton(); - -$server->setClass('CRM_Utils_SoapServer', $civicrmConfig->userFrameworkClass); - -$server->setPersistence(SOAP_PERSISTENCE_SESSION); - -$server->handle(); +$server = new SoapServer(NULL, [ + 'uri' => 'urn:civicrm', + 'soap_version' => SOAP_1_2, +]); + +$server->fault('obsolete', "SOAP support is no longer included with civicrm-core."); +// It's removed because (a) the main consumer is no longer live, (b) it's awkward to maintain 'extern/' scripts, +// and (c) there's an extensionized version at https://lab.civicrm.org/extensions/civismtp/ diff --git a/tests/phpunit/E2E/Extern/SoapTest.php b/tests/phpunit/E2E/Extern/SoapTest.php deleted file mode 100644 index 1a8af4079b87..000000000000 --- a/tests/phpunit/E2E/Extern/SoapTest.php +++ /dev/null @@ -1,98 +0,0 @@ -markTestSkipped('Unsupported environment'); - } - - global $_CV; - $this->adminUser = $_CV['ADMIN_USER']; - $this->adminPass = $_CV['ADMIN_PASS']; - $this->url = CRM_Core_Resources::singleton()->getUrl('civicrm', 'extern/soap.php'); - - foreach (array('adminUser', 'adminPass', 'url') as $prop) { - if (empty($this->{$prop})) { - $this->markTestSkipped("Failed to lookup SOAP URL, user, or password. Have you configured `cv` for testing?"); - } - } - } - - /** - * Send a request with bad credentials. - */ - public function testAuthenticationBadPassword() { - $this->expectException(SoapFault::class); - $client = $this->createClient(); - $client->authenticate($this->adminUser, mt_rand()); - } - - /** - * Send a request with bad credentials. - */ - public function testAuthenticationBadKey() { - $this->expectException(SoapFault::class); - $client = $this->createClient(); - $key = $client->authenticate($this->adminUser, $this->adminPass); - $client->get_contact(mt_rand(), []); - } - - /** - * A basic test for one SOAP function. - */ - public function testGetContact() { - $client = $this->createClient(); - $key = $client->authenticate($this->adminUser, $this->adminPass); - $contacts = $client->get_contact($key, array( - 'contact_id' => 101, - 'return.display_name' => 1, - )); - $this->assertEquals($contacts['is_error'], 0); - $this->assertEquals($contacts['count'], 1); - $this->assertEquals($contacts['values'][101]['contact_id'], 101); - } - - /** - * @return \SoapClient - */ - protected function createClient() { - return new SoapClient(NULL, array( - 'location' => $this->url, - 'uri' => 'urn:civicrm', - 'trace' => 1, - )); - } - -} From 7d7633ab478db851b219d79ddcedefddb5f4f6aa Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 11 Jan 2023 12:08:40 +1300 Subject: [PATCH 033/106] Pass metadata values rather than convoluted array to processCustomFields --- CRM/Dedupe/Merger.php | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index e28f7c5bdcfa..e0f7be460082 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -2112,8 +2112,15 @@ public static function moveAllBelongings($mainId, $otherId, $migrationInfo, $che $submitted = []; } foreach ($submitted as $key => $value) { - if (substr($key, 0, 7) === 'custom_') { - $submitted = self::processCustomFields($mainId, $key, $cFields, $submitted, $value); + if (strpos($key, 'custom_') === 0) { + $fieldID = (int) substr($key, 7); + if (empty($cFields[$fieldID])) { + $htmlType = $cFields[$fieldID]['attributes']['html_type']; + $isSerialized = CRM_Core_BAO_CustomField::isSerialized($cFields[$fieldID]['attributes']); + $isView = $cFields[$fieldID]['attributes']['is_view']; + $submitted = self::processCustomFields($mainId, $key, $submitted, $value, $fieldID, $isView, $htmlType, $isSerialized); + + } } } @@ -2526,31 +2533,27 @@ protected static function swapOutFieldsAffectedByQFZeroBug(&$migrationInfo) { * * @param int $mainId * @param string $key - * @param array $cFields * @param array $submitted * @param mixed $value + * @param int $fieldID + * @param bool $isView + * @param string $htmlType + * @param bool $isSerialized * * @return array * @throws \CRM_Core_Exception */ - protected static function processCustomFields($mainId, $key, $cFields, $submitted, $value) { - $fid = (int) substr($key, 7); - if (empty($cFields[$fid])) { - return $submitted; - } - $htmlType = $cFields[$fid]['attributes']['html_type']; - $isSerialized = CRM_Core_BAO_CustomField::isSerialized($cFields[$fid]['attributes']); - + protected static function processCustomFields(int $mainId, string $key, array $submitted, $value, int $fieldID, bool $isView, string $htmlType, bool $isSerialized): array { if ($htmlType === 'File') { // Handled in CustomField->move(). Tested in testMergeCustomFields. - unset($submitted["custom_$fid"]); + unset($submitted["custom_$fieldID"]); } elseif (!$isSerialized && ($htmlType === 'Select Country' || $htmlType === 'Select State/Province')) { // @todo Test in testMergeCustomFields disabled as this does not work, Handle in CustomField->move(). - $submitted[$key] = CRM_Core_BAO_CustomField::displayValue($value, $fid); + $submitted[$key] = CRM_Core_BAO_CustomField::displayValue($value, $fieldID); } elseif ($htmlType === 'Select Date') { - if ($cFields[$fid]['attributes']['is_view']) { + if ($isView) { $submitted[$key] = date('YmdHis', strtotime($submitted[$key])); } } From 8d31ec59aaeaf6aaf0f1558c93a73471f0a96365 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 10 Jan 2023 08:18:12 +1300 Subject: [PATCH 034/106] Php8.2 Contact import - remove columnCount --- CRM/Import/Forms.php | 1 - 1 file changed, 1 deletion(-) diff --git a/CRM/Import/Forms.php b/CRM/Import/Forms.php index ff4da683aa2b..6a8ca109c4fc 100644 --- a/CRM/Import/Forms.php +++ b/CRM/Import/Forms.php @@ -684,7 +684,6 @@ protected function assignMapFieldVariables(): void { $this->assign('columnNames', $this->getColumnHeaders()); $this->assign('showColumnNames', $this->getSubmittedValue('skipColumnHeader') || $this->getSubmittedValue('dataSource') !== 'CRM_Import_DataSource'); $this->assign('highlightedFields', $this->getHighlightedFields()); - $this->assign('columnCount', $this->_columnCount); $this->assign('dataValues', $this->_dataValues); } From 5a8206b4884a3075b90c072ccdb6b8d52048bb43 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 10 Jan 2023 08:25:59 +1300 Subject: [PATCH 035/106] Remove _columnCount from Contact MapField --- CRM/Contact/Import/Form/MapField.php | 3 +-- CRM/Import/Form/MapField.php | 7 ------- CRM/Import/Forms.php | 1 - 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index 5a8b5d0cdc49..23bf221dc6c9 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -277,9 +277,8 @@ public function buildQuickForm() { $processor->setContactSubType($this->getSubmittedValue('contactSubType')); $mapper = $this->getSubmittedValue('mapper'); - for ($i = 0; $i < $this->_columnCount; $i++) { + foreach ($this->getColumnHeaders() as $i => $columnHeader) { $sel = &$this->addElement('hierselect', "mapper[$i]", ts('Mapper for Field %1', [1 => $i]), NULL); - $last_key = 0; // Don't set any defaults if we are going to the next page. // ... or coming back. diff --git a/CRM/Import/Form/MapField.php b/CRM/Import/Form/MapField.php index 476d632ed9ad..6ac7669e2463 100644 --- a/CRM/Import/Form/MapField.php +++ b/CRM/Import/Form/MapField.php @@ -38,13 +38,6 @@ abstract class CRM_Import_Form_MapField extends CRM_Import_Forms { */ protected $_mapperFields; - /** - * Number of columns in import file - * - * @var int - */ - protected $_columnCount; - /** * Column headers, if we have them * diff --git a/CRM/Import/Forms.php b/CRM/Import/Forms.php index 6a8ca109c4fc..0c609c055d15 100644 --- a/CRM/Import/Forms.php +++ b/CRM/Import/Forms.php @@ -678,7 +678,6 @@ protected function getMappedFieldLabels(): array { */ protected function assignMapFieldVariables(): void { $this->addExpectedSmartyVariables(['highlightedRelFields', 'initHideBoxes']); - $this->_columnCount = $this->getNumberOfColumns(); $this->_columnNames = $this->getColumnHeaders(); $this->_dataValues = array_values($this->getDataRows([], 2)); $this->assign('columnNames', $this->getColumnHeaders()); From 1ea5d3b1767d3072c2be140463783ff5be30200a Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 10 Jan 2023 08:30:12 +1300 Subject: [PATCH 036/106] Fixes to type hints & docblocks --- CRM/Contact/Import/Form/MapField.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index 23bf221dc6c9..2e175d405f80 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -41,7 +41,7 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { * * @return string */ - public function defaultFromColumnName($columnName) { + public function defaultFromColumnName(string $columnName): string { if (!preg_match('/^[a-z0-9 ]$/i', $columnName)) { if ($columnKey = array_search($columnName, $this->getFieldTitles())) { @@ -70,7 +70,7 @@ public function defaultFromColumnName($columnName) { * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\UnauthorizedException */ - public function preProcess() { + public function preProcess(): void { $this->_mapperFields = $this->getAvailableFields(); $this->_contactSubType = $this->getSubmittedValue('contactSubType'); //format custom field names, CRM-2676 @@ -109,7 +109,7 @@ public function preProcess() { * * @throws \CRM_Core_Exception */ - public function buildQuickForm() { + public function buildQuickForm(): void { $this->addSavedMappingFields(); $this->addFormRule(['CRM_Contact_Import_Form_MapField', 'formRule']); @@ -334,7 +334,7 @@ public function buildQuickForm() { */ public static function formRule(array $fields) { if (!empty($fields['saveMapping'])) { - // todo - this is non-sensical - sane js is better. PR to fix got stale but + // todo - this is nonsensical - sane js is better. PR to fix got stale but // is here https://github.com/civicrm/civicrm-core/pull/23950 CRM_Core_Smarty::singleton()->assign('isCheked', TRUE); } @@ -343,8 +343,10 @@ public static function formRule(array $fields) { /** * Process the mapped fields and map it into the uploaded file. + * + * @throws \CRM_Core_Exception */ - public function postProcess() { + public function postProcess(): void { $params = $this->controller->exportValues('MapField'); $this->updateUserJobMetadata('submitted_values', $this->getSubmittedValues()); $this->submit($params); @@ -359,7 +361,7 @@ public function postProcess() { * * @return array */ - public function formatCustomFieldName($fields) { + public function formatCustomFieldName(array $fields): array { //CRM-2676, replacing the conflict for same custom field name from different custom group. $fieldIds = $formattedFieldNames = []; foreach ($fields as $key => $value) { @@ -388,12 +390,11 @@ public function formatCustomFieldName($fields) { * * Extracted to add testing & start refactoring. * - * @param $params - * @param $mapperKeys + * @param array $params * * @throws \CRM_Core_Exception */ - public function submit($params) { + public function submit(array $params): void { $this->set('columnNames', $this->_columnNames); // store mapping Id to display it in the preview page @@ -431,7 +432,6 @@ public function submit($params) { * Did the user specify duplicates matching should not be attempted. * * @return bool - * @throws \CRM_Core_Exception */ private function isIgnoreDuplicates(): bool { return ((int) $this->getSubmittedValue('onDuplicate')) === CRM_Import_Parser::DUPLICATE_NOCHECK; @@ -473,9 +473,11 @@ protected function getHighlightedFields(): array { * * e.g ['first_name' => FALSE, 'email' => TRUE, 'street_address' => TRUE'] * + * @param bool $name + * * @return bool */ - private function isLocationTypeRequired($name): bool { + private function isLocationTypeRequired(bool $name): bool { if (!isset(Civi::$statics[__CLASS__]['location_fields'])) { Civi::$statics[__CLASS__]['location_fields'] = (new CRM_Contact_Import_Parser_Contact())->setUserJobID($this->getUserJobID())->getFieldsWhichSupportLocationTypes(); } From 430c546a88d3e01242115137ca80aee6bffacd9d Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 10 Jan 2023 10:59:36 +1300 Subject: [PATCH 037/106] Cleanup type hints and comments --- CRM/Contact/Import/Form/MapField.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index 2e175d405f80..cd55054ac4ea 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -473,11 +473,11 @@ protected function getHighlightedFields(): array { * * e.g ['first_name' => FALSE, 'email' => TRUE, 'street_address' => TRUE'] * - * @param bool $name + * @param string $name * * @return bool */ - private function isLocationTypeRequired(bool $name): bool { + private function isLocationTypeRequired(string $name): bool { if (!isset(Civi::$statics[__CLASS__]['location_fields'])) { Civi::$statics[__CLASS__]['location_fields'] = (new CRM_Contact_Import_Parser_Contact())->setUserJobID($this->getUserJobID())->getFieldsWhichSupportLocationTypes(); } From 922acb31fafeded59223aeb0ff095065f341ac9e Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 10 Jan 2023 08:33:31 +1300 Subject: [PATCH 038/106] Remove undeclared & unused property I did a grep for this but it is also worth noting the reason this is no longer used is the parser has a function to get it from the submitted values & we don't pass the form around anymore --- CRM/Contact/Import/Form/MapField.php | 1 - 1 file changed, 1 deletion(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index cd55054ac4ea..c18bb6f0576e 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -72,7 +72,6 @@ public function defaultFromColumnName(string $columnName): string { */ public function preProcess(): void { $this->_mapperFields = $this->getAvailableFields(); - $this->_contactSubType = $this->getSubmittedValue('contactSubType'); //format custom field names, CRM-2676 $contactType = $this->getContactType(); From 9b4e90808856d6366d23847718c1555799c65dcf Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 10 Jan 2023 08:44:18 +1300 Subject: [PATCH 039/106] NFC remove unnecessary curly braces --- CRM/Contact/Import/Form/MapField.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index c18bb6f0576e..adf40353701c 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -173,12 +173,12 @@ public function buildQuickForm(): void { $id = $first = $second = NULL; } if (($first === 'a' && $second === 'b') || ($first === 'b' && $second === 'a')) { - $cType = $contactRelationCache[$id]["contact_type_{$second}"]; + $cType = $contactRelationCache[$id]["contact_type_$second"]; - //CRM-5125 for contact subtype specific relationshiptypes + //CRM-5125 for contact subtype specific RelationshipTypes $cSubType = NULL; - if (!empty($contactRelationCache[$id]["contact_sub_type_{$second}"])) { - $cSubType = $contactRelationCache[$id]["contact_sub_type_{$second}"]; + if (!empty($contactRelationCache[$id]["contact_sub_type_$second"])) { + $cSubType = $contactRelationCache[$id]["contact_sub_type_$second"]; } if (!$cType) { @@ -328,10 +328,10 @@ public function buildQuickForm(): void { * @param array $fields * Posted values of the form. * - * @return array|bool + * @return bool * list of errors to be posted back to the form */ - public static function formRule(array $fields) { + public static function formRule(array $fields): bool { if (!empty($fields['saveMapping'])) { // todo - this is nonsensical - sane js is better. PR to fix got stale but // is here https://github.com/civicrm/civicrm-core/pull/23950 @@ -374,7 +374,7 @@ public function formatCustomFieldName(array $fields): array { if (!empty($groupTitles)) { foreach ($groupTitles as $fId => $values) { - $key = "custom_{$fId}"; + $key = "custom_$fId"; $groupTitle = $values['groupTitle']; $formattedFieldNames[$key] = $fields[$key] . ' :: ' . $groupTitle; } From 315bb3656d626279cde30b507777b7b8acf18a28 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 10 Jan 2023 09:32:21 +1300 Subject: [PATCH 040/106] Remove legacy paramter columnNames --- CRM/Contact/Import/Form/MapField.php | 9 ++++----- CRM/Import/Forms.php | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index adf40353701c..b575872b6daf 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -117,7 +117,8 @@ public function buildQuickForm(): void { $defaults = []; $mapperKeys = array_keys($this->_mapperFields); - $hasColumnNames = !empty($this->_columnNames); + $hasColumnNames = $this->getSubmittedValue('skipColumnHeader'); + $this->_location_types = ['Primary' => ts('Primary')] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); @@ -292,7 +293,7 @@ public function buildQuickForm(): void { else { if ($hasColumnNames) { // do array search first to see if has mapped key - $columnKey = array_search($this->_columnNames[$i], $this->getFieldTitles()); + $columnKey = array_search($columnHeader, $this->getFieldTitles(), TRUE); if (isset($this->_fieldUsed[$columnKey])) { $defaults["mapper[$i]"] = [$columnKey]; $this->_fieldUsed[$key] = TRUE; @@ -300,7 +301,7 @@ public function buildQuickForm(): void { else { // Infer the default from the column names if we have them $defaults["mapper[$i]"] = [ - $this->defaultFromColumnName($this->_columnNames[$i]), + $this->defaultFromColumnName($columnHeader), ]; } } @@ -394,8 +395,6 @@ public function formatCustomFieldName(array $fields): array { * @throws \CRM_Core_Exception */ public function submit(array $params): void { - $this->set('columnNames', $this->_columnNames); - // store mapping Id to display it in the preview page $this->set('loadMappingId', CRM_Utils_Array::value('mappingId', $params)); diff --git a/CRM/Import/Forms.php b/CRM/Import/Forms.php index 0c609c055d15..8a72c3eae28c 100644 --- a/CRM/Import/Forms.php +++ b/CRM/Import/Forms.php @@ -678,7 +678,6 @@ protected function getMappedFieldLabels(): array { */ protected function assignMapFieldVariables(): void { $this->addExpectedSmartyVariables(['highlightedRelFields', 'initHideBoxes']); - $this->_columnNames = $this->getColumnHeaders(); $this->_dataValues = array_values($this->getDataRows([], 2)); $this->assign('columnNames', $this->getColumnHeaders()); $this->assign('showColumnNames', $this->getSubmittedValue('skipColumnHeader') || $this->getSubmittedValue('dataSource') !== 'CRM_Import_DataSource'); From 3310b2168303a7c73f373d3b14f639d9997ce45e Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 10 Jan 2023 09:42:27 +1300 Subject: [PATCH 041/106] Remove usages of dataValues, + unused function that calls it --- CRM/Import/Form/MapField.php | 47 ------------------------------------ CRM/Import/Forms.php | 3 +-- 2 files changed, 1 insertion(+), 49 deletions(-) diff --git a/CRM/Import/Form/MapField.php b/CRM/Import/Form/MapField.php index 6ac7669e2463..3ab882d2d110 100644 --- a/CRM/Import/Form/MapField.php +++ b/CRM/Import/Form/MapField.php @@ -24,13 +24,6 @@ */ abstract class CRM_Import_Form_MapField extends CRM_Import_Forms { - /** - * Cache of preview data values - * - * @var array - */ - protected $_dataValues; - /** * Mapper fields * @@ -134,46 +127,6 @@ public function defaultFromHeader($header, $patterns) { return ''; } - /** - * Guess at the field names given the data and patterns from the schema. - * - * @param array $patterns - * @param string $index - * - * @return string - */ - public function defaultFromData($patterns, $index) { - $best = ''; - $bestHits = 0; - $n = count($this->_dataValues); - - foreach ($patterns as $key => $re) { - // Skip empty key/patterns - if (!$key || !$re || strlen("$re") < 5) { - continue; - } - - /* Take a vote over the preview data set */ - $hits = 0; - for ($i = 0; $i < $n; $i++) { - if (isset($this->_dataValues[$i][$index])) { - if (preg_match($re, $this->_dataValues[$i][$index])) { - $hits++; - } - } - } - if ($hits > $bestHits) { - $bestHits = $hits; - $best = $key; - } - } - - if ($best != '') { - $this->_fieldUsed[$best] = TRUE; - } - return $best; - } - /** * Add the saved mapping fields to the form. * diff --git a/CRM/Import/Forms.php b/CRM/Import/Forms.php index 8a72c3eae28c..4c024ba2346a 100644 --- a/CRM/Import/Forms.php +++ b/CRM/Import/Forms.php @@ -678,11 +678,10 @@ protected function getMappedFieldLabels(): array { */ protected function assignMapFieldVariables(): void { $this->addExpectedSmartyVariables(['highlightedRelFields', 'initHideBoxes']); - $this->_dataValues = array_values($this->getDataRows([], 2)); $this->assign('columnNames', $this->getColumnHeaders()); $this->assign('showColumnNames', $this->getSubmittedValue('skipColumnHeader') || $this->getSubmittedValue('dataSource') !== 'CRM_Import_DataSource'); $this->assign('highlightedFields', $this->getHighlightedFields()); - $this->assign('dataValues', $this->_dataValues); + $this->assign('dataValues', array_values($this->getDataRows([], 2))); } /** From 5522f85b6ad97e51c62035c299b59956ffb5b6b0 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 10 Jan 2023 09:58:04 +1300 Subject: [PATCH 042/106] Remove another undefined property - LocationType --- CRM/Contact/Import/Form/MapField.php | 31 ++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index b575872b6daf..368c3201adea 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -120,10 +120,10 @@ public function buildQuickForm(): void { $hasColumnNames = $this->getSubmittedValue('skipColumnHeader'); - $this->_location_types = ['Primary' => ts('Primary')] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + $this->getLocationTypes(); $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); $this->assign('defaultLocationType', $defaultLocationType->id); - $this->assign('defaultLocationTypeLabel', $this->_location_types[$defaultLocationType->id]); + $this->assign('defaultLocationTypeLabel', $this->getLocationTypeLabel($defaultLocationType->id)); /* Initialize all field usages to false */ foreach ($mapperKeys as $key) { @@ -137,7 +137,7 @@ public function buildQuickForm(): void { $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); - foreach ($this->_location_types as $key => $value) { + foreach ($this->getLocationTypes() as $key => $value) { $sel3['phone'][$key] = &$phoneTypes; $sel3['phone_ext'][$key] = &$phoneTypes; //build array for IM service provider type for contact @@ -192,7 +192,7 @@ public function buildQuickForm(): void { foreach ($relatedFields as $name => $field) { $values[$name] = $field['title']; if ($this->isLocationTypeRequired($name)) { - $sel3[$key][$name] = $this->_location_types; + $sel3[$key][$name] = $this->getLocationTypes(); } elseif ($name === 'url') { $sel3[$key][$name] = $websiteTypes; @@ -246,7 +246,7 @@ public function buildQuickForm(): void { } } - foreach ($this->_location_types as $k => $value) { + foreach ($this->getLocationTypes() as $k => $value) { $sel4[$key]['phone'][$k] = &$phoneTypes; $sel4[$key]['phone_ext'][$k] = &$phoneTypes; //build array of IM service provider for related contact @@ -256,7 +256,7 @@ public function buildQuickForm(): void { else { $options = NULL; if ($this->isLocationTypeRequired($key)) { - $options = $this->_location_types; + $options = $this->getLocationTypes(); } elseif ($key === 'url') { $options = $websiteTypes; @@ -491,4 +491,23 @@ protected function getParser(): CRM_Contact_Import_Parser_Contact { return $parser; } + /** + * Get the location types for import, including the pseudo-type 'Primary'. + * + * @return array + */ + protected function getLocationTypes(): array { + return ['Primary' => ts('Primary')] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); + } + + /** + * Get the location types for import, including the pseudo-type 'Primary'. + * @param int|string $type + * Location Type ID or 'Primary'. + * @return string + */ + protected function getLocationTypeLabel($type): string { + return $this->getLocationTypes()[$type]; + } + } From 59adc04d26d2f1dd03eb8e32c1a8dca20ab86dbf Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 10 Jan 2023 10:15:32 +1300 Subject: [PATCH 043/106] Remove last dynamic property (_contactType) from MapField (Contact import) form Use strict comparison for cType (cat type?) cType is always a word so strict is good --- CRM/Contact/Import/Form/MapField.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index 368c3201adea..da82e2256220 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -75,8 +75,6 @@ public function preProcess(): void { //format custom field names, CRM-2676 $contactType = $this->getContactType(); - $this->_contactType = $contactType; - if ($this->isIgnoreDuplicates()) { //Mark Dedupe Rule Fields as required, since it's used in matching contact foreach (CRM_Contact_BAO_ContactType::basicTypes() as $cType) { @@ -117,8 +115,7 @@ public function buildQuickForm(): void { $defaults = []; $mapperKeys = array_keys($this->_mapperFields); - $hasColumnNames = $this->getSubmittedValue('skipColumnHeader'); - + $hasColumnNames = !empty($this->getDataSourceObject()->getColumnHeaders()); $this->getLocationTypes(); $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); @@ -203,7 +200,7 @@ public function buildQuickForm(): void { } //fix to append custom group name to field name, CRM-2676 - if (empty($this->_formattedFieldNames[$cType]) || $cType == $this->_contactType) { + if (empty($this->_formattedFieldNames[$cType]) || $cType === $this->getContactType()) { $this->_formattedFieldNames[$cType] = $this->formatCustomFieldName($values); } @@ -215,7 +212,7 @@ public function buildQuickForm(): void { is_array($this->_dedupeFields[$cType]) ) { static $cTypeArray = []; - if ($cType != $this->_contactType && !in_array($cType, $cTypeArray)) { + if ($cType !== $this->getContactType() && !in_array($cType, $cTypeArray)) { foreach ($this->_dedupeFields[$cType] as $val) { if ($valTitle = CRM_Utils_Array::value($val, $this->_formattedFieldNames[$cType])) { $this->_formattedFieldNames[$cType][$val] = $valTitle . ' (match to contact)'; @@ -226,7 +223,7 @@ public function buildQuickForm(): void { } foreach ($highlightedFields as $k => $v) { - if ($v == $cType || $v === 'All') { + if ($v === $cType || $v === 'All') { $highlightedRelFields[$key][] = $k; } } From 402c5c5fca33c14e2cc517679310985fe55aa297 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 11 Jan 2023 18:07:34 +1300 Subject: [PATCH 044/106] Use meaningful variable names --- CRM/Contact/Import/Form/MapField.php | 41 ++++++++++++---------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index da82e2256220..cee463fbfa02 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -171,19 +171,12 @@ public function buildQuickForm(): void { $id = $first = $second = NULL; } if (($first === 'a' && $second === 'b') || ($first === 'b' && $second === 'a')) { - $cType = $contactRelationCache[$id]["contact_type_$second"]; + $relatedContactType = $contactRelationCache[$id]["contact_type_$second"] ?: 'All'; //CRM-5125 for contact subtype specific RelationshipTypes - $cSubType = NULL; - if (!empty($contactRelationCache[$id]["contact_sub_type_$second"])) { - $cSubType = $contactRelationCache[$id]["contact_sub_type_$second"]; - } - - if (!$cType) { - $cType = 'All'; - } + $relatedContactSubType = $contactRelationCache[$id]["contact_sub_type_$second"] ?? NULL; - $relatedFields = CRM_Contact_BAO_Contact::importableFields($cType); + $relatedFields = CRM_Contact_BAO_Contact::importableFields($relatedContactType); unset($relatedFields['']); $values = []; foreach ($relatedFields as $name => $field) { @@ -200,39 +193,39 @@ public function buildQuickForm(): void { } //fix to append custom group name to field name, CRM-2676 - if (empty($this->_formattedFieldNames[$cType]) || $cType === $this->getContactType()) { - $this->_formattedFieldNames[$cType] = $this->formatCustomFieldName($values); + if (empty($this->_formattedFieldNames[$relatedContactType]) || $relatedContactType === $this->getContactType()) { + $this->_formattedFieldNames[$relatedContactType] = $this->formatCustomFieldName($values); } - $this->_formattedFieldNames[$cType] = array_merge($values, $this->_formattedFieldNames[$cType]); + $this->_formattedFieldNames[$relatedContactType] = array_merge($values, $this->_formattedFieldNames[$relatedContactType]); //Modified the Relationship fields if the fields are //present in dedupe rule - if ($this->isIgnoreDuplicates() && !empty($this->_dedupeFields[$cType]) && - is_array($this->_dedupeFields[$cType]) + if ($this->isIgnoreDuplicates() && !empty($this->_dedupeFields[$relatedContactType]) && + is_array($this->_dedupeFields[$relatedContactType]) ) { static $cTypeArray = []; - if ($cType !== $this->getContactType() && !in_array($cType, $cTypeArray)) { - foreach ($this->_dedupeFields[$cType] as $val) { - if ($valTitle = CRM_Utils_Array::value($val, $this->_formattedFieldNames[$cType])) { - $this->_formattedFieldNames[$cType][$val] = $valTitle . ' (match to contact)'; + if ($relatedContactType !== $this->getContactType() && !in_array($relatedContactType, $cTypeArray)) { + foreach ($this->_dedupeFields[$relatedContactType] as $val) { + if ($valTitle = CRM_Utils_Array::value($val, $this->_formattedFieldNames[$relatedContactType])) { + $this->_formattedFieldNames[$relatedContactType][$val] = $valTitle . ' (match to contact)'; } } - $cTypeArray[] = $cType; + $cTypeArray[] = $relatedContactType; } } foreach ($highlightedFields as $k => $v) { - if ($v === $cType || $v === 'All') { + if ($v === $relatedContactType || $v === 'All') { $highlightedRelFields[$key][] = $k; } } $this->assign('highlightedRelFields', $highlightedRelFields); - $sel2[$key] = $this->_formattedFieldNames[$cType]; + $sel2[$key] = $this->_formattedFieldNames[$relatedContactType]; - if (!empty($cSubType)) { + if (!empty($relatedContactSubType)) { //custom fields for sub type - $subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($cSubType); + $subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($relatedContactSubType); if (!empty($subTypeFields)) { $subType = NULL; From 4355339478b770934b5c13015da1d18423cd0927 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 2 Jan 2023 16:00:06 +1300 Subject: [PATCH 045/106] Deprecate meaningless parameter --- .../CRM/Contact/Form/Search/Custom/Base.php | 11 +++++------ .../CRM/Contact/Form/Search/Custom/FullText.php | 8 +------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/Base.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/Base.php index 6c275cdc0730..2ff571d5a265 100644 --- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/Base.php +++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/Base.php @@ -69,10 +69,14 @@ public function summary() { * @param int $rowcount * @param null $sort * @param bool $returnSQL + * Deprecated parameter * * @return string */ public function contactIDs($offset = 0, $rowcount = 0, $sort = NULL, $returnSQL = FALSE) { + if ($returnSQL) { + CRM_Core_Error::deprecatedWarning('do not pass returnSQL'); + } $sql = $this->sql( 'contact_a.id as contact_id', $offset, @@ -80,12 +84,7 @@ public function contactIDs($offset = 0, $rowcount = 0, $sort = NULL, $returnSQL $sort ); $this->validateUserSQL($sql); - - if ($returnSQL) { - return $sql; - } - - return CRM_Core_DAO::composeQuery($sql); + return $sql; } /** diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php index 286819413797..ae6eeec70cf2 100644 --- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php +++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php @@ -449,13 +449,7 @@ public function count() { */ public function contactIDs($offset = 0, $rowcount = 0, $sort = NULL, $returnSQL = FALSE) { $this->initialize(); - - if ($returnSQL) { - return $this->all($offset, $rowcount, $sort, FALSE, TRUE); - } - else { - return CRM_Core_DAO::singleValueQuery("SELECT contact_id FROM {$this->tableName}"); - } + return $this->all($offset, $rowcount, $sort, FALSE, TRUE); } /** From bbe46bbaf79e99d2894ec280db9a6687ec63ee83 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 1 Jan 2023 15:49:53 +1300 Subject: [PATCH 046/106] Re-run Civix - Greenwich extension --- ext/greenwich/greenwich.civix.php | 94 ++----------------------------- ext/greenwich/info.xml | 2 +- 2 files changed, 6 insertions(+), 90 deletions(-) diff --git a/ext/greenwich/greenwich.civix.php b/ext/greenwich/greenwich.civix.php index 782bb0f998e5..3e018c743bd3 100644 --- a/ext/greenwich/greenwich.civix.php +++ b/ext/greenwich/greenwich.civix.php @@ -84,27 +84,20 @@ public static function findClass($suffix) { * * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config */ -function _greenwich_civix_civicrm_config(&$config = NULL) { +function _greenwich_civix_civicrm_config($config = NULL) { static $configured = FALSE; if ($configured) { return; } $configured = TRUE; - $template = CRM_Core_Smarty::singleton(); - $extRoot = __DIR__ . DIRECTORY_SEPARATOR; $extDir = $extRoot . 'templates'; - - if (is_array($template->template_dir)) { - array_unshift($template->template_dir, $extDir); - } - else { - $template->template_dir = [$extDir, $template->template_dir]; - } + CRM_Core_Smarty::singleton()->addTemplateDir($extDir); $include_path = $extRoot . PATH_SEPARATOR . get_include_path(); set_include_path($include_path); + // Based on , this does not currently require mixin/polyfill.php. } /** @@ -114,35 +107,7 @@ function _greenwich_civix_civicrm_config(&$config = NULL) { */ function _greenwich_civix_civicrm_install() { _greenwich_civix_civicrm_config(); - if ($upgrader = _greenwich_civix_upgrader()) { - $upgrader->onInstall(); - } -} - -/** - * Implements hook_civicrm_postInstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall - */ -function _greenwich_civix_civicrm_postInstall() { - _greenwich_civix_civicrm_config(); - if ($upgrader = _greenwich_civix_upgrader()) { - if (is_callable([$upgrader, 'onPostInstall'])) { - $upgrader->onPostInstall(); - } - } -} - -/** - * Implements hook_civicrm_uninstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall - */ -function _greenwich_civix_civicrm_uninstall(): void { - _greenwich_civix_civicrm_config(); - if ($upgrader = _greenwich_civix_upgrader()) { - $upgrader->onUninstall(); - } + // Based on , this does not currently require mixin/polyfill.php. } /** @@ -152,56 +117,7 @@ function _greenwich_civix_civicrm_uninstall(): void { */ function _greenwich_civix_civicrm_enable(): void { _greenwich_civix_civicrm_config(); - if ($upgrader = _greenwich_civix_upgrader()) { - if (is_callable([$upgrader, 'onEnable'])) { - $upgrader->onEnable(); - } - } -} - -/** - * (Delegated) Implements hook_civicrm_disable(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable - * @return mixed - */ -function _greenwich_civix_civicrm_disable(): void { - _greenwich_civix_civicrm_config(); - if ($upgrader = _greenwich_civix_upgrader()) { - if (is_callable([$upgrader, 'onDisable'])) { - $upgrader->onDisable(); - } - } -} - -/** - * (Delegated) Implements hook_civicrm_upgrade(). - * - * @param $op string, the type of operation being performed; 'check' or 'enqueue' - * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks - * - * @return mixed - * based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending) - * for 'enqueue', returns void - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade - */ -function _greenwich_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { - if ($upgrader = _greenwich_civix_upgrader()) { - return $upgrader->onUpgrade($op, $queue); - } -} - -/** - * @return CRM_Greenwich_Upgrader - */ -function _greenwich_civix_upgrader() { - if (!file_exists(__DIR__ . '/CRM/Greenwich/Upgrader.php')) { - return NULL; - } - else { - return CRM_Greenwich_Upgrader_Base::instance(); - } + // Based on , this does not currently require mixin/polyfill.php. } /** diff --git a/ext/greenwich/info.xml b/ext/greenwich/info.xml index 48d68344a5b7..2a92ec6e103a 100644 --- a/ext/greenwich/info.xml +++ b/ext/greenwich/info.xml @@ -29,6 +29,6 @@ CRM/Greenwich - 22.10.0 + 22.12.1 From 17a5f733607c357d2fd6de3422fd033723ca169b Mon Sep 17 00:00:00 2001 From: Herb v/d Dool Date: Wed, 11 Jan 2023 09:48:39 -0500 Subject: [PATCH 047/106] add :bool and update comments --- CRM/Core/BAO/UFGroup.php | 3 +-- CRM/Utils/System/Base.php | 2 +- CRM/Utils/System/Drupal8.php | 4 ++-- CRM/Utils/System/DrupalBase.php | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 5cbb50cc7e53..e9bbdadb3499 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -916,8 +916,7 @@ public static function getEditHTML( $template = CRM_Core_Smarty::singleton(); - // Hide CRM error messages if they are set based on CMS - // criteria. + // Hide CRM error messages if they are set by the CMS. if (!empty($_POST)) { $supressForm = CRM_Core_Config::singleton()->userSystem->suppressProfileFormErrors(); $template->assign('suppressForm', $supressForm); diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 553cb333bd20..9b435b22d825 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -1119,7 +1119,7 @@ public function checkCleanurls() { * * @return bool */ - public function suppressProfileFormErrors() { + public function suppressProfileFormErrors():bool { return FALSE; } diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index 445b4ebbb491..30d2b5f012e5 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -904,9 +904,9 @@ public function getVersion() { /** * @inheritdoc */ - public function suppressProfileFormErrors() { + public function suppressProfileFormErrors():bool { // Suppress the errors if they are displayed using - // drupal form_set_error. + // setErrorByName method on FormStateInterface. $current_path = \Drupal::service('path.current')->getPath(); $path_args = explode('/', $current_path); if ($path_args[1] == 'user' || ($path_args[1] == 'admin' && $path_args[2] == 'people')) { diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index c0e567a4b2b4..102f3fa76e93 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -724,9 +724,9 @@ public function getUfGroupTypes() { /** * @inheritdoc */ - public function suppressProfileFormErrors() { + public function suppressProfileFormErrors():bool { // Suppress the errors if they are displayed using - // drupal form_set_error. + // form_set_error. if (arg(0) == 'user' || (arg(0) == 'admin' && arg(1) == 'people')) { return TRUE; } From 16268a9e1474eeb71637b3728aeb914a7f6e887a Mon Sep 17 00:00:00 2001 From: Stephen Palmstrom Date: Wed, 11 Jan 2023 17:36:37 +0000 Subject: [PATCH 048/106] Issue 1984 updated --- CRM/Core/BAO/UFGroup.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index e9bbdadb3499..c7d1b83e46f7 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -729,7 +729,9 @@ protected static function getCustomFields($ctype, $checkPermission = CRM_Core_Pe if ($checkPermission == CRM_Core_Permission::CREATE) { $checkPermission = CRM_Core_Permission::EDIT; } - $cacheKey = 'uf_group_custom_fields_' . $ctype . '_' . (int) $checkPermission; + // Make the cache user specific by adding the ID to the key. + $id = CRM_Core_Session::getLoggedInContactID(); + $cacheKey = 'uf_group_custom_fields_' . $ctype . '_' . $id . '_' . (int) $checkPermission; if (!Civi::cache('metadata')->has($cacheKey)) { $customFields = CRM_Core_BAO_CustomField::getFieldsForImport($ctype, FALSE, FALSE, FALSE, $checkPermission, TRUE); @@ -916,10 +918,11 @@ public static function getEditHTML( $template = CRM_Core_Smarty::singleton(); - // Hide CRM error messages if they are set by the CMS. - if (!empty($_POST)) { - $supressForm = CRM_Core_Config::singleton()->userSystem->suppressProfileFormErrors(); - $template->assign('suppressForm', $supressForm); + // Hide CRM error messages if they are displayed using drupal form_set_error. + if (!empty($_POST) && CRM_Core_Config::singleton()->userFramework == 'Drupal') { + if (arg(0) == 'user' || (arg(0) == 'admin' && arg(1) == 'people')) { + $template->assign('suppressForm', TRUE); + } } $templateFile = "CRM/Profile/Form/{$profileID}/Dynamic.tpl"; From 5101acab02ce6414558c2f8d7d2d06848c2d68a9 Mon Sep 17 00:00:00 2001 From: Stephen Palmstrom Date: Wed, 11 Jan 2023 17:42:37 +0000 Subject: [PATCH 049/106] Issue 1984 - make caches ID specific. --- CRM/Core/BAO/UFGroup.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index c7d1b83e46f7..03c38ba36c7a 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -918,12 +918,11 @@ public static function getEditHTML( $template = CRM_Core_Smarty::singleton(); - // Hide CRM error messages if they are displayed using drupal form_set_error. - if (!empty($_POST) && CRM_Core_Config::singleton()->userFramework == 'Drupal') { - if (arg(0) == 'user' || (arg(0) == 'admin' && arg(1) == 'people')) { - $template->assign('suppressForm', TRUE); + // Hide CRM error messages if they are set by the CMS. + if (!empty($_POST)) { + $supressForm = CRM_Core_Config::singleton()->userSystem->suppressProfileFormErrors(); + $template->assign('suppressForm', $supressForm); } - } $templateFile = "CRM/Profile/Form/{$profileID}/Dynamic.tpl"; if (!$template->template_exists($templateFile)) { From ba5c63e4a3b450a7b809ed0433b115e979e4bba1 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Wed, 11 Jan 2023 18:53:38 +0000 Subject: [PATCH 050/106] (REF) Tidy-up unreachable return --- CRM/Utils/REST.php | 1 - 1 file changed, 1 deletion(-) diff --git a/CRM/Utils/REST.php b/CRM/Utils/REST.php index 9a2f7ee25ea6..4c6edc9c6606 100644 --- a/CRM/Utils/REST.php +++ b/CRM/Utils/REST.php @@ -133,7 +133,6 @@ public static function output(&$result) { if (!empty($requestParams['prettyprint'])) { // Don't set content-type header for api explorer output return json_encode(array_merge($result), JSON_PRETTY_PRINT + JSON_UNESCAPED_SLASHES + JSON_UNESCAPED_UNICODE); - return self::jsonFormated(array_merge($result)); } CRM_Utils_System::setHttpHeader('Content-Type', 'application/json'); return json_encode(array_merge($result)); From bdcf5fdc4662145773fc9faa1ba2d2893c291326 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 11 Jan 2023 18:13:04 +1300 Subject: [PATCH 051/106] Simplify / clarify contact type simplification --- CRM/Contact/Import/Form/MapField.php | 71 ++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 15 deletions(-) diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index cee463fbfa02..26d8eb6c35e8 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -15,6 +15,8 @@ * @copyright CiviCRM LLC https://civicrm.org/licensing */ +use Civi\Api4\RelationshipType; + /** * This class gets the name of the file to upload. */ @@ -143,16 +145,6 @@ public function buildQuickForm(): void { $sel4 = NULL; - // store and cache all relationship types - $contactRelation = new CRM_Contact_DAO_RelationshipType(); - $contactRelation->find(); - while ($contactRelation->fetch()) { - $contactRelationCache[$contactRelation->id] = []; - $contactRelationCache[$contactRelation->id]['contact_type_a'] = $contactRelation->contact_type_a; - $contactRelationCache[$contactRelation->id]['contact_sub_type_a'] = $contactRelation->contact_sub_type_a; - $contactRelationCache[$contactRelation->id]['contact_type_b'] = $contactRelation->contact_type_b; - $contactRelationCache[$contactRelation->id]['contact_sub_type_b'] = $contactRelation->contact_sub_type_b; - } $highlightedFields = $highlightedRelFields = []; $highlightedFields['email'] = 'All'; @@ -166,16 +158,14 @@ public function buildQuickForm(): void { // check if there is a _a_b or _b_a in the key if (strpos($key, '_a_b') || strpos($key, '_b_a')) { [$id, $first, $second] = explode('_', $key); + $relatedContactType = $this->getRelatedContactType($key); + //CRM-5125 for contact subtype specific RelationshipTypes + $relatedContactSubType = $this->getRelatedContactSubType($key); } else { $id = $first = $second = NULL; } if (($first === 'a' && $second === 'b') || ($first === 'b' && $second === 'a')) { - $relatedContactType = $contactRelationCache[$id]["contact_type_$second"] ?: 'All'; - - //CRM-5125 for contact subtype specific RelationshipTypes - $relatedContactSubType = $contactRelationCache[$id]["contact_sub_type_$second"] ?? NULL; - $relatedFields = CRM_Contact_BAO_Contact::importableFields($relatedContactType); unset($relatedFields['']); $values = []; @@ -492,6 +482,7 @@ protected function getLocationTypes(): array { /** * Get the location types for import, including the pseudo-type 'Primary'. + * * @param int|string $type * Location Type ID or 'Primary'. * @return string @@ -500,4 +491,54 @@ protected function getLocationTypeLabel($type): string { return $this->getLocationTypes()[$type]; } + /** + * Get the type of the related contact. + * + * @param string $key + * + * @return string + */ + protected function getRelatedContactType(string $key): string { + $relationship = $this->getRelationshipType($key); + if (strpos($key, '_a_b')) { + return $relationship['contact_type_b'] ?: 'All'; + } + return $relationship['contact_type_a'] ?: 'All'; + } + + /** + * Get the sub_type of the related contact. + * + * @param string $key + * + * @return string|null + */ + protected function getRelatedContactSubType(string $key): ?string { + $relationship = $this->getRelationshipType($key); + if (strpos($key, '_a_b')) { + return $relationship['contact_sub_type_b']; + } + return $relationship['contact_sub_type_a']; + } + + /** + * Get the relationship type. + * + * @param string $key + * e.g 5_a_b for relationship ID 5 in an a-b direction. + * + * @noinspection PhpUnhandledExceptionInspection + * @noinspection PhpDocMissingThrowsInspection + */ + protected function getRelationshipType(string $key): array { + $relationshipTypeID = str_replace(['_a_b', '_b_a'], '', $key); + if (!isset(Civi::$statics[__CLASS__]['relationship_type'][$relationshipTypeID])) { + Civi::$statics[__CLASS__]['relationship_type'][$relationshipTypeID] = RelationshipType::get(FALSE) + ->addWhere('id', '=', $relationshipTypeID) + ->addSelect('contact_type_a', 'contact_type_b', 'contact_sub_type_a', 'contact_sub_type_b') + ->execute()->first(); + } + return Civi::$statics[__CLASS__]['relationship_type'][$relationshipTypeID]; + } + } From fd8341bb4e26d49f96b445e1292bd240af5d9fc1 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Wed, 11 Jan 2023 19:41:40 +0000 Subject: [PATCH 052/106] [REF][PHP8.2] Avoid dynamic properties in CRM_Case_XMLProcessor_ProcessTest --- .../CRM/Case/XMLProcessor/ProcessTest.php | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php b/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php index c83fcfa9769e..8d6a890d566f 100644 --- a/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php +++ b/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php @@ -7,11 +7,44 @@ */ class CRM_Case_XMLProcessor_ProcessTest extends CiviCaseTestCase { + /** + * @var array + */ + private $defaultAssigneeOptionsValues = []; + + /** + * @var array + */ + private $contacts = []; + + /** + * @var array + */ + private $relationships = []; + + /** + * @var array + */ + private $moreRelationshipTypes = []; + + /** + * @var SimpleXMLElement + */ + private $activityTypeXml; + + /** + * @var array + */ + private $activityParams = []; + + /** + * @var CRM_Case_XMLProcessor_Process + */ + private $process; + public function setUp(): void { parent::setUp(); - $this->defaultAssigneeOptionsValues = []; - $this->setupContacts(); $this->setupDefaultAssigneeOptions(); $this->setupRelationships(); From 73113ecdea3c8d801bc8b47b9e737fcd70484aa1 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Wed, 11 Jan 2023 19:48:10 +0000 Subject: [PATCH 053/106] Remove unused method in CRM_Contact_Form_Task_PDFLetterCommon --- CRM/Contact/Form/Task/PDFLetterCommon.php | 24 ----------------------- 1 file changed, 24 deletions(-) diff --git a/CRM/Contact/Form/Task/PDFLetterCommon.php b/CRM/Contact/Form/Task/PDFLetterCommon.php index eb2e058e99ea..b4df6126da00 100644 --- a/CRM/Contact/Form/Task/PDFLetterCommon.php +++ b/CRM/Contact/Form/Task/PDFLetterCommon.php @@ -109,30 +109,6 @@ public static function processMessageTemplate($formValues) { return [$formValues, $categories, $html_message, $messageToken, $returnProperties]; } - /** - * Convert from a vague-type/file-extension to mime-type. - * - * @param string $type - * @return string - * @throws \CRM_Core_Exception - * - * @deprecated - */ - private static function getMimeType($type) { - $mimeTypes = [ - 'pdf' => 'application/pdf', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'odt' => 'application/vnd.oasis.opendocument.text', - 'html' => 'text/html', - ]; - if (isset($mimeTypes[$type])) { - return $mimeTypes[$type]; - } - else { - throw new \CRM_Core_Exception("Cannot determine mime type"); - } - } - /** * Get the categories required for rendering tokens. * From 5c99a0c37864d5e70681aff948d1dfa40fd4ce8c Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 12 Jan 2023 13:01:29 +1300 Subject: [PATCH 054/106] Standardise Type on includedGroups --- CRM/ACL/API.php | 8 ++++++-- CRM/ACL/BAO/ACL.php | 14 ++++++++------ CRM/Report/Form.php | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CRM/ACL/API.php b/CRM/ACL/API.php index a02fb38a7cd6..1bafc8b8b615 100644 --- a/CRM/ACL/API.php +++ b/CRM/ACL/API.php @@ -140,7 +140,7 @@ public static function whereClause( * * @param string $tableName * @param array|null $allGroups - * @param array|null $includedGroups + * @param array $includedGroups * * @return array * the ids of the groups for which the user has permissions @@ -150,8 +150,12 @@ public static function group( $contactID = NULL, $tableName = 'civicrm_saved_search', $allGroups = NULL, - $includedGroups = NULL + $includedGroups = [] ) { + if (!is_array($includedGroups)) { + CRM_Core_Error::deprecatedWarning('pass an array for included groups'); + $includedGroups = (array) $includedGroups; + } if ($contactID == NULL) { $contactID = CRM_Core_Session::getLoggedInContactID(); } diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 58b388b7330c..d1166f87ed67 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -324,7 +324,7 @@ public static function whereClause($type, &$tables, &$whereTables, $contactID = * @param int $contactID * @param string $tableName * @param array|null $allGroups - * @param array|null $includedGroups + * @param array $includedGroups * * @return array */ @@ -333,9 +333,13 @@ public static function group( $contactID = NULL, $tableName = 'civicrm_saved_search', $allGroups = NULL, - $includedGroups = NULL + $includedGroups = [] ) { - $userCacheKey = "{$contactID}_{$type}_{$tableName}_" . CRM_Core_Config::domainID() . '_' . md5(implode(',', array_merge((array) $allGroups, (array) $includedGroups))); + if (!is_array($includedGroups)) { + CRM_Core_Error::deprecatedWarning('pass an array for included groups'); + $includedGroups = (array) $includedGroups; + } + $userCacheKey = "{$contactID}_{$type}_{$tableName}_" . CRM_Core_Config::domainID() . '_' . md5(implode(',', array_merge((array) $allGroups, $includedGroups))); if (empty(Civi::$statics[__CLASS__]['permissioned_groups'])) { Civi::$statics[__CLASS__]['permissioned_groups'] = []; } @@ -363,9 +367,7 @@ public static function group( } } - if (empty($ids) && !empty($includedGroups) && - is_array($includedGroups) - ) { + if (empty($ids) && !empty($includedGroups)) { // This is pretty alarming - we 'sometimes' include all included groups // seems problematic per https://lab.civicrm.org/dev/core/-/issues/1879 $ids = $includedGroups; diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index e74c355a0c86..e659a5035764 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -598,7 +598,7 @@ public function __construct() { // and addCustomDataToColumns() will allow access to all custom groups. $permCustomGroupIds = []; if (!CRM_Core_Permission::check('access all custom data')) { - $permCustomGroupIds = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_custom_group', $allGroups, NULL); + $permCustomGroupIds = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_custom_group', $allGroups); // do not allow custom data for reports if user doesn't have // permission to access custom data. if (!empty($this->_customGroupExtends) && empty($permCustomGroupIds)) { From 03d53ecbc5bf9f3b749cf36834af6fd0418ef254 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 12 Jan 2023 15:19:50 +1300 Subject: [PATCH 055/106] Php 8.2 - undefined property fix in test class --- tests/phpunit/api/v3/ACLPermissionTest.php | 43 +++++++++++++--------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/tests/phpunit/api/v3/ACLPermissionTest.php b/tests/phpunit/api/v3/ACLPermissionTest.php index dbd1c85a87f6..076f8dc024e0 100644 --- a/tests/phpunit/api/v3/ACLPermissionTest.php +++ b/tests/phpunit/api/v3/ACLPermissionTest.php @@ -38,6 +38,16 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { public $DBResetRequired = FALSE; protected $_entity; + /** + * @var int + */ + protected $_permissionedGroup; + + /** + * @var int + */ + protected $_permissionedDisabledGroup; + public function setUp(): void { parent::setUp(); CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_Pledge', [], 1, 0); @@ -46,7 +56,6 @@ public function setUp(): void { } /** - * (non-PHPdoc) * @see CiviUnitTestCase::tearDown() */ public function tearDown(): void { @@ -382,7 +391,7 @@ public function testContactGetAddressReturned(): void { $this, 'aclWhereOnlySecond', ]); - $fullresult = $this->callAPISuccess('contact', 'get', [ + $fullResult = $this->callAPISuccess('contact', 'get', [ 'sequential' => 1, ]); //return doesn't work for all keys - can't fix that here so let's skip ... @@ -399,7 +408,7 @@ public function testContactGetAddressReturned(): void { 'worldregion_id', 'world_region', ]; - $expectedReturnElements = array_diff(array_keys($fullresult['values'][0]), $elementsReturnDoesntSupport); + $expectedReturnElements = array_diff(array_keys($fullResult['values'][0]), $elementsReturnDoesntSupport); $result = $this->callAPISuccess('contact', 'get', [ 'check_permissions' => 1, 'return' => $expectedReturnElements, @@ -862,7 +871,7 @@ public function testGetActivityByAclCannotViewAnyContacts(int $version): void { * @dataProvider versionThreeAndFour * @throws \CRM_Core_Exception */ - public function testGetActivityACLSourceContactDeleted($version): void { + public function testGetActivityACLSourceContactDeleted(int $version): void { $this->_apiversion = $version; $this->setPermissions(['access CiviCRM', 'delete contacts']); $activity = $this->activityCreate(); @@ -1124,34 +1133,34 @@ public function testApi4CustomEntityACL(): void { $this->hookClass->setHook('civicrm_aclWhereClause', [$this, 'aclWhereHookAllResults']); // Without "access deleted contacts" we won't see C2 - $vals = CustomValue::get($group)->setDebug(TRUE)->execute(); - $this->assertCount(1, $vals); - $this->assertEquals($c1, $vals[0]['entity_id']); + $customValues = CustomValue::get($group)->setDebug(TRUE)->execute(); + $this->assertCount(1, $customValues); + $this->assertEquals($c1, $customValues[0]['entity_id']); $this->setPermissions(['access CiviCRM', 'access deleted contacts', 'view debug output', 'access all custom data']); $this->hookClass->setHook('civicrm_aclWhereClause', [$this, 'aclWhereHookAllResults']); $this->cleanupCachedPermissions(); - $vals = CustomValue::get($group)->execute(); - $this->assertCount(2, $vals); + $customValues = CustomValue::get($group)->execute(); + $this->assertCount(2, $customValues); $this->allowedContactId = $c2; $this->hookClass->setHook('civicrm_aclWhereClause', [$this, 'aclWhereOnlyOne']); $this->cleanupCachedPermissions(); - $vals = CustomValue::get($group)->addSelect('*', 'contact.first_name')->execute(); - $this->assertCount(1, $vals); - $this->assertEquals($c2, $vals[0]['entity_id']); - $this->assertEquals('C2', $vals[0]['contact.first_name']); + $customValues = CustomValue::get($group)->addSelect('*', 'contact.first_name')->execute(); + $this->assertCount(1, $customValues); + $this->assertEquals($c2, $customValues[0]['entity_id']); + $this->assertEquals('C2', $customValues[0]['contact.first_name']); - $vals = Contact::get() + $customValues = Contact::get() ->addJoin('Custom_' . $group . ' AS cf') ->addSelect('first_name', 'cf.' . $textField) ->addWhere('is_deleted', '=', TRUE) ->execute(); - $this->assertCount(1, $vals); - $this->assertEquals('C2', $vals[0]['first_name']); - $this->assertEquals('2', $vals[0]['cf.' . $textField]); + $this->assertCount(1, $customValues); + $this->assertEquals('C2', $customValues[0]['first_name']); + $this->assertEquals('2', $customValues[0]['cf.' . $textField]); } } From 367904b98072205fe9ed98203fb799fb61c69a7b Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 12 Jan 2023 17:14:34 +1300 Subject: [PATCH 056/106] NFC superficial prelminary cleanup in test class --- tests/phpunit/CRM/Utils/StringTest.php | 155 ++++++++++++++----------- 1 file changed, 85 insertions(+), 70 deletions(-) diff --git a/tests/phpunit/CRM/Utils/StringTest.php b/tests/phpunit/CRM/Utils/StringTest.php index c9d46ab10892..ed452120f7e3 100644 --- a/tests/phpunit/CRM/Utils/StringTest.php +++ b/tests/phpunit/CRM/Utils/StringTest.php @@ -6,7 +6,7 @@ */ class CRM_Utils_StringTest extends CiviUnitTestCase { - public function testBase64Url() { + public function testBase64Url(): void { $examples = [ 'a' => 'YQ', 'ab' => 'YWI', @@ -19,7 +19,7 @@ public function testBase64Url() { } } - public function testStripPathChars() { + public function testStripPathChars(): void { $testSet = [ '' => '', NULL => NULL, @@ -32,11 +32,11 @@ public function testStripPathChars() { foreach ($testSet as $in => $expected) { $out = CRM_Utils_String::stripPathChars($in); - $this->assertEquals($out, $expected, "Output does not match"); + $this->assertEquals($out, $expected, 'Output does not match'); } } - public function testExtractName() { + public function testExtractName(): void { $cases = [ [ 'full_name' => 'Alan', @@ -85,7 +85,12 @@ public function testExtractName() { } } - public function testEllipsify() { + /** + * Test the ellipsify function. + * + * @noinspection SpellCheckingInspection + */ + public function testEllipsify(): void { $maxLen = 5; $cases = [ '1' => '1', @@ -101,7 +106,7 @@ public function testEllipsify() { $this->assertEquals(TRUE, mb_check_encoding(CRM_Utils_String::ellipsify($input, $maxLen), 'UTF-8')); } - public function testRandom() { + public function testRandom(): void { for ($i = 0; $i < 4; $i++) { $actual = CRM_Utils_String::createRandom(4, 'abc'); $this->assertEquals(4, strlen($actual)); @@ -116,7 +121,7 @@ public function testRandom() { /** * @return array */ - public function parsePrefixData() { + public function parsePrefixData(): array { $cases = []; $cases[] = ['administer CiviCRM', NULL, [NULL, 'administer CiviCRM']]; $cases[] = ['administer CiviCRM', 'com_civicrm', ['com_civicrm', 'administer CiviCRM']]; @@ -127,11 +132,12 @@ public function parsePrefixData() { /** * @dataProvider parsePrefixData + * * @param $input * @param $defaultPrefix * @param $expected */ - public function testParsePrefix($input, $defaultPrefix, $expected) { + public function testParsePrefix($input, $defaultPrefix, $expected): void { $actual = CRM_Utils_String::parsePrefix(':', $input, $defaultPrefix); $this->assertEquals($expected, $actual); } @@ -139,7 +145,7 @@ public function testParsePrefix($input, $defaultPrefix, $expected) { /** * @return array */ - public function booleanDataProvider() { + public function booleanDataProvider(): array { // array(0 => $input, 1 => $expectedOutput) $cases = []; $cases[] = [TRUE, TRUE]; @@ -166,16 +172,22 @@ public function booleanDataProvider() { } /** - * @param $input + * @param mixed $input * @param bool $expected - * * @dataProvider booleanDataProvider + * + * @dataProvider booleanDataProvider */ - public function testStrToBool($input, $expected) { + public function testStrToBool($input, bool $expected): void { $actual = CRM_Utils_String::strtobool($input); - $this->assertTrue($expected === $actual); + $this->assertSame($expected, $actual); } - public function startEndCases() { + /** + * Data provider for checking how strings start and end. + * + * @noinspection SpellCheckingInspection + */ + public function startEndCases(): array { $cases = []; $cases[] = ['startsWith', 'foo', '', TRUE]; $cases[] = ['startsWith', 'foo', 'f', TRUE]; @@ -194,19 +206,20 @@ public function startEndCases() { } /** - * @param string $func + * @param string $function * One of: 'startsWith' or 'endsWith'. * @param $string * @param $fragment * @param $expectedResult + * * @dataProvider startEndCases */ - public function testStartEndWith($func, $string, $fragment, $expectedResult) { - $actualResult = \CRM_Utils_String::$func($string, $fragment); - $this->assertEquals($expectedResult, $actualResult, "Checking $func($string,$fragment)"); + public function testStartEndWith(string $function, $string, $fragment, $expectedResult): void { + $actualResult = CRM_Utils_String::$function($string, $fragment); + $this->assertEquals($expectedResult, $actualResult, "Checking $function($string,$fragment)"); } - public function wildcardCases() { + public function wildcardCases(): array { $cases = []; $cases[] = ['*', ['foo.bar.1', 'foo.bar.2', 'foo.whiz', 'bang.bang']]; $cases[] = ['foo.*', ['foo.bar.1', 'foo.bar.2', 'foo.whiz']]; @@ -221,7 +234,7 @@ public function wildcardCases() { * @param $expectedResults * @dataProvider wildcardCases */ - public function testFilterByWildCards($patterns, $expectedResults) { + public function testFilterByWildCards($patterns, $expectedResults): void { $data = ['foo.bar.1', 'foo.bar.2', 'foo.whiz', 'bang.bang']; $actualResults = CRM_Utils_String::filterByWildcards($patterns, $data); @@ -230,7 +243,7 @@ public function testFilterByWildCards($patterns, $expectedResults) { $patterns = (array) $patterns; $patterns[] = 'noise'; - $actualResults = CRM_Utils_String::filterByWildcards($patterns, $data, FALSE); + $actualResults = CRM_Utils_String::filterByWildcards($patterns, $data); $this->assertEquals($expectedResults, $actualResults); $actualResults = CRM_Utils_String::filterByWildcards($patterns, $data, TRUE); @@ -242,12 +255,12 @@ public function testFilterByWildCards($patterns, $expectedResults) { * @see https://issues.civicrm.org/jira/browse/CRM-14283 * * @param string $imageURL - * @param book $forceHttps + * @param bool $forceHttps * @param string $expected * * @dataProvider simplifyURLProvider */ - public function testSimplifyURL($imageURL, $forceHttps, $expected) { + public function testSimplifyURL(string $imageURL, bool $forceHttps, string $expected): void { $this->assertEquals( $expected, CRM_Utils_String::simplifyURL($imageURL, $forceHttps) @@ -258,18 +271,20 @@ public function testSimplifyURL($imageURL, $forceHttps, $expected) { * Used for testNormalizeImageURL above * * @return array + * @throws \CRM_Core_Exception + * @noinspection HttpUrlsUsage */ - public function simplifyURLProvider() { + public function simplifyURLProvider(): array { $config = CRM_Core_Config::singleton(); $urlParts = CRM_Utils_String::simpleParseUrl($config->userFrameworkBaseURL); $localDomain = $urlParts['host+port']; if (empty($localDomain)) { - throw new \Exception("Failed to determine local base URL"); + throw new CRM_Core_Exception('Failed to determine local base URL'); } $externalDomain = 'example.org'; // Ensure that $externalDomain really is different from $localDomain - if ($externalDomain == $localDomain) { + if ($externalDomain === $localDomain) { $externalDomain = 'example.net'; } @@ -295,14 +310,14 @@ public function simplifyURLProvider() { "http://$externalDomain/sites/default/files/coffee-mug.jpg", ], 'local URL' => [ - "/sites/default/files/coffee-mug.jpg", + '/sites/default/files/coffee-mug.jpg', FALSE, - "/sites/default/files/coffee-mug.jpg", + '/sites/default/files/coffee-mug.jpg', ], 'local URL without a forward slash' => [ - "sites/default/files/coffee-mug.jpg", + 'sites/default/files/coffee-mug.jpg', FALSE, - "/sites/default/files/coffee-mug.jpg", + '/sites/default/files/coffee-mug.jpg', ], 'empty input' => [ '', @@ -318,7 +333,7 @@ public function simplifyURLProvider() { * * @dataProvider parseURLProvider */ - public function testSimpleParseUrl($url, $expected) { + public function testSimpleParseUrl(string $url, array $expected): void { $this->assertEquals( $expected, CRM_Utils_String::simpleParseUrl($url) @@ -330,40 +345,40 @@ public function testSimpleParseUrl($url, $expected) { * * @return array */ - public function parseURLProvider() { + public function parseURLProvider(): array { return [ - "prototypical example" => [ - "https://example.com:8000/foo/bar/?id=1#fragment", + 'prototypical example' => [ + 'https://example.com:8000/foo/bar/?id=1#fragment', [ - 'host+port' => "example.com:8000", - 'path+query' => "/foo/bar/?id=1", + 'host+port' => 'example.com:8000', + 'path+query' => '/foo/bar/?id=1', ], ], - "default port example" => [ - "https://example.com/foo/bar/?id=1#fragment", + 'default port example' => [ + 'https://example.com/foo/bar/?id=1#fragment', [ - 'host+port' => "example.com", - 'path+query' => "/foo/bar/?id=1", + 'host+port' => 'example.com', + 'path+query' => '/foo/bar/?id=1', ], ], - "empty" => [ - "", + 'empty' => [ + '', [ - 'host+port' => "", - 'path+query' => "", + 'host+port' => '', + 'path+query' => '', ], ], - "path only" => [ - "/foo/bar/image.png", + 'path only' => [ + '/foo/bar/image.png', [ - 'host+port' => "", - 'path+query' => "/foo/bar/image.png", + 'host+port' => '', + 'path+query' => '/foo/bar/image.png', ], ], ]; } - public function purifyHTMLProvider() { + public function purifyHTMLProvider(): array { $tests = []; $tests[] = ['HOVER', 'HOVER']; $tests[] = ['hello', 'hello']; @@ -371,51 +386,51 @@ public function purifyHTMLProvider() { } /** - * Test ouput of purifyHTML + * Test output of purifyHTML + * * @param string $testString * @param string $expectedString + * * @dataProvider purifyHTMLProvider */ - public function testPurifyHTML($testString, $expectedString) { + public function testPurifyHTML(string $testString, string $expectedString): void { $this->assertEquals($expectedString, CRM_Utils_String::purifyHTML($testString)); } - public function getGoodSerializeExamples() { - $strs = []; - - $strs[] = ['a:1:{s:1:"a";s:1:"b";}']; - $strs[] = ['d:1.2;']; - $strs[] = ['s:3:"abc";']; - $strs[] = ['N;']; - $strs[] = ['a:7:{i:0;N;i:1;s:3:"abc";i:2;i:1;i:3;d:2.3;i:4;b:1;i:5;b:0;i:6;i:0;}']; - - return $strs; + public function getGoodSerializeExamples(): array { + $strings = []; + $strings[] = ['a:1:{s:1:"a";s:1:"b";}']; + $strings[] = ['d:1.2;']; + $strings[] = ['s:3:"abc";']; + $strings[] = ['N;']; + $strings[] = ['a:7:{i:0;N;i:1;s:3:"abc";i:2;i:1;i:3;d:2.3;i:4;b:1;i:5;b:0;i:6;i:0;}']; + return $strings; } /** * @param string $str * A safe serialized value. + * * @dataProvider getGoodSerializeExamples */ - public function testGoodSerialize($str) { + public function testGoodSerialize(string $str): void { $this->assertEquals(unserialize($str), CRM_Utils_String::unserialize($str)); } - public function getBadSerializeExamples() { - $strs = []; - - $strs[] = ['O:8:"stdClass":0:{}']; - $strs[] = ['O:9:"Exception":7:{s:10:"*message";s:3:"abc";s:17:"Exceptionstring";s:0:"";s:7:"*code";i:0;s:7:"*file";s:17:"Command line code";s:7:"*line";i:1;s:16:"Exceptiontrace";a:0:{}s:19:"Exceptionprevious";N;}']; - - return $strs; + public function getBadSerializeExamples(): array { + $strings = []; + $strings[] = ['O:8:"stdClass":0:{}']; + $strings[] = ['O:9:"Exception":7:{s:10:"*message";s:3:"abc";s:17:"ExceptionString";s:0:"";s:7:"*code";i:0;s:7:"*file";s:17:"Command line code";s:7:"*line";i:1;s:16:"ExceptionTrace";a:0:{}s:19:"ExceptionPrevious";N;}']; + return $strings; } /** * @param string $str * An unsafe serialized value. + * * @dataProvider getBadSerializeExamples */ - public function testBadSerializeExamples($str) { + public function testBadSerializeExamples(string $str): void { $this->assertFalse(CRM_Utils_String::unserialize($str)); } From 63a0726919a1a649ae3abd81a7ca6a01546cc332 Mon Sep 17 00:00:00 2001 From: Stephen Palmstrom Date: Thu, 12 Jan 2023 10:38:44 +0000 Subject: [PATCH 057/106] Issue 1984 - change $id to $contactID --- CRM/Core/BAO/UFGroup.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 03c38ba36c7a..3ccf9fe61da4 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -730,8 +730,8 @@ protected static function getCustomFields($ctype, $checkPermission = CRM_Core_Pe $checkPermission = CRM_Core_Permission::EDIT; } // Make the cache user specific by adding the ID to the key. - $id = CRM_Core_Session::getLoggedInContactID(); - $cacheKey = 'uf_group_custom_fields_' . $ctype . '_' . $id . '_' . (int) $checkPermission; + $contactId = CRM_Core_Session::getLoggedInContactID(); + $cacheKey = 'uf_group_custom_fields_' . $ctype . '_' . $contactId . '_' . (int) $checkPermission; if (!Civi::cache('metadata')->has($cacheKey)) { $customFields = CRM_Core_BAO_CustomField::getFieldsForImport($ctype, FALSE, FALSE, FALSE, $checkPermission, TRUE); @@ -922,7 +922,7 @@ public static function getEditHTML( if (!empty($_POST)) { $supressForm = CRM_Core_Config::singleton()->userSystem->suppressProfileFormErrors(); $template->assign('suppressForm', $supressForm); - } + } $templateFile = "CRM/Profile/Form/{$profileID}/Dynamic.tpl"; if (!$template->template_exists($templateFile)) { From 9dd72c2d5f104d6dd90acb7e9d0bced0ede39c8b Mon Sep 17 00:00:00 2001 From: Herb v/d Dool Date: Thu, 12 Jan 2023 12:04:29 -0500 Subject: [PATCH 058/106] dev/drupal#153 include name when fetching UFGroups so validation can use it --- CRM/Core/BAO/UFGroup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index e9bbdadb3499..2734474898b4 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -1672,7 +1672,7 @@ public static function getWeight($ufGroupId = NULL) { * array of ufgroups for a module */ public static function getModuleUFGroup($moduleName = NULL, $count = 0, $skipPermission = TRUE, $op = CRM_Core_Permission::VIEW, $returnFields = NULL) { - $selectFields = ['id', 'title', 'created_id', 'is_active', 'is_reserved', 'group_type', 'description']; + $selectFields = ['id', 'name', 'title', 'created_id', 'is_active', 'is_reserved', 'group_type', 'description']; if (CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_uf_group', 'frontend_title')) { $selectFields[] = 'frontend_title'; From 3864a38f48bab4fd138988d01cc35736fd27442f Mon Sep 17 00:00:00 2001 From: Aidan Saunders Date: Fri, 16 Dec 2022 09:46:01 +0000 Subject: [PATCH 059/106] Enhance metadata for OptionGroups Extracted from https://github.com/civicrm/civicrm-core/pull/25180 --- CRM/Core/DAO/OptionGroup.php | 25 +++++++++++++++++++++---- xml/schema/Core/OptionGroup.xml | 23 ++++++++++++++++++++--- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/CRM/Core/DAO/OptionGroup.php b/CRM/Core/DAO/OptionGroup.php index 0b6a0d2de758..9f909157efc1 100644 --- a/CRM/Core/DAO/OptionGroup.php +++ b/CRM/Core/DAO/OptionGroup.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/OptionGroup.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:6d1ca6dc8aa693e7b26bb19b731b0b55) + * (GenCodeChecksum:1d5fad72032ebfdfdce93a4b29f97542) */ /** @@ -174,12 +174,15 @@ public static function &fields() { 'entity' => 'OptionGroup', 'bao' => 'CRM_Core_BAO_OptionGroup', 'localizable' => 0, + 'html' => [ + 'type' => 'Text', + ], 'add' => '1.5', ], 'title' => [ 'name' => 'title', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Option Group title'), + 'title' => ts('Option Group Title'), 'description' => ts('Option Group title.'), 'maxlength' => 255, 'size' => CRM_Utils_Type::HUGE, @@ -188,6 +191,9 @@ public static function &fields() { 'entity' => 'OptionGroup', 'bao' => 'CRM_Core_BAO_OptionGroup', 'localizable' => 1, + 'html' => [ + 'type' => 'Text', + ], 'add' => '1.5', ], 'description' => [ @@ -200,6 +206,9 @@ public static function &fields() { 'entity' => 'OptionGroup', 'bao' => 'CRM_Core_BAO_OptionGroup', 'localizable' => 1, + 'html' => [ + 'type' => 'Text', + ], 'add' => '1.5', ], 'data_type' => [ @@ -222,7 +231,7 @@ public static function &fields() { 'is_reserved' => [ 'name' => 'is_reserved', 'type' => CRM_Utils_Type::T_BOOLEAN, - 'title' => ts('Option Group Is Reserved?'), + 'title' => ts('Option Group Is Reserved'), 'description' => ts('Is this a predefined system option group (i.e. it can not be deleted)?'), 'required' => TRUE, 'where' => 'civicrm_option_group.is_reserved', @@ -231,12 +240,16 @@ public static function &fields() { 'entity' => 'OptionGroup', 'bao' => 'CRM_Core_BAO_OptionGroup', 'localizable' => 0, + 'html' => [ + 'type' => 'CheckBox', + 'label' => ts("Reserved"), + ], 'add' => '1.5', ], 'is_active' => [ 'name' => 'is_active', 'type' => CRM_Utils_Type::T_BOOLEAN, - 'title' => ts('Option Group Is Active?'), + 'title' => ts('Enabled'), 'description' => ts('Is this option group active?'), 'required' => TRUE, 'where' => 'civicrm_option_group.is_active', @@ -263,6 +276,10 @@ public static function &fields() { 'entity' => 'OptionGroup', 'bao' => 'CRM_Core_BAO_OptionGroup', 'localizable' => 0, + 'html' => [ + 'type' => 'CheckBox', + 'label' => ts("Locked"), + ], 'add' => '4.5', ], 'option_value_fields' => [ diff --git a/xml/schema/Core/OptionGroup.xml b/xml/schema/Core/OptionGroup.xml index f4e3f6203127..25469867cbd0 100644 --- a/xml/schema/Core/OptionGroup.xml +++ b/xml/schema/Core/OptionGroup.xml @@ -29,15 +29,21 @@ true Option group name. Used as selection key by class properties which lookup options in civicrm_option_value. 1.5 + + Text + title - Option Group title + Option Group Title varchar 255 true Option Group title. 1.5 + + Text + description @@ -46,6 +52,9 @@ true Option group description. 1.5 + + Text + data_type @@ -60,16 +69,20 @@ is_reserved - Option Group Is Reserved? + Option Group Is Reserved boolean 1 true Is this a predefined system option group (i.e. it can not be deleted)? 1.5 + + CheckBox + + is_active - Option Group Is Active? + Enabled boolean 1 true @@ -88,6 +101,10 @@ true A lock to remove the ability to add new options via the UI. 4.5 + + CheckBox + + option_value_fields From 2f1cb5071bda3e4233c570c8bba17ba7eab76e6b Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Thu, 12 Jan 2023 20:52:24 +0000 Subject: [PATCH 060/106] (REF) Fix field name when doing DAO find in MergerTest --- tests/phpunit/CRM/Dedupe/MergerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/Dedupe/MergerTest.php b/tests/phpunit/CRM/Dedupe/MergerTest.php index 9443d792dc40..0201b0d1fe2b 100644 --- a/tests/phpunit/CRM/Dedupe/MergerTest.php +++ b/tests/phpunit/CRM/Dedupe/MergerTest.php @@ -170,7 +170,7 @@ public function testBatchMergeSelectedDuplicates(): void { $dao = new CRM_Dedupe_DAO_DedupeRuleGroup(); $dao->contact_type = 'Individual'; $dao->name = 'IndividualSupervised'; - $dao->is_default = 1; + $dao->is_reserved = 1; $dao->find(TRUE); $foundDupes = CRM_Dedupe_Finder::dupesInGroup($dao->id, $this->_groupId); @@ -240,7 +240,7 @@ public function testBatchMergeAllDuplicates() { $dao = new CRM_Dedupe_DAO_DedupeRuleGroup(); $dao->contact_type = 'Individual'; $dao->name = 'IndividualSupervised'; - $dao->is_default = 1; + $dao->is_reserved = 1; $dao->find(TRUE); $foundDupes = CRM_Dedupe_Finder::dupesInGroup($dao->id, $this->_groupId); From f20ecd3f6fc06d81e160e2e2b3c3079ff4daa9fe Mon Sep 17 00:00:00 2001 From: John Kingsnorth Date: Fri, 13 Jan 2023 12:06:54 +0000 Subject: [PATCH 061/106] PHP 8.1 compatibility improvement --- CRM/Logging/Schema.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Logging/Schema.php b/CRM/Logging/Schema.php index bbe7801f215a..f1f5847cc4a2 100644 --- a/CRM/Logging/Schema.php +++ b/CRM/Logging/Schema.php @@ -743,7 +743,7 @@ public function columnsWithDiffSpecs($civiTable, $logTable) { } elseif ( $civiTableSpecs[$col]['COLUMN_DEFAULT'] != ($logTableSpecs[$col]['COLUMN_DEFAULT'] ?? NULL) - && !stristr($civiTableSpecs[$col]['COLUMN_DEFAULT'], 'timestamp') + && !stristr(($civiTableSpecs[$col]['COLUMN_DEFAULT'] ?? ''), 'timestamp') && !($civiTableSpecs[$col]['COLUMN_DEFAULT'] === NULL && ($logTableSpecs[$col]['COLUMN_DEFAULT'] ?? NULL) === 'NULL') ) { // if default property is different, and its not about a timestamp column, consider it From e19f1397e661c345efaee39e9493c3249022ad16 Mon Sep 17 00:00:00 2001 From: Aidan Saunders Date: Fri, 13 Jan 2023 16:43:16 +0000 Subject: [PATCH 062/106] Fix failure when changing processor type on add Payment Processor screen --- CRM/Admin/Form/PaymentProcessor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Admin/Form/PaymentProcessor.php b/CRM/Admin/Form/PaymentProcessor.php index 1700337313ee..2e6a3b99d110 100644 --- a/CRM/Admin/Form/PaymentProcessor.php +++ b/CRM/Admin/Form/PaymentProcessor.php @@ -114,13 +114,13 @@ public function preProcess() { $this->assign('ppTypeName', $this->_paymentProcessorDAO->name); if ($this->_id) { - $refreshURL = CRM_Utils_System::url('civicrm/admin/paymentProcessor', + $refreshURL = CRM_Utils_System::url('civicrm/admin/paymentProcessor/edit', "reset=1&action=update&id={$this->_id}", FALSE, NULL, FALSE ); } else { - $refreshURL = CRM_Utils_System::url('civicrm/admin/paymentProcessor', + $refreshURL = CRM_Utils_System::url('civicrm/admin/paymentProcessor/edit', "reset=1&action=add", FALSE, NULL, FALSE ); From e265090f5bd78ccab112f5464536a67251f92bec Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Fri, 13 Jan 2023 19:41:04 +0000 Subject: [PATCH 063/106] [REF][PHP8.2] Avoid dynamic properties in api_v3_ContactTypeTest --- tests/phpunit/api/v3/ContactTypeTest.php | 37 +++++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/api/v3/ContactTypeTest.php b/tests/phpunit/api/v3/ContactTypeTest.php index fe34b4d73116..6406f5817234 100644 --- a/tests/phpunit/api/v3/ContactTypeTest.php +++ b/tests/phpunit/api/v3/ContactTypeTest.php @@ -16,6 +16,21 @@ class api_v3_ContactTypeTest extends CiviUnitTestCase { protected $_apiversion; + /** + * @var string + */ + protected $subTypeIndividual; + + /** + * @var string + */ + protected $subTypeOrganization; + + /** + * @var string + */ + protected $subTypeHousehold; + public function setUp(): void { parent::setUp(); $this->useTransaction(TRUE); @@ -26,7 +41,7 @@ public function setUp(): void { 'parent_id' => 1, 'is_active' => 1, ]; - $result = CRM_Contact_BAO_ContactType::add($params); + CRM_Contact_BAO_ContactType::add($params); $this->subTypeIndividual = $params['name']; $params = [ @@ -36,7 +51,7 @@ public function setUp(): void { 'parent_id' => 3, 'is_active' => 1, ]; - $result = CRM_Contact_BAO_ContactType::add($params); + CRM_Contact_BAO_ContactType::add($params); $this->subTypeOrganization = $params['name']; $params = [ @@ -46,7 +61,7 @@ public function setUp(): void { 'parent_id' => 2, 'is_active' => 1, ]; - $result = CRM_Contact_BAO_ContactType::add($params); + CRM_Contact_BAO_ContactType::add($params); $this->subTypeHousehold = $params['name']; } @@ -111,7 +126,7 @@ public function testContactAddInvalidData($version) { 'contact_type' => 'Individual', 'contact_sub_type' => $this->subTypeHousehold, ]; - $contact = $this->callAPIFailure('contact', 'create', $contactParams); + $this->callAPIFailure('contact', 'create', $contactParams); // check for Type:Organization Subtype:sub_individual $contactParams = [ @@ -119,7 +134,7 @@ public function testContactAddInvalidData($version) { 'contact_type' => 'Organization', 'contact_sub_type' => $this->subTypeIndividual, ]; - $contact = $this->callAPIFailure('contact', 'create', $contactParams); + $this->callAPIFailure('contact', 'create', $contactParams); } /** @@ -214,7 +229,7 @@ public function testContactUpdateNoSubtypeInvalid($version) { 'contact_type' => 'Individual', 'contact_sub_type' => $this->subTypeHousehold, ]; - $updateContact = $this->callAPIFailure('contact', 'create', $updateParams); + $this->callAPIFailure('contact', 'create', $updateParams); $params = [ 'contact_id' => $contact['id'], ]; @@ -233,7 +248,7 @@ public function testContactUpdateNoSubtypeInvalid($version) { 'contact_type' => 'Organization', 'contact_sub_type' => $this->subTypeIndividual, ]; - $updateContact = $this->callAPIFailure('contact', 'create', $updateParams); + $this->callAPIFailure('contact', 'create', $updateParams); $params = [ 'contact_id' => $contact['id'], ]; @@ -256,7 +271,7 @@ public function testContactUpdateSubtypeValid($version) { 'parent_id' => 1, 'is_active' => 1, ]; - $getSubtype = CRM_Contact_BAO_ContactType::add($params); + CRM_Contact_BAO_ContactType::add($params); $subtype = $params['name']; // check for Type:Individual subype:sub_individual @@ -299,7 +314,7 @@ public function testContactUpdateSubtypeValid($version) { 'parent_id' => 3, 'is_active' => 1, ]; - $getSubtype = CRM_Contact_BAO_ContactType::add($params); + CRM_Contact_BAO_ContactType::add($params); $subtype = $params['name']; // check for Type:Organization subype:sub_organization @@ -357,7 +372,7 @@ public function testContactUpdateSubtypeInvalid($version) { 'contact_type' => 'Individual', 'contact_sub_type' => $this->subTypeHousehold, ]; - $updateContact = $this->callAPIFailure('contact', 'create', $updateParams); + $this->callAPIFailure('contact', 'create', $updateParams); $params = [ 'contact_id' => $contact['id'], ]; @@ -376,7 +391,7 @@ public function testContactUpdateSubtypeInvalid($version) { 'contact_id' => $contact['id'], 'contact_sub_type' => $this->subTypeIndividual, ]; - $updateContact = $this->callAPIFailure('contact', 'create', $updateParams); + $this->callAPIFailure('contact', 'create', $updateParams); $params = [ 'contact_id' => $contact['id'], ]; From 08c259c3a643f788d62ddf801dd085070f8c83b7 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Fri, 13 Jan 2023 19:48:48 +0000 Subject: [PATCH 064/106] [REF][PHP8.2] Move to standard varaibles in CRM_Price_BAO_PriceFieldValueTest to avoid dynamic properties --- tests/phpunit/CRM/Price/BAO/PriceFieldValueTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/CRM/Price/BAO/PriceFieldValueTest.php b/tests/phpunit/CRM/Price/BAO/PriceFieldValueTest.php index d229b86a00a7..6dc246104333 100644 --- a/tests/phpunit/CRM/Price/BAO/PriceFieldValueTest.php +++ b/tests/phpunit/CRM/Price/BAO/PriceFieldValueTest.php @@ -41,10 +41,10 @@ public function testEmptyStringLabel() { ]; $price_set = $this->callAPISuccess('price_set', 'create', $priceSetParams); - $this->priceSetID = $price_set['id']; + $priceSetID = $price_set['id']; $priceFieldParams = [ - 'price_set_id' => $this->priceSetID, + 'price_set_id' => $priceSetID, 'name' => 'grassvariety', 'label' => 'Grass Variety', 'html_type' => 'Text', @@ -52,15 +52,15 @@ public function testEmptyStringLabel() { 'is_active' => 1, ]; $priceField = $this->callAPISuccess('price_field', 'create', $priceFieldParams); - $this->priceFieldID = $priceField['id']; - $this->_params = [ - 'price_field_id' => $this->priceFieldID, + $priceFieldID = $priceField['id']; + $params = [ + 'price_field_id' => $priceFieldID, 'name' => 'rye_grass', 'label' => '', 'amount' => 1, 'financial_type_id' => 1, ]; - $priceFieldValue = CRM_Price_BAO_PriceFieldValue::create($this->_params); + $priceFieldValue = CRM_Price_BAO_PriceFieldValue::create($params); $priceFieldValue->find(TRUE); $this->assertEquals('', $priceFieldValue->label); } From f9eef6fd05e271b553b83413913ca11d0b941206 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Fri, 13 Jan 2023 20:00:46 +0000 Subject: [PATCH 065/106] Remove error suppression operator from test --- tests/phpunit/CRM/Dedupe/MergerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/Dedupe/MergerTest.php b/tests/phpunit/CRM/Dedupe/MergerTest.php index 0201b0d1fe2b..9aad35e896b8 100644 --- a/tests/phpunit/CRM/Dedupe/MergerTest.php +++ b/tests/phpunit/CRM/Dedupe/MergerTest.php @@ -195,7 +195,7 @@ public function testBatchMergeSelectedDuplicates(): void { $object->set('rgid', $dao->id); $object->set('action', CRM_Core_Action::UPDATE); $object->setEmbedded(TRUE); - @$object->run(); + $object->run(); // Retrieve pairs from prev next cache table $select = ['pn.is_selected' => 'is_selected']; @@ -265,7 +265,7 @@ public function testBatchMergeAllDuplicates() { $object->set('rgid', $dao->id); $object->set('action', CRM_Core_Action::UPDATE); $object->setEmbedded(TRUE); - @$object->run(); + $object->run(); // Retrieve pairs from prev next cache table $select = ['pn.is_selected' => 'is_selected']; From 84797c07459545e4a534f52d7046e199e07edeb6 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Fri, 13 Jan 2023 20:04:59 +0000 Subject: [PATCH 066/106] [REF][PHP8.2] Use const instead of dynamic property api_v3_CaseTypeTest --- tests/phpunit/api/v3/CaseTypeTest.php | 62 +++++++++++++-------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/phpunit/api/v3/CaseTypeTest.php b/tests/phpunit/api/v3/CaseTypeTest.php index 5421b1f47ead..8a67826846b0 100644 --- a/tests/phpunit/api/v3/CaseTypeTest.php +++ b/tests/phpunit/api/v3/CaseTypeTest.php @@ -15,37 +15,37 @@ */ class api_v3_CaseTypeTest extends CiviCaseTestCase { - public function setUp(): void { - $this->quickCleanup(['civicrm_case_type']); - parent::setUp(); - - $this->fixtures['Application_with_Definition'] = [ - 'title' => 'Application with Definition', - 'name' => 'Application_with_Definition', - 'is_active' => 1, - 'weight' => 4, - 'definition' => [ - 'activityTypes' => [ - ['name' => 'First act'], - ], - 'activitySets' => [ - [ - 'name' => 'set1', - 'label' => 'Label 1', - 'timeline' => 1, - 'activityTypes' => [ - ['name' => 'Open Case', 'status' => 'Completed'], - ], + const APPLICATION_WITH_DEFINITION_PARAMS = [ + 'title' => 'Application with Definition', + 'name' => 'Application_with_Definition', + 'is_active' => 1, + 'weight' => 4, + 'definition' => [ + 'activityTypes' => [ + ['name' => 'First act'], + ], + 'activitySets' => [ + [ + 'name' => 'set1', + 'label' => 'Label 1', + 'timeline' => 1, + 'activityTypes' => [ + ['name' => 'Open Case', 'status' => 'Completed'], ], ], - 'timelineActivityTypes' => [ - ['name' => 'Open Case', 'status' => 'Completed'], - ], - 'caseRoles' => [ - ['name' => 'First role', 'creator' => 1, 'manager' => 1], - ], ], - ]; + 'timelineActivityTypes' => [ + ['name' => 'Open Case', 'status' => 'Completed'], + ], + 'caseRoles' => [ + ['name' => 'First role', 'creator' => 1, 'manager' => 1], + ], + ], + ]; + + public function setUp(): void { + $this->quickCleanup(['civicrm_case_type']); + parent::setUp(); } /** @@ -174,7 +174,7 @@ public function testCaseTypeDelete_New() { */ public function testCaseTypeCreateWithDefinition() { // Create Case Type - $params = $this->fixtures['Application_with_Definition']; + $params = self::APPLICATION_WITH_DEFINITION_PARAMS; $result = $this->callAPISuccess('CaseType', 'create', $params); $id = $result['id']; @@ -193,7 +193,7 @@ public function testCaseTypeCreateWithDefinition() { */ public function testCaseTypeDelete_InUse() { // Create Case Type - $params = $this->fixtures['Application_with_Definition']; + $params = self::APPLICATION_WITH_DEFINITION_PARAMS; $createCaseType = $this->callAPISuccess('CaseType', 'create', $params); $createCase = $this->callAPISuccess('Case', 'create', [ @@ -244,7 +244,7 @@ public function testCaseStatusByCaseType() { public function testDefinitionGroups() { $gid1 = $this->groupCreate(['name' => 'testDefinitionGroups1', 'title' => 'testDefinitionGroups1']); $gid2 = $this->groupCreate(['name' => 'testDefinitionGroups2', 'title' => 'testDefinitionGroups2']); - $def = $this->fixtures['Application_with_Definition']; + $def = self::APPLICATION_WITH_DEFINITION_PARAMS; $def['definition']['caseRoles'][] = [ 'name' => 'Second role', 'groups' => ['testDefinitionGroups1', 'testDefinitionGroups2'], From d1047f337bd8447a74f5710fcc032d8c6f5f2f41 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Sat, 14 Jan 2023 17:33:32 +0000 Subject: [PATCH 067/106] [REF][PHP8.2] Avoid dynamic properties in CRM_Contact_BAO_ContactType_RelationshipTest --- .../BAO/ContactType/RelationshipTest.php | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php b/tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php index 4419de4dcd50..525ea7a8fa87 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php @@ -6,6 +6,24 @@ */ class CRM_Contact_BAO_ContactType_RelationshipTest extends CiviUnitTestCase { + /** + * Name of contact subtype + * @var string + */ + private $student; + + /** + * Name of contact subtype + * @var string + */ + private $parent; + + /** + * Name of contact subtype + * @var string + */ + private $sponsor; + public function setUp(): void { parent::setUp(); @@ -17,7 +35,7 @@ public function setUp(): void { 'parent_id' => 1, 'is_active' => 1, ]; - $result = CRM_Contact_BAO_ContactType::add($params); + CRM_Contact_BAO_ContactType::add($params); $this->student = $params['name']; $params = [ @@ -27,7 +45,7 @@ public function setUp(): void { 'parent_id' => 1, 'is_active' => 1, ]; - $result = CRM_Contact_BAO_ContactType::add($params); + CRM_Contact_BAO_ContactType::add($params); $this->parent = $params['name']; $params = [ @@ -37,7 +55,7 @@ public function setUp(): void { 'parent_id' => 3, 'is_active' => 1, ]; - $result = CRM_Contact_BAO_ContactType::add($params); + CRM_Contact_BAO_ContactType::add($params); $this->sponsor = $params['name']; //create contacts @@ -46,7 +64,7 @@ public function setUp(): void { 'last_name' => 'Grant', 'contact_type' => 'Individual', ]; - $this->individual = $this->individualCreate($params); + $this->individualCreate($params); $params = [ 'first_name' => 'Bill', @@ -54,7 +72,7 @@ public function setUp(): void { 'contact_type' => 'Individual', 'contact_sub_type' => $this->student, ]; - $this->indivi_student = $this->individualCreate($params); + $this->individualCreate($params); $params = [ 'first_name' => 'Alen', @@ -62,20 +80,20 @@ public function setUp(): void { 'contact_type' => 'Individual', 'contact_sub_type' => $this->parent, ]; - $this->indivi_parent = $this->individualCreate($params); + $this->individualCreate($params); $params = [ 'organization_name' => 'Compumentor', 'contact_type' => 'Organization', ]; - $this->organization = $this->organizationCreate($params); + $this->organizationCreate($params); $params = [ 'organization_name' => 'Conservation Corp', 'contact_type' => 'Organization', 'contact_sub_type' => $this->sponsor, ]; - $this->organization_sponsor = $this->organizationCreate($params); + $this->organizationCreate($params); } public function tearDown(): void { From ca367b107819f5e234717f658398408433d1cfa2 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Sun, 15 Jan 2023 10:32:59 +0000 Subject: [PATCH 068/106] [REF][PHP8.2] Avoid dynamic properties in module tests --- tests/phpunit/CRM/Extension/Manager/ModuleTest.php | 10 ++++++++++ tests/phpunit/CRM/Extension/Manager/ModuleUpgTest.php | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/tests/phpunit/CRM/Extension/Manager/ModuleTest.php b/tests/phpunit/CRM/Extension/Manager/ModuleTest.php index 59d1de4d062f..3599dbe35018 100644 --- a/tests/phpunit/CRM/Extension/Manager/ModuleTest.php +++ b/tests/phpunit/CRM/Extension/Manager/ModuleTest.php @@ -6,6 +6,16 @@ */ class CRM_Extension_Manager_ModuleTest extends CiviUnitTestCase { + /** + * @var string + */ + protected $basedir; + + /** + * @var \CRM_Extension_System + */ + protected $system; + public function setUp():void { parent::setUp(); // $query = "INSERT INTO civicrm_domain ( name, version ) VALUES ( 'domain', 3 )"; diff --git a/tests/phpunit/CRM/Extension/Manager/ModuleUpgTest.php b/tests/phpunit/CRM/Extension/Manager/ModuleUpgTest.php index 16eb99601169..b2c67d66fbbd 100644 --- a/tests/phpunit/CRM/Extension/Manager/ModuleUpgTest.php +++ b/tests/phpunit/CRM/Extension/Manager/ModuleUpgTest.php @@ -6,6 +6,11 @@ */ class CRM_Extension_Manager_ModuleUpgTest extends CiviUnitTestCase { + /** + * @var string + */ + protected $basedir; + /** * @var \CRM_Extension_System */ From 2a4832b31ffb484718607584683ddba87cbb6a9e Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Sun, 15 Jan 2023 11:20:16 +0000 Subject: [PATCH 069/106] (REF) Tidy up properties in CRM_Core_ResourcesTest --- tests/phpunit/CRM/Core/ResourcesTest.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/CRM/Core/ResourcesTest.php b/tests/phpunit/CRM/Core/ResourcesTest.php index ac9ccda08860..ca838ee6862b 100644 --- a/tests/phpunit/CRM/Core/ResourcesTest.php +++ b/tests/phpunit/CRM/Core/ResourcesTest.php @@ -40,7 +40,7 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { public function setUp(): void { parent::setUp(); - list ($this->basedir, $this->container, $this->mapper) = $this->_createMapper(); + $this->mapper = $this->createMapper(); $cache = new CRM_Utils_Cache_Arraycache([]); $this->res = new CRM_Core_Resources($this->mapper, new CRM_Core_Resources_Strings($cache), NULL); $this->res->setCacheCode('resTest'); @@ -427,22 +427,18 @@ public function ajaxModeData() { } /** - * @param CRM_Utils_Cache_Interface $cache - * @param string $cacheKey - * - * @return array - * [string $basedir, CRM_Extension_Container_Interface, CRM_Extension_Mapper] + * @return CRM_Extension_Mapper */ - public function _createMapper(CRM_Utils_Cache_Interface $cache = NULL, $cacheKey = NULL) { + private function createMapper() { $basedir = rtrim($this->createTempDir('ext-'), '/'); mkdir("$basedir/com.example.ext"); mkdir("$basedir/com.example.ext/js"); file_put_contents("$basedir/com.example.ext/info.xml", "oddball"); file_put_contents("$basedir/com.example.ext/js/example.js", "alert('Boo!');"); // not needed for now // file_put_contents("$basedir/weird/bar/oddball.php", " Date: Sun, 15 Jan 2023 11:36:27 +0000 Subject: [PATCH 070/106] (REF) Tidy up of CRM_Extension_ManagerTest --- tests/phpunit/CRM/Extension/ManagerTest.php | 48 +++++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/tests/phpunit/CRM/Extension/ManagerTest.php b/tests/phpunit/CRM/Extension/ManagerTest.php index 9e3beff8b2e6..c85a5e5c1192 100644 --- a/tests/phpunit/CRM/Extension/ManagerTest.php +++ b/tests/phpunit/CRM/Extension/ManagerTest.php @@ -17,9 +17,24 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { const TESTING_TYPE = 'report'; const OTHER_TESTING_TYPE = 'module'; + /** + * @var string + */ + protected $basedir; + + /** + * @var CRM_Extension_Container_Basic + */ + protected $container; + + /** + * @var CRM_Extension_Mapper + */ + protected $mapper; + public function setUp(): void { parent::setUp(); - list ($this->basedir, $this->container) = $this->_createContainer(); + list($this->basedir, $this->container) = $this->createContainer(); $this->mapper = new CRM_Extension_Mapper($this->container); } @@ -368,7 +383,7 @@ public function testReplace_Unknown() { ]); $this->assertEquals('unknown', $manager->getStatus('test.newextension')); - $this->download = $this->_createDownload('test.newextension', 'newextension'); + $download = $this->createDownload('test.newextension', 'newextension'); $testingTypeManager // no data to replace @@ -378,7 +393,7 @@ public function testReplace_Unknown() { // no data to replace ->expects($this->never()) ->method('onPostReplace'); - $manager->replace($this->download); + $manager->replace($download); $this->assertEquals('uninstalled', $manager->getStatus('test.newextension')); $this->assertTrue(file_exists("{$this->basedir}/test.newextension/info.xml")); $this->assertTrue(file_exists("{$this->basedir}/test.newextension/newextension.php")); @@ -397,7 +412,7 @@ public function testReplace_Uninstalled() { $this->assertEquals('uninstalled', $manager->getStatus('test.whiz.bang')); $this->assertEquals('oddball', $this->mapper->keyToInfo('test.whiz.bang')->file); - $this->download = $this->_createDownload('test.whiz.bang', 'newextension'); + $download = $this->createDownload('test.whiz.bang', 'newextension'); $testingTypeManager // no data to replace @@ -407,7 +422,7 @@ public function testReplace_Uninstalled() { // no data to replace ->expects($this->never()) ->method('onPostReplace'); - $manager->replace($this->download); + $manager->replace($download); $this->assertEquals('uninstalled', $manager->getStatus('test.whiz.bang')); $this->assertTrue(file_exists("{$this->basedir}/weird/whizbang/info.xml")); $this->assertTrue(file_exists("{$this->basedir}/weird/whizbang/newextension.php")); @@ -435,7 +450,7 @@ public function testReplace_Installed() { $this->assertEquals('oddball', $this->mapper->keyToInfo('test.whiz.bang')->file); $this->assertDBQuery('oddball', 'SELECT file FROM civicrm_extension WHERE full_name ="test.whiz.bang"'); - $this->download = $this->_createDownload('test.whiz.bang', 'newextension'); + $download = $this->createDownload('test.whiz.bang', 'newextension'); $testingTypeManager ->expects($this->once()) @@ -443,7 +458,7 @@ public function testReplace_Installed() { $testingTypeManager ->expects($this->once()) ->method('onPostReplace'); - $manager->replace($this->download); + $manager->replace($download); $this->assertEquals('installed', $manager->getStatus('test.whiz.bang')); $this->assertTrue(file_exists("{$this->basedir}/weird/whizbang/info.xml")); $this->assertTrue(file_exists("{$this->basedir}/weird/whizbang/newextension.php")); @@ -478,7 +493,7 @@ public function testReplace_InstalledMissing() { $this->assertEquals('installed-missing', $manager->getStatus('test.whiz.bang')); // download and reinstall - $this->download = $this->_createDownload('test.whiz.bang', 'newextension'); + $download = $this->createDownload('test.whiz.bang', 'newextension'); $testingTypeManager ->expects($this->once()) @@ -486,7 +501,7 @@ public function testReplace_InstalledMissing() { $testingTypeManager ->expects($this->once()) ->method('onPostReplace'); - $manager->replace($this->download); + $manager->replace($download); $this->assertEquals('installed', $manager->getStatus('test.whiz.bang')); $this->assertTrue(file_exists("{$this->basedir}/test.whiz.bang/info.xml")); $this->assertTrue(file_exists("{$this->basedir}/test.whiz.bang/newextension.php")); @@ -500,18 +515,13 @@ public function testReplace_InstalledMissing() { * @return CRM_Extension_Manager */ public function _createManager($typeManagers) { - //list ($basedir, $c) = $this->_createContainer(); - $mapper = new CRM_Extension_Mapper($this->container); return new CRM_Extension_Manager($this->container, $this->container, $this->mapper, $typeManagers); } /** - * @param CRM_Utils_Cache_Interface $cache - * @param null $cacheKey - * * @return array */ - public function _createContainer(CRM_Utils_Cache_Interface $cache = NULL, $cacheKey = NULL) { + private function createContainer() { $basedir = $this->createTempDir('ext-'); mkdir("$basedir/weird"); mkdir("$basedir/weird/foobar"); @@ -523,17 +533,17 @@ public function _createContainer(CRM_Utils_Cache_Interface $cache = NULL, $cache mkdir("$basedir/weird/downstream"); file_put_contents("$basedir/weird/downstream/info.xml", "oddballtest.foo.bar"); // not needed for now // file_put_contents("$basedir/weird/downstream/oddball.php", "createTempDir('ext-dl-'); file_put_contents("$basedir/info.xml", "$file"); file_put_contents("$basedir/$file.php", " Date: Sun, 15 Jan 2023 16:26:44 +0000 Subject: [PATCH 071/106] [REF][PHP8.2] Avoid dynamic properties in api_v3_GroupOrganizationTest --- tests/phpunit/api/v3/GroupOrganizationTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/phpunit/api/v3/GroupOrganizationTest.php b/tests/phpunit/api/v3/GroupOrganizationTest.php index aed10a7ea4eb..dc75418b05f6 100644 --- a/tests/phpunit/api/v3/GroupOrganizationTest.php +++ b/tests/phpunit/api/v3/GroupOrganizationTest.php @@ -18,6 +18,16 @@ class api_v3_GroupOrganizationTest extends CiviUnitTestCase { protected $_apiversion; + /** + * @var int + */ + private $_groupID; + + /** + * @var int + */ + private $_orgID; + /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. From cbf33c9423a8dff51ca04f1fd884c211124cc2e7 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 15 Jan 2023 20:13:35 +0000 Subject: [PATCH 072/106] [REF][PHP8.2] Fix PHP8.2 creation of dynamic properties in the elavon tests and Payment Processor class --- ext/elavon/CRM/Core/Payment/Elavon.php | 7 +++++++ .../tests/phpunit/CRM/Core/Payment/ElavonTest.php | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ext/elavon/CRM/Core/Payment/Elavon.php b/ext/elavon/CRM/Core/Payment/Elavon.php index 32f6039b61da..3615ccf621b6 100644 --- a/ext/elavon/CRM/Core/Payment/Elavon.php +++ b/ext/elavon/CRM/Core/Payment/Elavon.php @@ -27,6 +27,13 @@ */ class CRM_Core_Payment_Elavon extends CRM_Core_Payment { + /** + * Payment Processor Mode + * either test or live + * @var string + */ + protected $_mode; + /** * Constructor. * diff --git a/ext/elavon/tests/phpunit/CRM/Core/Payment/ElavonTest.php b/ext/elavon/tests/phpunit/CRM/Core/Payment/ElavonTest.php index c6a785d390c4..76ca53526e9b 100644 --- a/ext/elavon/tests/phpunit/CRM/Core/Payment/ElavonTest.php +++ b/ext/elavon/tests/phpunit/CRM/Core/Payment/ElavonTest.php @@ -25,6 +25,18 @@ class CRM_Core_Payment_ElavonTest extends \PHPUnit\Framework\TestCase implements use \Civi\Test\GuzzleTestTrait; use \Civi\Test\Api3TestTrait; + /** + * Instance of CRM_Core_Payment_Elavon|null + * @var CRM_Core_Payment_Elavon + */ + protected $processor; + + /** + * Created Object Ids + * @var array + */ + public $ids; + /** * Setup used when HeadlessInterface is implemented. * From a8a08b20a29c3919317971691cc1e44d911f0f24 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 15 Jan 2023 20:19:12 +0000 Subject: [PATCH 073/106] [REF][PHP8.2] Fix Eway Single Payment Processor extension for dynamic properties --- ext/ewaysingle/CRM/Core/Payment/eWAY.php | 7 +++++++ .../tests/phpunit/CRM/Core/Payment/EwayTest.php | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ext/ewaysingle/CRM/Core/Payment/eWAY.php b/ext/ewaysingle/CRM/Core/Payment/eWAY.php index a36c28c5ec00..9a8669181781 100644 --- a/ext/ewaysingle/CRM/Core/Payment/eWAY.php +++ b/ext/ewaysingle/CRM/Core/Payment/eWAY.php @@ -93,6 +93,13 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { */ protected $guzzleClient; + /** + * Payment Processor Mode + * either test or live + * @var string + */ + protected $_mode; + /** * ******************************************************* * Constructor diff --git a/ext/ewaysingle/tests/phpunit/CRM/Core/Payment/EwayTest.php b/ext/ewaysingle/tests/phpunit/CRM/Core/Payment/EwayTest.php index d0f77adc2d91..f22c9bcda26e 100644 --- a/ext/ewaysingle/tests/phpunit/CRM/Core/Payment/EwayTest.php +++ b/ext/ewaysingle/tests/phpunit/CRM/Core/Payment/EwayTest.php @@ -23,6 +23,18 @@ class CRM_Core_Payment_EwayTest extends \PHPUnit\Framework\TestCase implements H use \Civi\Test\GuzzleTestTrait; use \Civi\Test\Api3TestTrait; + /** + * Instance of CRM_Core_Payment_eWay|null + * @var CRM_Core_Payment_eWay + */ + protected $processor; + + /** + * Created Object Ids + * @var array + */ + public $ids; + public function setUpHeadless() { // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile(). // See: https://docs.civicrm.org/dev/en/latest/testing/phpunit/#civitest From 0ff88c67cc3507b7de3361c65958479c4ec57fdc Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 15 Jan 2023 20:26:58 +0000 Subject: [PATCH 074/106] [REF][PHP8.2] Fix creation of dynamic properties in Payflow Pro extension --- ext/payflowpro/CRM/Core/Payment/PayflowPro.php | 7 +++++++ .../phpunit/CRM/Core/Payment/PayflowProTest.php | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ext/payflowpro/CRM/Core/Payment/PayflowPro.php b/ext/payflowpro/CRM/Core/Payment/PayflowPro.php index acd64bb02132..0fad94fce8a8 100644 --- a/ext/payflowpro/CRM/Core/Payment/PayflowPro.php +++ b/ext/payflowpro/CRM/Core/Payment/PayflowPro.php @@ -21,6 +21,13 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { */ protected $guzzleClient; + /** + * Payment Processor Mode + * either test or live + * @var string + */ + protected $_mode; + /** * Constructor * diff --git a/ext/payflowpro/tests/phpunit/CRM/Core/Payment/PayflowProTest.php b/ext/payflowpro/tests/phpunit/CRM/Core/Payment/PayflowProTest.php index 4021911608e5..dd5a889138c0 100644 --- a/ext/payflowpro/tests/phpunit/CRM/Core/Payment/PayflowProTest.php +++ b/ext/payflowpro/tests/phpunit/CRM/Core/Payment/PayflowProTest.php @@ -23,6 +23,18 @@ class CRM_Core_Payment_PayflowProTest extends \PHPUnit\Framework\TestCase implem use \Civi\Test\GuzzleTestTrait; use \Civi\Test\Api3TestTrait; + /** + * Instance of CRM_Core_Payment_PayflowPro|null + * @var CRM_Core_Payment_PayflowPro + */ + protected $processor; + + /** + * Created Object Ids + * @var array + */ + public $ids; + public function setUpHeadless() { // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile(). // See: https://docs.civicrm.org/dev/en/latest/testing/phpunit/#civitest From 4bb246b6d43dfd5b3cf2a7e2b1f6b41368d85e59 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 16 Jan 2023 13:50:19 +1100 Subject: [PATCH 075/106] dev/core#4081 Ensure that if using the API to update an event template it is not converted to a non template Remove unneded lines now that we have a sensible default value in the database --- CRM/Event/BAO/Event.php | 3 --- tests/phpunit/api/v3/EventTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index ba87473d1821..23d26017feb7 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -95,9 +95,6 @@ public static function add(&$params) { */ public static function create(&$params) { $transaction = new CRM_Core_Transaction(); - if (empty($params['is_template'])) { - $params['is_template'] = 0; - } // check if new event, if so set the created_id (if not set) // and always set created_date to now if (empty($params['id'])) { diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index bba9dc803c02..a9debb622a49 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -935,4 +935,28 @@ public function testGetListLeadingZero() { $this->assertEquals(1, $result['count']); } + /** + * Test that using the API to update an Event template keeps the is_template parameter the same + * @dataProvider versionThreeAndFour + */ + public function testUpdateEventTemplate($version): void { + $this->_apiversion = $version; + $templateParams = [ + 'summary' => 'Sign up now to learn the results of this unit test', + 'description' => 'This event is created from a template, so all the values should be the same as the original ones.', + 'event_type_id' => 1, + 'is_public' => 1, + 'end_date' => '2018-06-25 17:00:00', + 'is_online_registration' => 1, + 'registration_start_date' => '2017-06-25 17:00:00', + 'registration_end_date' => '2018-06-25 17:00:00', + 'max_participants' => 100, + 'event_full_text' => 'Sorry! We are already full', + ]; + $template = $this->callAPISuccess('Event', 'create', ['is_template' => 1, 'template_title' => 'Test tpl'] + $templateParams); + $this->callAPISuccess('Event', 'create', ['id' => $template['id'], 'is_public' => 0]); + $template = $this->callAPISuccess('Event', 'get', ['id' => $template['id']])['values'][$template['id']]; + $this->assertEquals(1, $template['is_template']); + } + } From af34abeaf60e2b7fe080308bfb07bc62d833b5d3 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 17 Jan 2023 10:05:50 +1300 Subject: [PATCH 076/106] Re-run civix upgrade on flexmailer Also see https://github.com/civicrm/civicrm-core/pull/25249 --- ext/flexmailer/flexmailer.civix.php | 94 ++--------------------------- ext/flexmailer/flexmailer.php | 36 ----------- ext/flexmailer/info.xml | 2 +- 3 files changed, 6 insertions(+), 126 deletions(-) diff --git a/ext/flexmailer/flexmailer.civix.php b/ext/flexmailer/flexmailer.civix.php index 92186e76323b..6a215af36820 100644 --- a/ext/flexmailer/flexmailer.civix.php +++ b/ext/flexmailer/flexmailer.civix.php @@ -84,27 +84,20 @@ public static function findClass($suffix) { * * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config */ -function _flexmailer_civix_civicrm_config(&$config = NULL) { +function _flexmailer_civix_civicrm_config($config = NULL) { static $configured = FALSE; if ($configured) { return; } $configured = TRUE; - $template = CRM_Core_Smarty::singleton(); - $extRoot = __DIR__ . DIRECTORY_SEPARATOR; $extDir = $extRoot . 'templates'; - - if (is_array($template->template_dir)) { - array_unshift($template->template_dir, $extDir); - } - else { - $template->template_dir = [$extDir, $template->template_dir]; - } + CRM_Core_Smarty::singleton()->addTemplateDir($extDir); $include_path = $extRoot . PATH_SEPARATOR . get_include_path(); set_include_path($include_path); + // Based on , this does not currently require mixin/polyfill.php. } /** @@ -114,35 +107,7 @@ function _flexmailer_civix_civicrm_config(&$config = NULL) { */ function _flexmailer_civix_civicrm_install() { _flexmailer_civix_civicrm_config(); - if ($upgrader = _flexmailer_civix_upgrader()) { - $upgrader->onInstall(); - } -} - -/** - * Implements hook_civicrm_postInstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall - */ -function _flexmailer_civix_civicrm_postInstall() { - _flexmailer_civix_civicrm_config(); - if ($upgrader = _flexmailer_civix_upgrader()) { - if (is_callable([$upgrader, 'onPostInstall'])) { - $upgrader->onPostInstall(); - } - } -} - -/** - * Implements hook_civicrm_uninstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall - */ -function _flexmailer_civix_civicrm_uninstall(): void { - _flexmailer_civix_civicrm_config(); - if ($upgrader = _flexmailer_civix_upgrader()) { - $upgrader->onUninstall(); - } + // Based on , this does not currently require mixin/polyfill.php. } /** @@ -152,56 +117,7 @@ function _flexmailer_civix_civicrm_uninstall(): void { */ function _flexmailer_civix_civicrm_enable(): void { _flexmailer_civix_civicrm_config(); - if ($upgrader = _flexmailer_civix_upgrader()) { - if (is_callable([$upgrader, 'onEnable'])) { - $upgrader->onEnable(); - } - } -} - -/** - * (Delegated) Implements hook_civicrm_disable(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable - * @return mixed - */ -function _flexmailer_civix_civicrm_disable(): void { - _flexmailer_civix_civicrm_config(); - if ($upgrader = _flexmailer_civix_upgrader()) { - if (is_callable([$upgrader, 'onDisable'])) { - $upgrader->onDisable(); - } - } -} - -/** - * (Delegated) Implements hook_civicrm_upgrade(). - * - * @param $op string, the type of operation being performed; 'check' or 'enqueue' - * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks - * - * @return mixed - * based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending) - * for 'enqueue', returns void - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade - */ -function _flexmailer_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { - if ($upgrader = _flexmailer_civix_upgrader()) { - return $upgrader->onUpgrade($op, $queue); - } -} - -/** - * @return CRM_Flexmailer_Upgrader - */ -function _flexmailer_civix_upgrader() { - if (!file_exists(__DIR__ . '/CRM/Flexmailer/Upgrader.php')) { - return NULL; - } - else { - return CRM_Flexmailer_Upgrader_Base::instance(); - } + // Based on , this does not currently require mixin/polyfill.php. } /** diff --git a/ext/flexmailer/flexmailer.php b/ext/flexmailer/flexmailer.php index bf3047f4276d..7397be2abf1b 100644 --- a/ext/flexmailer/flexmailer.php +++ b/ext/flexmailer/flexmailer.php @@ -32,24 +32,6 @@ function flexmailer_civicrm_install() { _flexmailer_civix_civicrm_install(); } -/** - * Implements hook_civicrm_postInstall(). - * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_postInstall - */ -function flexmailer_civicrm_postInstall() { - _flexmailer_civix_civicrm_postInstall(); -} - -/** - * Implements hook_civicrm_uninstall(). - * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall - */ -function flexmailer_civicrm_uninstall() { - _flexmailer_civix_civicrm_uninstall(); -} - /** * Implements hook_civicrm_enable(). * @@ -59,24 +41,6 @@ function flexmailer_civicrm_enable() { _flexmailer_civix_civicrm_enable(); } -/** - * Implements hook_civicrm_disable(). - * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable - */ -function flexmailer_civicrm_disable() { - _flexmailer_civix_civicrm_disable(); -} - -/** - * Implements hook_civicrm_upgrade(). - * - * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade - */ -function flexmailer_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { - return _flexmailer_civix_civicrm_upgrade($op, $queue); -} - /** * Implements hook_civicrm_navigationMenu(). * diff --git a/ext/flexmailer/info.xml b/ext/flexmailer/info.xml index 9725fbf01640..cc4960f97111 100644 --- a/ext/flexmailer/info.xml +++ b/ext/flexmailer/info.xml @@ -37,6 +37,6 @@ CRM/Flexmailer - 22.10.0 + 22.12.1 From fb1ccb6417fa57cc6d8f69c511f7a2ba38cd2f73 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 17 Jan 2023 10:08:28 +1300 Subject: [PATCH 077/106] Run civix upgrade on oauth --- ext/oauth-client/CRM/OAuth/Upgrader.php | 2 +- ext/oauth-client/CRM/OAuth/Upgrader/Base.php | 7 -- ext/oauth-client/info.xml | 2 +- ext/oauth-client/oauth_client.civix.php | 100 ++----------------- 4 files changed, 10 insertions(+), 101 deletions(-) delete mode 100644 ext/oauth-client/CRM/OAuth/Upgrader/Base.php diff --git a/ext/oauth-client/CRM/OAuth/Upgrader.php b/ext/oauth-client/CRM/OAuth/Upgrader.php index df5fdd0eb55e..d196fd8ee675 100644 --- a/ext/oauth-client/CRM/OAuth/Upgrader.php +++ b/ext/oauth-client/CRM/OAuth/Upgrader.php @@ -4,7 +4,7 @@ /** * Collection of upgrade steps. */ -class CRM_OAuth_Upgrader extends CRM_OAuth_Upgrader_Base { +class CRM_OAuth_Upgrader extends CRM_Extension_Upgrader_Base { /** * @see CRM_Utils_Hook::install() diff --git a/ext/oauth-client/CRM/OAuth/Upgrader/Base.php b/ext/oauth-client/CRM/OAuth/Upgrader/Base.php deleted file mode 100644 index ae97dcb7334d..000000000000 --- a/ext/oauth-client/CRM/OAuth/Upgrader/Base.php +++ /dev/null @@ -1,7 +0,0 @@ - CRM/OAuth - 22.10.0 + 22.12.1 diff --git a/ext/oauth-client/oauth_client.civix.php b/ext/oauth-client/oauth_client.civix.php index 3d9ae5d3f523..91cdf5cfa0fd 100644 --- a/ext/oauth-client/oauth_client.civix.php +++ b/ext/oauth-client/oauth_client.civix.php @@ -24,7 +24,7 @@ class CRM_OAuth_ExtensionUtil { * Translated text. * @see ts */ - public static function ts($text, $params = []) { + public static function ts($text, $params = []): string { if (!array_key_exists('domain', $params)) { $params['domain'] = [self::LONG_NAME, NULL]; } @@ -41,7 +41,7 @@ public static function ts($text, $params = []) { * Ex: 'http://example.org/sites/default/ext/org.example.foo'. * Ex: 'http://example.org/sites/default/ext/org.example.foo/css/foo.css'. */ - public static function url($file = NULL) { + public static function url($file = NULL): string { if ($file === NULL) { return rtrim(CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME), '/'); } @@ -84,27 +84,20 @@ public static function findClass($suffix) { * * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config */ -function _oauth_client_civix_civicrm_config(&$config = NULL) { +function _oauth_client_civix_civicrm_config($config = NULL) { static $configured = FALSE; if ($configured) { return; } $configured = TRUE; - $template = CRM_Core_Smarty::singleton(); - $extRoot = __DIR__ . DIRECTORY_SEPARATOR; $extDir = $extRoot . 'templates'; - - if (is_array($template->template_dir)) { - array_unshift($template->template_dir, $extDir); - } - else { - $template->template_dir = [$extDir, $template->template_dir]; - } + CRM_Core_Smarty::singleton()->addTemplateDir($extDir); $include_path = $extRoot . PATH_SEPARATOR . get_include_path(); set_include_path($include_path); + // Based on , this does not currently require mixin/polyfill.php. } /** @@ -114,35 +107,7 @@ function _oauth_client_civix_civicrm_config(&$config = NULL) { */ function _oauth_client_civix_civicrm_install() { _oauth_client_civix_civicrm_config(); - if ($upgrader = _oauth_client_civix_upgrader()) { - $upgrader->onInstall(); - } -} - -/** - * Implements hook_civicrm_postInstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall - */ -function _oauth_client_civix_civicrm_postInstall() { - _oauth_client_civix_civicrm_config(); - if ($upgrader = _oauth_client_civix_upgrader()) { - if (is_callable([$upgrader, 'onPostInstall'])) { - $upgrader->onPostInstall(); - } - } -} - -/** - * Implements hook_civicrm_uninstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall - */ -function _oauth_client_civix_civicrm_uninstall() { - _oauth_client_civix_civicrm_config(); - if ($upgrader = _oauth_client_civix_upgrader()) { - $upgrader->onUninstall(); - } + // Based on , this does not currently require mixin/polyfill.php. } /** @@ -150,58 +115,9 @@ function _oauth_client_civix_civicrm_uninstall() { * * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable */ -function _oauth_client_civix_civicrm_enable() { - _oauth_client_civix_civicrm_config(); - if ($upgrader = _oauth_client_civix_upgrader()) { - if (is_callable([$upgrader, 'onEnable'])) { - $upgrader->onEnable(); - } - } -} - -/** - * (Delegated) Implements hook_civicrm_disable(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable - * @return mixed - */ -function _oauth_client_civix_civicrm_disable() { +function _oauth_client_civix_civicrm_enable(): void { _oauth_client_civix_civicrm_config(); - if ($upgrader = _oauth_client_civix_upgrader()) { - if (is_callable([$upgrader, 'onDisable'])) { - $upgrader->onDisable(); - } - } -} - -/** - * (Delegated) Implements hook_civicrm_upgrade(). - * - * @param $op string, the type of operation being performed; 'check' or 'enqueue' - * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks - * - * @return mixed - * based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending) - * for 'enqueue', returns void - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade - */ -function _oauth_client_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { - if ($upgrader = _oauth_client_civix_upgrader()) { - return $upgrader->onUpgrade($op, $queue); - } -} - -/** - * @return CRM_OAuth_Upgrader - */ -function _oauth_client_civix_upgrader() { - if (!file_exists(__DIR__ . '/CRM/OAuth/Upgrader.php')) { - return NULL; - } - else { - return CRM_OAuth_Upgrader_Base::instance(); - } + // Based on , this does not currently require mixin/polyfill.php. } /** From 97b2f56b53c3b6005d7a2cc4def0b4aef5f9ba68 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 17 Jan 2023 10:18:28 +1300 Subject: [PATCH 078/106] Civix upgrade message_admin --- ext/message_admin/info.xml | 2 +- ext/message_admin/message_admin.civix.php | 94 ++--------------------- ext/message_admin/message_admin.php | 36 --------- 3 files changed, 6 insertions(+), 126 deletions(-) diff --git a/ext/message_admin/info.xml b/ext/message_admin/info.xml index 802b24e46f1a..cc8bdbd41a16 100644 --- a/ext/message_admin/info.xml +++ b/ext/message_admin/info.xml @@ -34,6 +34,6 @@ CRM/MessageAdmin - 22.10.0 + 22.12.1 diff --git a/ext/message_admin/message_admin.civix.php b/ext/message_admin/message_admin.civix.php index 14af7812f49b..b386a62dc72d 100644 --- a/ext/message_admin/message_admin.civix.php +++ b/ext/message_admin/message_admin.civix.php @@ -84,27 +84,20 @@ public static function findClass($suffix) { * * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config */ -function _message_admin_civix_civicrm_config(&$config = NULL) { +function _message_admin_civix_civicrm_config($config = NULL) { static $configured = FALSE; if ($configured) { return; } $configured = TRUE; - $template = CRM_Core_Smarty::singleton(); - $extRoot = __DIR__ . DIRECTORY_SEPARATOR; $extDir = $extRoot . 'templates'; - - if (is_array($template->template_dir)) { - array_unshift($template->template_dir, $extDir); - } - else { - $template->template_dir = [$extDir, $template->template_dir]; - } + CRM_Core_Smarty::singleton()->addTemplateDir($extDir); $include_path = $extRoot . PATH_SEPARATOR . get_include_path(); set_include_path($include_path); + // Based on , this does not currently require mixin/polyfill.php. } /** @@ -114,35 +107,7 @@ function _message_admin_civix_civicrm_config(&$config = NULL) { */ function _message_admin_civix_civicrm_install() { _message_admin_civix_civicrm_config(); - if ($upgrader = _message_admin_civix_upgrader()) { - $upgrader->onInstall(); - } -} - -/** - * Implements hook_civicrm_postInstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall - */ -function _message_admin_civix_civicrm_postInstall() { - _message_admin_civix_civicrm_config(); - if ($upgrader = _message_admin_civix_upgrader()) { - if (is_callable([$upgrader, 'onPostInstall'])) { - $upgrader->onPostInstall(); - } - } -} - -/** - * Implements hook_civicrm_uninstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall - */ -function _message_admin_civix_civicrm_uninstall(): void { - _message_admin_civix_civicrm_config(); - if ($upgrader = _message_admin_civix_upgrader()) { - $upgrader->onUninstall(); - } + // Based on , this does not currently require mixin/polyfill.php. } /** @@ -152,56 +117,7 @@ function _message_admin_civix_civicrm_uninstall(): void { */ function _message_admin_civix_civicrm_enable(): void { _message_admin_civix_civicrm_config(); - if ($upgrader = _message_admin_civix_upgrader()) { - if (is_callable([$upgrader, 'onEnable'])) { - $upgrader->onEnable(); - } - } -} - -/** - * (Delegated) Implements hook_civicrm_disable(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable - * @return mixed - */ -function _message_admin_civix_civicrm_disable(): void { - _message_admin_civix_civicrm_config(); - if ($upgrader = _message_admin_civix_upgrader()) { - if (is_callable([$upgrader, 'onDisable'])) { - $upgrader->onDisable(); - } - } -} - -/** - * (Delegated) Implements hook_civicrm_upgrade(). - * - * @param $op string, the type of operation being performed; 'check' or 'enqueue' - * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks - * - * @return mixed - * based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending) - * for 'enqueue', returns void - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade - */ -function _message_admin_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { - if ($upgrader = _message_admin_civix_upgrader()) { - return $upgrader->onUpgrade($op, $queue); - } -} - -/** - * @return CRM_MessageAdmin_Upgrader - */ -function _message_admin_civix_upgrader() { - if (!file_exists(__DIR__ . '/CRM/MessageAdmin/Upgrader.php')) { - return NULL; - } - else { - return CRM_MessageAdmin_Upgrader_Base::instance(); - } + // Based on , this does not currently require mixin/polyfill.php. } /** diff --git a/ext/message_admin/message_admin.php b/ext/message_admin/message_admin.php index 4f9bd7b47540..872e322729f4 100644 --- a/ext/message_admin/message_admin.php +++ b/ext/message_admin/message_admin.php @@ -23,24 +23,6 @@ function message_admin_civicrm_install() { _message_admin_civix_civicrm_install(); } -/** - * Implements hook_civicrm_postInstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall - */ -function message_admin_civicrm_postInstall() { - _message_admin_civix_civicrm_postInstall(); -} - -/** - * Implements hook_civicrm_uninstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall - */ -function message_admin_civicrm_uninstall() { - _message_admin_civix_civicrm_uninstall(); -} - /** * Implements hook_civicrm_enable(). * @@ -50,24 +32,6 @@ function message_admin_civicrm_enable() { _message_admin_civix_civicrm_enable(); } -/** - * Implements hook_civicrm_disable(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable - */ -function message_admin_civicrm_disable() { - _message_admin_civix_civicrm_disable(); -} - -/** - * Implements hook_civicrm_upgrade(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade - */ -function message_admin_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { - return _message_admin_civix_civicrm_upgrade($op, $queue); -} - /** * Implements hook_civicrm_entityTypes(). * From cb97a87740379721f29f071266168644a0070747 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 17 Jan 2023 12:07:35 +1300 Subject: [PATCH 079/106] Civix upgrade on event cart --- ext/eventcart/eventcart.civix.php | 94 ++----------------------------- ext/eventcart/eventcart.php | 36 ------------ ext/eventcart/info.xml | 2 +- 3 files changed, 7 insertions(+), 125 deletions(-) diff --git a/ext/eventcart/eventcart.civix.php b/ext/eventcart/eventcart.civix.php index 609fdb2e6e7b..91bd958e3b75 100644 --- a/ext/eventcart/eventcart.civix.php +++ b/ext/eventcart/eventcart.civix.php @@ -84,27 +84,22 @@ public static function findClass($suffix) { * * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config */ -function _eventcart_civix_civicrm_config(&$config = NULL) { +function _eventcart_civix_civicrm_config($config = NULL) { static $configured = FALSE; if ($configured) { return; } $configured = TRUE; - $template = CRM_Core_Smarty::singleton(); - $extRoot = __DIR__ . DIRECTORY_SEPARATOR; $extDir = $extRoot . 'templates'; - - if (is_array($template->template_dir)) { - array_unshift($template->template_dir, $extDir); - } - else { - $template->template_dir = [$extDir, $template->template_dir]; + if (file_exists($extDir)) { + CRM_Core_Smarty::singleton()->addTemplateDir($extDir); } $include_path = $extRoot . PATH_SEPARATOR . get_include_path(); set_include_path($include_path); + // Based on , this does not currently require mixin/polyfill.php. } /** @@ -114,35 +109,7 @@ function _eventcart_civix_civicrm_config(&$config = NULL) { */ function _eventcart_civix_civicrm_install() { _eventcart_civix_civicrm_config(); - if ($upgrader = _eventcart_civix_upgrader()) { - $upgrader->onInstall(); - } -} - -/** - * Implements hook_civicrm_postInstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall - */ -function _eventcart_civix_civicrm_postInstall() { - _eventcart_civix_civicrm_config(); - if ($upgrader = _eventcart_civix_upgrader()) { - if (is_callable([$upgrader, 'onPostInstall'])) { - $upgrader->onPostInstall(); - } - } -} - -/** - * Implements hook_civicrm_uninstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall - */ -function _eventcart_civix_civicrm_uninstall(): void { - _eventcart_civix_civicrm_config(); - if ($upgrader = _eventcart_civix_upgrader()) { - $upgrader->onUninstall(); - } + // Based on , this does not currently require mixin/polyfill.php. } /** @@ -152,56 +119,7 @@ function _eventcart_civix_civicrm_uninstall(): void { */ function _eventcart_civix_civicrm_enable(): void { _eventcart_civix_civicrm_config(); - if ($upgrader = _eventcart_civix_upgrader()) { - if (is_callable([$upgrader, 'onEnable'])) { - $upgrader->onEnable(); - } - } -} - -/** - * (Delegated) Implements hook_civicrm_disable(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable - * @return mixed - */ -function _eventcart_civix_civicrm_disable(): void { - _eventcart_civix_civicrm_config(); - if ($upgrader = _eventcart_civix_upgrader()) { - if (is_callable([$upgrader, 'onDisable'])) { - $upgrader->onDisable(); - } - } -} - -/** - * (Delegated) Implements hook_civicrm_upgrade(). - * - * @param $op string, the type of operation being performed; 'check' or 'enqueue' - * @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks - * - * @return mixed - * based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending) - * for 'enqueue', returns void - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade - */ -function _eventcart_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { - if ($upgrader = _eventcart_civix_upgrader()) { - return $upgrader->onUpgrade($op, $queue); - } -} - -/** - * @return CRM_Event_Cart_Upgrader - */ -function _eventcart_civix_upgrader() { - if (!file_exists(__DIR__ . '/CRM/Event/Cart/Upgrader.php')) { - return NULL; - } - else { - return CRM_Event_Cart_Upgrader_Base::instance(); - } + // Based on , this does not currently require mixin/polyfill.php. } /** diff --git a/ext/eventcart/eventcart.php b/ext/eventcart/eventcart.php index d160a35861ac..df46e2bc7f6e 100644 --- a/ext/eventcart/eventcart.php +++ b/ext/eventcart/eventcart.php @@ -32,24 +32,6 @@ function eventcart_civicrm_install() { _eventcart_civix_civicrm_install(); } -/** - * Implements hook_civicrm_postInstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall - */ -function eventcart_civicrm_postInstall() { - _eventcart_civix_civicrm_postInstall(); -} - -/** - * Implements hook_civicrm_uninstall(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall - */ -function eventcart_civicrm_uninstall() { - _eventcart_civix_civicrm_uninstall(); -} - /** * Implements hook_civicrm_enable(). * @@ -59,24 +41,6 @@ function eventcart_civicrm_enable() { _eventcart_civix_civicrm_enable(); } -/** - * Implements hook_civicrm_disable(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable - */ -function eventcart_civicrm_disable() { - _eventcart_civix_civicrm_disable(); -} - -/** - * Implements hook_civicrm_upgrade(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade - */ -function eventcart_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { - return _eventcart_civix_civicrm_upgrade($op, $queue); -} - /** * Implements hook_civicrm_entityTypes(). * diff --git a/ext/eventcart/info.xml b/ext/eventcart/info.xml index 861003aeb843..f485d04adc24 100644 --- a/ext/eventcart/info.xml +++ b/ext/eventcart/info.xml @@ -31,6 +31,6 @@ CRM/Event/Cart - 22.10.0 + 22.12.1 From a081223c188408df47534bb30a90a4e1e02c10fe Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 1 Jan 2023 14:25:04 +1300 Subject: [PATCH 080/106] Remove code for legacy php versions - assign_by_ref with an object --- CRM/Core/Smarty.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Smarty.php b/CRM/Core/Smarty.php index 483ef374baea..4874e2b5424f 100644 --- a/CRM/Core/Smarty.php +++ b/CRM/Core/Smarty.php @@ -117,8 +117,8 @@ private function initialize() { // add the session and the config here $session = CRM_Core_Session::singleton(); - $this->assign_by_ref('config', $config); - $this->assign_by_ref('session', $session); + $this->assign('config', $config); + $this->assign('session', $session); $tsLocale = CRM_Core_I18n::getLocale(); $this->assign('tsLocale', $tsLocale); From b8cdd036a011eddc415fe652dfad09e73b2a1a56 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 16 Jan 2023 18:52:04 -0800 Subject: [PATCH 081/106] Add CRM_Utils_Time::delta() --- CRM/Utils/Time.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CRM/Utils/Time.php b/CRM/Utils/Time.php index dd56d6b9e422..dab77826d5b5 100644 --- a/CRM/Utils/Time.php +++ b/CRM/Utils/Time.php @@ -74,6 +74,16 @@ public static function time() { return self::$callback === NULL ? time() : call_user_func(self::$callback); } + /** + * Get the simulation offset. + * + * @return int + * Seconds between logical time and real time. + */ + public static function delta(): int { + return self::$callback === NULL ? 0 : (call_user_func(self::$callback) - time()); + } + /** * Get the time. * From 77e1a56e017d80153cf11466791e245cf52ea79a Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 16 Jan 2023 18:52:28 -0800 Subject: [PATCH 082/106] CRM_Queue_Queue_Sql - Prefer operations using Unix epoch format --- CRM/Queue/Queue/Sql.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/CRM/Queue/Queue/Sql.php b/CRM/Queue/Queue/Sql.php index d556cbaf7d9b..5d095dc1808a 100644 --- a/CRM/Queue/Queue/Sql.php +++ b/CRM/Queue/Queue/Sql.php @@ -56,29 +56,24 @@ public function claimItem($lease_time = NULL) { ORDER BY weight, id LIMIT 1 ) first_in_queue - WHERE release_time IS NULL OR release_time < %2 + WHERE release_time IS NULL OR UNIX_TIMESTAMP(release_time) < %2 '; $params = [ 1 => [$this->getName(), 'String'], - 2 => [CRM_Utils_Time::getTime(), 'Timestamp'], + 2 => [CRM_Utils_Time::time(), 'Integer'], ]; $dao = CRM_Core_DAO::executeQuery($sql, $params, TRUE, 'CRM_Queue_DAO_QueueItem'); if ($dao->fetch()) { $nowEpoch = CRM_Utils_Time::getTimeRaw(); $dao->run_count++; - $sql = 'UPDATE civicrm_queue_item SET release_time = %1, run_count = %3 WHERE id = %2'; + $sql = 'UPDATE civicrm_queue_item SET release_time = from_unixtime(unix_timestamp() + %1), run_count = %3 WHERE id = %2'; $sqlParams = [ - '1' => [date('YmdHis', $nowEpoch + $lease_time), 'String'], + '1' => [CRM_Utils_Time::delta() + $lease_time, 'Integer'], '2' => [$dao->id, 'Integer'], '3' => [$dao->run_count, 'Integer'], ]; CRM_Core_DAO::executeQuery($sql, $sqlParams); - // (Comment by artfulrobot Sep 2019: Not sure what the below comment means, should be removed/clarified?) - // work-around: inconsistent date-formatting causes unintentional breakage - # $dao->submit_time = date('YmdHis', strtotime($dao->submit_time)); - # $dao->release_time = date('YmdHis', $nowEpoch + $lease_time); - # $dao->save(); $dao->data = unserialize($dao->data); $result = $dao; } @@ -114,8 +109,8 @@ public function stealItem($lease_time = NULL) { if ($dao->fetch()) { $nowEpoch = CRM_Utils_Time::getTimeRaw(); $dao->run_count++; - CRM_Core_DAO::executeQuery("UPDATE civicrm_queue_item SET release_time = %1 WHERE id = %2", [ - '1' => [date('YmdHis', $nowEpoch + $lease_time), 'String'], + CRM_Core_DAO::executeQuery("UPDATE civicrm_queue_item SET release_time = from_unixtime(unix_timestamp() + %1) WHERE id = %2", [ + '1' => [CRM_Utils_Time::delta() + $lease_time, 'Integer'], '2' => [$dao->id, 'Integer'], ]); $dao->data = unserialize($dao->data); From 474d6c04fd3f9e73a2151bba87b409d4385a1e04 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 16 Jan 2023 18:52:44 -0800 Subject: [PATCH 083/106] CRM_Queue_Queue_SqlParallel - Prefer operations using Unix epoch format --- CRM/Queue/Queue/SqlParallel.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/CRM/Queue/Queue/SqlParallel.php b/CRM/Queue/Queue/SqlParallel.php index 8573b7b99883..7a4b6e4704c3 100644 --- a/CRM/Queue/Queue/SqlParallel.php +++ b/CRM/Queue/Queue/SqlParallel.php @@ -53,13 +53,13 @@ public function claimItems(int $limit, ?int $lease_time = NULL): array { $sql = "SELECT id, queue_name, submit_time, release_time, run_count, data FROM civicrm_queue_item WHERE queue_name = %1 - AND (release_time IS NULL OR release_time < %2) + AND (release_time IS NULL OR UNIX_TIMESTAMP(release_time) < %2) ORDER BY weight ASC, id ASC LIMIT %3 "; $params = [ 1 => [$this->getName(), 'String'], - 2 => [CRM_Utils_Time::getTime(), 'Timestamp'], + 2 => [CRM_Utils_Time::time(), 'Integer'], 3 => [$limit, 'Integer'], ]; $dao = CRM_Core_DAO::executeQuery($sql, $params, TRUE, 'CRM_Queue_DAO_QueueItem'); @@ -78,9 +78,8 @@ public function claimItems(int $limit, ?int $lease_time = NULL): array { ]; } if ($result) { - $nowEpoch = CRM_Utils_Time::getTimeRaw(); - $sql = CRM_Utils_SQL::interpolate('UPDATE civicrm_queue_item SET release_time = @RT, run_count = 1+run_count WHERE id IN (#ids)', [ - 'RT' => date('YmdHis', $nowEpoch + $lease_time), + $sql = CRM_Utils_SQL::interpolate('UPDATE civicrm_queue_item SET release_time = FROM_UNIXTIME(UNIX_TIMESTAMP() + #release), run_count = 1+run_count WHERE id IN (#ids)', [ + 'release' => CRM_Utils_Time::delta() + $lease_time, 'ids' => CRM_Utils_Array::collect('id', $result), ]); CRM_Core_DAO::executeQuery($sql); @@ -117,8 +116,8 @@ public function stealItem($lease_time = NULL) { if ($dao->fetch()) { $nowEpoch = CRM_Utils_Time::getTimeRaw(); $dao->run_count++; - CRM_Core_DAO::executeQuery("UPDATE civicrm_queue_item SET release_time = %1, run_count = %3 WHERE id = %2", [ - '1' => [date('YmdHis', $nowEpoch + $lease_time), 'String'], + CRM_Core_DAO::executeQuery("UPDATE civicrm_queue_item SET release_time = from_unixtime(unix_timestamp() + %1), run_count = %3 WHERE id = %2", [ + '1' => [CRM_Utils_Time::delta() + $lease_time, 'Integer'], '2' => [$dao->id, 'Integer'], '3' => [$dao->run_count, 'Integer'], ]); From d4ef7d8b8abd34a92c70b0097c358e1e94bde0b5 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 16 Jan 2023 19:00:41 -0800 Subject: [PATCH 084/106] CRM_Queue_Queue_SqlTrait - Prefer operations using Unix epoch format --- CRM/Queue/Queue/SqlTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Queue/Queue/SqlTrait.php b/CRM/Queue/Queue/SqlTrait.php index 69f5cf220689..8fc9275e51a5 100644 --- a/CRM/Queue/Queue/SqlTrait.php +++ b/CRM/Queue/Queue/SqlTrait.php @@ -59,12 +59,12 @@ public function getStatistic(string $name) { switch ($name) { case 'ready': return (int) CRM_Core_DAO::singleValueQuery( - 'SELECT count(*) FROM civicrm_queue_item WHERE queue_name = %1 AND (release_time is null OR release_time <= FROM_UNIXTIME(%2))', + 'SELECT count(*) FROM civicrm_queue_item WHERE queue_name = %1 AND (release_time is null OR UNIX_TIMESTAMP(release_time) <= %2)', [1 => [$this->getName(), 'String'], 2 => [CRM_Utils_Time::time(), 'Int']]); case 'blocked': return (int) CRM_Core_DAO::singleValueQuery( - 'SELECT count(*) FROM civicrm_queue_item WHERE queue_name = %1 AND release_time > FROM_UNIXTIME(%2)', + 'SELECT count(*) FROM civicrm_queue_item WHERE queue_name = %1 AND UNIX_TIMESTAMP(release_time) > %2', [1 => [$this->getName(), 'String'], 2 => [CRM_Utils_Time::time(), 'Int']]); case 'total': From 1bcb4f32f0315bba1ff003fa99a1424790521287 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 16 Jan 2023 19:01:01 -0800 Subject: [PATCH 085/106] CRM_Queue_Queue_SqlTrait - Insert using epoch format --- CRM/Queue/Queue/SqlTrait.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/CRM/Queue/Queue/SqlTrait.php b/CRM/Queue/Queue/SqlTrait.php index 8fc9275e51a5..6b315b83ee27 100644 --- a/CRM/Queue/Queue/SqlTrait.php +++ b/CRM/Queue/Queue/SqlTrait.php @@ -88,15 +88,21 @@ public function getStatistic(string $name) { * Ex: ['release_time' => strtotime('+3 hours')] */ public function createItem($data, $options = []) { - $dao = new CRM_Queue_DAO_QueueItem(); - $dao->queue_name = $this->getName(); - $dao->submit_time = CRM_Utils_Time::getTime('YmdHis'); - $dao->data = serialize($data); - $dao->weight = CRM_Utils_Array::value('weight', $options, 0); - if (isset($options['release_time'])) { - $dao->release_time = date('Y-m-d H:i:s', $options['release_time']); + if (!isset($options['release_time'])) { + $releaseTime = 'null'; } - $dao->save(); + elseif (is_numeric($options['release_time'])) { + $releaseTime = sprintf('FROM_UNIXTIME(%d)', $options['release_time']); + } + else { + throw new \CRM_Core_Exception("Cannot enqueue item. Malformed release_time."); + } + + \CRM_Core_DAO::executeQuery("INSERT INTO civicrm_queue_item (queue_name, submit_time, data, weight, release_time) VALUES (%1, now(), %2, %3, {$releaseTime})", [ + 1 => [$this->getName(), 'String'], + 2 => [serialize($data), 'String'], + 3 => [CRM_Utils_Array::value('weight', $options, 0), 'Integer'], + ], TRUE, NULL, FALSE, FALSE); } /** From 7dccc95519688c1993823c1789e136923d0038a2 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 16 Jan 2023 21:48:24 -0800 Subject: [PATCH 086/106] (NFC) Cleanup Gitlab references --- CRM/Contact/Form/Task/PDFTrait.php | 2 +- CRM/Core/BAO/Address.php | 2 +- CRM/Core/Form/Task/PDFLetterCommon.php | 2 +- CRM/Core/I18n.php | 2 +- CRM/Upgrade/Incremental/php/FiveForty.php | 2 +- CRM/Upgrade/Incremental/php/FiveThirtyFive.php | 6 +++--- CRM/Upgrade/Incremental/php/FiveThirtyFour.php | 8 ++++---- CRM/Upgrade/Incremental/php/FiveThirtySeven.php | 10 +++++----- CRM/Upgrade/Incremental/php/FiveThirtySix.php | 14 +++++++------- CRM/Upgrade/Incremental/sql/5.3.alpha1.mysql.tpl | 2 +- api/v3/Contact.php | 2 +- release-notes/5.10.0.md | 2 +- release-notes/5.16.0.md | 2 +- release-notes/5.56.0.md | 2 +- release-notes/5.9.0.md | 2 +- tests/phpunit/CRM/Activity/BAO/ActivityTest.php | 4 ++-- tests/phpunit/CRM/Core/BAO/AddressTest.php | 4 ++-- 17 files changed, 34 insertions(+), 34 deletions(-) diff --git a/CRM/Contact/Form/Task/PDFTrait.php b/CRM/Contact/Form/Task/PDFTrait.php index 088990239136..e19cdac942c8 100644 --- a/CRM/Contact/Form/Task/PDFTrait.php +++ b/CRM/Contact/Form/Task/PDFTrait.php @@ -67,7 +67,7 @@ public function addPDFElementsToForm(): void { FALSE ); - // Added for core#2121, + // Added for dev/core#2121, // To support sending a custom pdf filename before downloading. $form->addElement('hidden', 'pdf_file_name'); diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index 5b114112fce8..9c7d90ff2813 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -1311,7 +1311,7 @@ public static function addGeocoderData(&$params) { if ($providerExists) { $provider::format($params); } - // core#2379 - Limit geocode length to 14 characters to avoid validation error on save in UI. + // dev/core#2379 - Limit geocode length to 14 characters to avoid validation error on save in UI. foreach (['geo_code_1', 'geo_code_2'] as $geocode) { if ($params[$geocode] ?? FALSE) { // ensure that if the geocoding provider (Google, OSM etc) has returned the string 'null' because they can't geocode, ensure that contacts are not placed on null island 0,0 diff --git a/CRM/Core/Form/Task/PDFLetterCommon.php b/CRM/Core/Form/Task/PDFLetterCommon.php index e9d32eab6cbe..af2e9e3fc357 100644 --- a/CRM/Core/Form/Task/PDFLetterCommon.php +++ b/CRM/Core/Form/Task/PDFLetterCommon.php @@ -62,7 +62,7 @@ public static function buildQuickForm(&$form) { FALSE ); - // Added for core#2121, + // Added for dev/core#2121, // To support sending a custom pdf filename before downloading. $form->addElement('hidden', 'pdf_file_name'); diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index b1aa48974af0..01e6aef7fe9f 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -180,7 +180,7 @@ public static function languages($justEnabled = FALSE) { if (!$all) { $optionValues = []; - // Use `getValues`, not `buildOptions` to bypass hook_civicrm_fieldOptions. See core#1132. + // Use `getValues`, not `buildOptions` to bypass hook_civicrm_fieldOptions. See dev/core#1132. CRM_Core_OptionValue::getValues(['name' => 'languages'], $optionValues, 'weight', TRUE); $all = array_column($optionValues, 'label', 'name'); diff --git a/CRM/Upgrade/Incremental/php/FiveForty.php b/CRM/Upgrade/Incremental/php/FiveForty.php index 047d87a9a0c5..a771b55a8fc6 100644 --- a/CRM/Upgrade/Incremental/php/FiveForty.php +++ b/CRM/Upgrade/Incremental/php/FiveForty.php @@ -17,7 +17,7 @@ class CRM_Upgrade_Incremental_php_FiveForty extends CRM_Upgrade_Incremental_Base public function upgrade_5_40_alpha1($rev) { $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); $this->addTask('Add option list for group_used_for', 'addGroupOptionList'); - $this->addTask('core-issue#2486 - Add product_id foreign key to civicrm_contribution_product', 'addContributionProductFK'); + $this->addTask('dev/core#2486 - Add product_id foreign key to civicrm_contribution_product', 'addContributionProductFK'); $this->addTask('Add membership_num_terms column to civicrm_line_item', 'addColumn', 'civicrm_line_item', 'membership_num_terms', "int unsigned DEFAULT NULL COMMENT 'Number of terms for this membership (only supported in Order->Payment flow). If the field is NULL it means unknown and it will be assumed to be 1 during payment.create if entity_table is civicrm_membership'" ); diff --git a/CRM/Upgrade/Incremental/php/FiveThirtyFive.php b/CRM/Upgrade/Incremental/php/FiveThirtyFive.php index 7d3e3f3c5ae2..54ffd45a0775 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirtyFive.php +++ b/CRM/Upgrade/Incremental/php/FiveThirtyFive.php @@ -22,11 +22,11 @@ class CRM_Upgrade_Incremental_php_FiveThirtyFive extends CRM_Upgrade_Incremental public function upgrade_5_35_alpha1(string $rev): void { $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); - $this->addTask('dev/core/#2329 - Add is_active to Country', 'addColumn', + $this->addTask('dev/core#2329 - Add is_active to Country', 'addColumn', 'civicrm_country', 'is_active', "tinyint DEFAULT 1 COMMENT 'Is this Country active?'"); - $this->addTask('dev/core/#2329 - Add is_active to StateProvince', 'addColumn', + $this->addTask('dev/core#2329 - Add is_active to StateProvince', 'addColumn', 'civicrm_state_province', 'is_active', "tinyint DEFAULT 1 COMMENT 'Is this StateProvince active?'"); - $this->addTask('dev/core/#2329 - Add is_active to County', 'addColumn', + $this->addTask('dev/core#2329 - Add is_active to County', 'addColumn', 'civicrm_county', 'is_active', "tinyint DEFAULT 1 COMMENT 'Is this County active?'"); } diff --git a/CRM/Upgrade/Incremental/php/FiveThirtyFour.php b/CRM/Upgrade/Incremental/php/FiveThirtyFour.php index 7c6c49687645..00419821e0f6 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirtyFour.php +++ b/CRM/Upgrade/Incremental/php/FiveThirtyFour.php @@ -122,16 +122,16 @@ public function upgrade_5_34_alpha1(string $rev): void { $this->addTask('Migrate SMTP password', 'migrateSmtpPasswords'); } - $this->addTask('core-issue#365 - Add created_date to civicrm_action_schedule', 'addColumn', + $this->addTask('dev/core#365 - Add created_date to civicrm_action_schedule', 'addColumn', 'civicrm_action_schedule', 'created_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When was the schedule reminder created.'"); - $this->addTask('core-issue#365 - Add modified_date to civicrm_action_schedule', 'addColumn', + $this->addTask('dev/core#365 - Add modified_date to civicrm_action_schedule', 'addColumn', 'civicrm_action_schedule', 'modified_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When was the schedule reminder created.'"); - $this->addTask('core-issue#365 - Add effective_start_date to civicrm_action_schedule', 'addColumn', + $this->addTask('dev/core#365 - Add effective_start_date to civicrm_action_schedule', 'addColumn', 'civicrm_action_schedule', 'effective_start_date', "timestamp NULL COMMENT 'Earliest date to consider start events from.'"); - $this->addTask('core-issue#365 - Add effective_end_date to civicrm_action_schedule', 'addColumn', + $this->addTask('dev/core#365 - Add effective_end_date to civicrm_action_schedule', 'addColumn', 'civicrm_action_schedule', 'effective_end_date', "timestamp NULL COMMENT 'Latest date to consider end events from.'"); $this->addTask('Set defaults and required on financial type boolean fields', 'updateFinancialTypeTable'); diff --git a/CRM/Upgrade/Incremental/php/FiveThirtySeven.php b/CRM/Upgrade/Incremental/php/FiveThirtySeven.php index b773ab8a9fd1..7e5ad9ff5345 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirtySeven.php +++ b/CRM/Upgrade/Incremental/php/FiveThirtySeven.php @@ -43,13 +43,13 @@ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NU */ public function upgrade_5_37_alpha1($rev) { $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); - $this->addTask('core-issue#1845 - Alter Foreign key on civicrm_group to delete when the associated group when the saved search is deleted', 'alterSavedSearchFK'); - $this->addTask('core-issue#2243 - Add note_date to civicrm_note', 'addColumn', + $this->addTask('dev/core#1845 - Alter Foreign key on civicrm_group to delete when the associated group when the saved search is deleted', 'alterSavedSearchFK'); + $this->addTask('dev/core#2243 - Add note_date to civicrm_note', 'addColumn', 'civicrm_note', 'note_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Date attached to the note'"); - $this->addTask('core-issue#2243 - Add created_date to civicrm_note', 'addColumn', + $this->addTask('dev/core#2243 - Add created_date to civicrm_note', 'addColumn', 'civicrm_note', 'created_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the note was created'"); - $this->addTask('core-issue#2243 - Update existing note_date and created_date', 'updateNoteDates'); - $this->addTask('core-issue#2487 Add / alter defaults for civicrm_contribution_recur', 'updateDBDefaultsForContributionRecur'); + $this->addTask('dev/core#2243 - Update existing note_date and created_date', 'updateNoteDates'); + $this->addTask('dev/core#2487 Add / alter defaults for civicrm_contribution_recur', 'updateDBDefaultsForContributionRecur'); $this->addTask('Install reCAPTCHA extension', 'installReCaptchaExtension'); } diff --git a/CRM/Upgrade/Incremental/php/FiveThirtySix.php b/CRM/Upgrade/Incremental/php/FiveThirtySix.php index 78ef2eb8c536..ba0ab2e70bb5 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirtySix.php +++ b/CRM/Upgrade/Incremental/php/FiveThirtySix.php @@ -49,20 +49,20 @@ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NU public function upgrade_5_36_alpha1(string $rev): void { // Not used // $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); - $this->addTask('core-issue#2422 - Add created_id to civicrm_saved_search', 'addColumn', + $this->addTask('dev/core#2422 - Add created_id to civicrm_saved_search', 'addColumn', 'civicrm_saved_search', 'created_id', "int(10) unsigned DEFAULT NULL COMMENT 'FK to contact table.'"); - $this->addTask('core-issue#2422 - Add modified_id to civicrm_saved_search', 'addColumn', + $this->addTask('dev/core#2422 - Add modified_id to civicrm_saved_search', 'addColumn', 'civicrm_saved_search', 'modified_id', "int(10) unsigned DEFAULT NULL COMMENT 'FK to contact table.'"); - $this->addTask('core-issue#2422 - Add expires_date to civicrm_saved_search', 'addColumn', + $this->addTask('dev/core#2422 - Add expires_date to civicrm_saved_search', 'addColumn', 'civicrm_saved_search', 'expires_date', "timestamp NULL DEFAULT NULL COMMENT 'Optional date after which the search is not needed'"); - $this->addTask('core-issue#2422 - Add created_date to civicrm_saved_search', 'addColumn', + $this->addTask('dev/core#2422 - Add created_date to civicrm_saved_search', 'addColumn', 'civicrm_saved_search', 'created_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the search was created.'"); - $this->addTask('core-issue#2422 - Add modified_date to civicrm_saved_search', 'addColumn', + $this->addTask('dev/core#2422 - Add modified_date to civicrm_saved_search', 'addColumn', 'civicrm_saved_search', 'modified_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When the search was last modified.'"); - $this->addTask('core-issue#2422 - Add description to civicrm_saved_search', 'addColumn', + $this->addTask('dev/core#2422 - Add description to civicrm_saved_search', 'addColumn', 'civicrm_saved_search', 'description', "text DEFAULT NULL"); - $this->addTask('core-issue#2422 - Add constraints to civicrm_saved_search', 'taskAddConstraints'); + $this->addTask('dev/core#2422 - Add constraints to civicrm_saved_search', 'taskAddConstraints'); } /** diff --git a/CRM/Upgrade/Incremental/sql/5.3.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.3.alpha1.mysql.tpl index 7c05f9ecaacd..c99948dd6ae0 100644 --- a/CRM/Upgrade/Incremental/sql/5.3.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/5.3.alpha1.mysql.tpl @@ -14,5 +14,5 @@ SET @UKCountryId = (SELECT id FROM civicrm_country cc WHERE cc.name = 'United Ki INSERT IGNORE INTO civicrm_state_province (country_id, abbreviation, name) VALUES (@UKCountryId, 'MON', 'Monmouthshire'); -{* dev/core/#152 *} +{* dev/core#152 *} UPDATE `civicrm_custom_field` set `html_type` = "Multi-Select" WHERE `html_type` = "AdvMulti-Select"; diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 732f14be833f..0fc2ca5b6606 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -770,7 +770,7 @@ function civicrm_api3_contact_getquick($params) { if ($field_name == 'contact_id') { $field_name = 'id'; } - // core#1420 : trim non-numeric character from phone search string + // dev/core#1420 : trim non-numeric character from phone search string elseif ($field_name == 'phone_numeric') { $name = preg_replace('/[^\d]/', '', $name); } diff --git a/release-notes/5.10.0.md b/release-notes/5.10.0.md index e0fc05b64890..4524bf189eaa 100644 --- a/release-notes/5.10.0.md +++ b/release-notes/5.10.0.md @@ -63,7 +63,7 @@ Released February 6, 2019 ### CiviCase -- **[dev-core#564](https://lab.civicrm.org/dev/core/issues/564) Differentiate +- **[dev/core#564](https://lab.civicrm.org/dev/core/issues/564) Differentiate case relationships in Contact Summary page ([13189](https://github.com/civicrm/civicrm-core/pull/13189))** diff --git a/release-notes/5.16.0.md b/release-notes/5.16.0.md index 82cddef0ff1e..39c010b6763f 100644 --- a/release-notes/5.16.0.md +++ b/release-notes/5.16.0.md @@ -363,7 +363,7 @@ Released August 7, 2019 [14625](https://github.com/civicrm/civicrm-core/pull/14625))** - **Improper character encoding breaks xml processor - ([dev-core#1079](https://lab.civicrm.org/dev/core/issues/1079): + ([dev/core#1079](https://lab.civicrm.org/dev/core/issues/1079): [14654](https://github.com/civicrm/civicrm-core/pull/14654))** - **Php 7.2 notices fix on import diff --git a/release-notes/5.56.0.md b/release-notes/5.56.0.md index 48a06ba5b48f..f4e741e57091 100644 --- a/release-notes/5.56.0.md +++ b/release-notes/5.56.0.md @@ -417,7 +417,7 @@ Released December 7, 2022 - **Additional Participants are incorrectly added to group set in profile for primary participant - ([dev/core/#3849](https://lab.civicrm.org/dev/core/-/issues/3849): + ([dev/core#3849](https://lab.civicrm.org/dev/core/-/issues/3849): [24633](https://github.com/civicrm/civicrm-core/pull/24633))** ### CiviMember diff --git a/release-notes/5.9.0.md b/release-notes/5.9.0.md index 687ecddb1f92..e7c307dbc806 100644 --- a/release-notes/5.9.0.md +++ b/release-notes/5.9.0.md @@ -78,7 +78,7 @@ Released January 2, 2019 This change makes it so extension authors can specify phpType and crmType in their xml files. -- **[dev-core#565](https://lab.civicrm.org/dev/core/issues/565) Make subject +- **[dev/core#565](https://lab.civicrm.org/dev/core/issues/565) Make subject field of Note, inline editable in contact summary page ([13190](https://github.com/civicrm/civicrm-core/pull/13190))** diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php index 14e6d8d8e592..d8a0dc4d6e83 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php @@ -1440,7 +1440,7 @@ public function testSendSmsMobilePhoneNumber(): void { /** * Test that when a number is specified in the To Param of the SMS provider parameters that an SMS is sent - * @see dev/core/#273 + * @see dev/core#273 */ public function testSendSMSMobileInToProviderParam(): void { $sent = $this->createSendSmsTest(TRUE, 2, TRUE); @@ -1449,7 +1449,7 @@ public function testSendSMSMobileInToProviderParam(): void { /** * Test that when a numbe ris specified in the To Param of the SMS provider parameters that an SMS is sent - * @see dev/core/#273 + * @see dev/core#273 */ public function testSendSMSMobileInToProviderParamWithDoNotSMS(): void { $sent = $this->createSendSmsTest(FALSE, 2, TRUE, ['do_not_sms' => 1]); diff --git a/tests/phpunit/CRM/Core/BAO/AddressTest.php b/tests/phpunit/CRM/Core/BAO/AddressTest.php index 371440559e14..e1c573bf8f0a 100644 --- a/tests/phpunit/CRM/Core/BAO/AddressTest.php +++ b/tests/phpunit/CRM/Core/BAO/AddressTest.php @@ -726,7 +726,7 @@ public function testSharedAddressChaining3() { } /** - * dev/core#1670 - Ensure that the custom fields on adresses are copied + * dev/dev/core#1670 - Ensure that the custom fields on adresses are copied * to inherited address * 1. test the creation of the shared address with custom field * 2. test the update of the custom field in the master @@ -823,7 +823,7 @@ public function testPinnedCountriesWithOutDefaultCountry() { } /** - * Test core#2379 fix - geocodes shouldn't be > 14 characters. + * Test dev/core#2379 fix - geocodes shouldn't be > 14 characters. */ public function testLongGeocodes() { $contactId = $this->individualCreate(); From 378d5c0bfff1e7ddd2420b6548c85830dc6e0517 Mon Sep 17 00:00:00 2001 From: yashodha Date: Tue, 17 Jan 2023 11:45:19 +0530 Subject: [PATCH 087/106] (dev/core#4084) Assign participant_status_id in both edit/create modes --- CRM/Event/Form/Participant.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 7fe919029e2a..335d1088415a 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -516,7 +516,6 @@ public function setDefaultValues() { $this->assign('participant_is_pay_later', TRUE); } - $this->assign('participant_status_id', $defaults[$this->_id]['participant_status_id']); $eventID = $defaults[$this->_id]['event_id']; $this->_eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventID, 'event_type_id', 'id'); @@ -1025,6 +1024,7 @@ public function submit($params) { $this->_params['participant_status_id'] = $params['status_id']; $this->_params['participant_role_id'] = is_array($params['role_id']) ? $params['role_id'] : explode(',', $params['role_id']); $roleIdWithSeparator = implode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_params['participant_role_id']); + $this->assign('participant_status_id', $params['status_id']); $now = date('YmdHis'); From 77800af0903a0f9095279e38ac38b43f9529ad9c Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Sun, 15 Jan 2023 11:48:47 +0000 Subject: [PATCH 088/106] (NFC) Another batch of PHPDoc fixes --- CRM/Campaign/Form/Task/Release.php | 2 +- CRM/Contact/Tokens.php | 2 +- CRM/Contribute/Form/AdditionalPayment.php | 2 +- CRM/Core/BAO/Address.php | 3 ++- CRM/Core/BAO/Cache.php | 2 +- CRM/Core/BAO/Job.php | 2 +- CRM/Core/Form.php | 10 +++++----- CRM/Core/QuickForm/Action/Upload.php | 1 + CRM/Utils/Mail/Incoming.php | 4 ++-- CRM/Utils/SQL/TempTable.php | 2 +- Civi/Api4/Action/Setting/GetFields.php | 2 +- 11 files changed, 17 insertions(+), 15 deletions(-) diff --git a/CRM/Campaign/Form/Task/Release.php b/CRM/Campaign/Form/Task/Release.php index 4f5605379943..8cfb78ba14b2 100644 --- a/CRM/Campaign/Form/Task/Release.php +++ b/CRM/Campaign/Form/Task/Release.php @@ -21,7 +21,7 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task { /** - * Survet id + * Survey id * * @var int */ diff --git a/CRM/Contact/Tokens.php b/CRM/Contact/Tokens.php index 4dc0cc9236f6..0c558d202f7e 100644 --- a/CRM/Contact/Tokens.php +++ b/CRM/Contact/Tokens.php @@ -183,7 +183,7 @@ protected function getExposedFields(): array { /** * Get the fields exposed from related entities. * - * @return \string[][] + * @return string[][] */ protected function getRelatedEntityTokenMetadata(): array { return [ diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index d3929969298b..97369550449e 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -410,7 +410,7 @@ public function processCreditCard() { if ($paymentParams['amount'] > 0.0) { try { - // force a reget of the payment processor in case the form changed it, CRM-7179 + // force a reset of the payment processor in case the form changed it, CRM-7179 $payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor); $result = $payment->doPayment($paymentParams); } diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index 5b114112fce8..98026c3bc5a5 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -1149,7 +1149,8 @@ public static function processSharedAddressRelationship($masterAddressId, $curre * @param bool $returnStatus * By default false. * - * @return string + * @return array|void + * If ($returnStatus == true) the returned value is an array containing contactList and count */ public static function setSharedAddressDeleteStatus($addressId = NULL, $contactId = NULL, $returnStatus = FALSE) { // check if address that is being deleted has any shared diff --git a/CRM/Core/BAO/Cache.php b/CRM/Core/BAO/Cache.php index c75341193082..77c530f61827 100644 --- a/CRM/Core/BAO/Cache.php +++ b/CRM/Core/BAO/Cache.php @@ -99,7 +99,7 @@ public static function storeSessionToCache($names, $resetSession = TRUE) { /** * Restore session from cache. * - * @param string $names + * @param array $names */ public static function restoreSessionFromCache($names) { foreach ($names as $key => $sessionName) { diff --git a/CRM/Core/BAO/Job.php b/CRM/Core/BAO/Job.php index e07d3b2398a8..aecf92d79dba 100644 --- a/CRM/Core/BAO/Job.php +++ b/CRM/Core/BAO/Job.php @@ -26,7 +26,7 @@ class CRM_Core_BAO_Job extends CRM_Core_DAO_Job { * @param array $params * An assoc array of name/value pairs. * - * @return CRM_Financial_DAO_PaymentProcessorType + * @return CRM_Core_DAO_Job */ public static function create($params) { $job = new CRM_Core_DAO_Job(); diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index d6c526711fc6..f71fb5335bb5 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -416,7 +416,7 @@ public function registerRules() { * For datepicker elements this is consistent with the data * from CRM_Utils_Date::getDatePickerExtra * - * @return HTML_QuickForm_element + * @return HTML_QuickForm_Element * Could be an error object * * @throws \CRM_Core_Exception @@ -1598,7 +1598,7 @@ public function getDefaultContext() { * - context - @see CRM_Core_DAO::buildOptionsContext * @param bool $required * @throws CRM_Core_Exception - * @return HTML_QuickForm_element + * @return HTML_QuickForm_Element */ public function addSelect($name, $props = [], $required = FALSE) { if (!isset($props['entity'])) { @@ -2138,7 +2138,7 @@ public function addDateTime($name, $label, $required = FALSE, $attributes = NULL * @param string $defaultCurrency * @param bool $freezeCurrency * - * @return HTML_QuickForm_element + * @return \HTML_QuickForm_Element */ public function addMoney( $name, @@ -2222,7 +2222,7 @@ public function addCurrency( * - class, etc. - other html properties * @param bool $required * - * @return HTML_QuickForm_element + * @return HTML_QuickForm_Element */ public function addEntityRef($name, $label = '', $props = [], $required = FALSE) { // Default properties @@ -2538,7 +2538,7 @@ public function setPageTitle($entityLabel) { * @param string $elementName * @param array $settings * - * @return HTML_QuickForm_element + * @return HTML_QuickForm_Element */ public function addChainSelect($elementName, $settings = []) { $required = $settings['required'] ?? FALSE; diff --git a/CRM/Core/QuickForm/Action/Upload.php b/CRM/Core/QuickForm/Action/Upload.php index fb999305c41e..c86d0b2f1602 100644 --- a/CRM/Core/QuickForm/Action/Upload.php +++ b/CRM/Core/QuickForm/Action/Upload.php @@ -72,6 +72,7 @@ public function upload(&$page, &$data, $pageName, $uploadName) { // get the element containing the upload $element = &$page->getElement($uploadName); if ('file' == $element->getType()) { + /** @var HTML_QuickForm_file $element */ if ($element->isUploadedFile()) { // rename the uploaded file with a unique number at the end $value = $element->getValue(); diff --git a/CRM/Utils/Mail/Incoming.php b/CRM/Utils/Mail/Incoming.php index ff539d2bd632..d5911ac0156e 100644 --- a/CRM/Utils/Mail/Incoming.php +++ b/CRM/Utils/Mail/Incoming.php @@ -394,7 +394,7 @@ public static function parseMailingObject(&$mail, $createContact = TRUE, $requir } /** - * @param $address + * @param ezcMailAddress $address * @param array $params * @param $subParam * @param $mail @@ -418,7 +418,7 @@ public static function parseAddress(&$address, &$params, &$subParam, &$mail, $cr } /** - * @param $addresses + * @param ezcMailAddress[] $addresses * @param $token * @param array $params * @param $mail diff --git a/CRM/Utils/SQL/TempTable.php b/CRM/Utils/SQL/TempTable.php index 567b282d561b..1a86f130b63f 100644 --- a/CRM/Utils/SQL/TempTable.php +++ b/CRM/Utils/SQL/TempTable.php @@ -156,7 +156,7 @@ public function getUtf8String() { /** * Create the empty table. * - * @parma string $columns + * @param string $columns * SQL column listing. * Ex: 'id int(10), name varchar(64)'. * @return CRM_Utils_SQL_TempTable diff --git a/Civi/Api4/Action/Setting/GetFields.php b/Civi/Api4/Action/Setting/GetFields.php index dab24462689e..2fc022832ace 100644 --- a/Civi/Api4/Action/Setting/GetFields.php +++ b/Civi/Api4/Action/Setting/GetFields.php @@ -15,7 +15,7 @@ /** * Get information about CiviCRM settings. * - * @method int getDomainId + * @method int getDomainId() * @method $this setDomainId(int $domainId) */ class GetFields extends \Civi\Api4\Generic\BasicGetFieldsAction { From e994c00e925dd4e63dd0ecd9f00c480c4c75b862 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Wed, 18 Jan 2023 19:22:36 +0000 Subject: [PATCH 089/106] [REF][PHP8.2] Use const instead of dynamic property: CRM_Contribute_BAO_ContributionPageTest --- .../CRM/Contribute/BAO/ContributionPageTest.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php index 0efa4c5945e8..6961b681c1c2 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php @@ -15,9 +15,10 @@ */ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { + const FINANCIAL_TYPE_ID = 1; + public function setUp(): void { parent::setUp(); - $this->_financialTypeID = 1; } /** @@ -28,7 +29,7 @@ public function testCreate() { $params = [ 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e', 'title' => 'Test Contribution Page', - 'financial_type_id' => $this->_financialTypeID, + 'financial_type_id' => self::FINANCIAL_TYPE_ID, 'intro_text' => '', 'footer_text' => 'Thanks', 'is_for_organization' => 0, @@ -58,7 +59,7 @@ public function testsetIsActive() { $params = [ 'title' => 'Test Contribution Page', - 'financial_type_id' => $this->_financialTypeID, + 'financial_type_id' => self::FINANCIAL_TYPE_ID, 'is_active' => 1, ]; @@ -77,7 +78,7 @@ public function testSetValues() { $params = [ 'title' => 'Test Contribution Page', - 'financial_type_id' => $this->_financialTypeID, + 'financial_type_id' => self::FINANCIAL_TYPE_ID, 'is_active' => 1, ]; @@ -88,7 +89,7 @@ public function testSetValues() { CRM_Contribute_BAO_ContributionPage::setValues($id, $values); $this->assertEquals($params['title'], $values['title'], 'Verify contribution title.'); - $this->assertEquals($this->_financialTypeID, $values['financial_type_id'], 'Verify financial types id.'); + $this->assertEquals(self::FINANCIAL_TYPE_ID, $values['financial_type_id'], 'Verify financial types id.'); $this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.'); $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionPage->id]); } @@ -100,7 +101,7 @@ public function testcopy() { $params = [ 'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e', 'title' => 'Test Contribution Page', - 'financial_type_id' => $this->_financialTypeID, + 'financial_type_id' => self::FINANCIAL_TYPE_ID, 'intro_text' => '', 'footer_text' => 'Thanks', 'is_for_organization' => 0, @@ -118,7 +119,7 @@ public function testcopy() { $contributionPage = CRM_Contribute_BAO_ContributionPage::create($params); $copyContributionPage = CRM_Contribute_BAO_ContributionPage::copy($contributionPage->id); - $this->assertEquals($copyContributionPage->financial_type_id, $this->_financialTypeID, 'Check for Financial type id.'); + $this->assertEquals($copyContributionPage->financial_type_id, self::FINANCIAL_TYPE_ID, 'Check for Financial type id.'); $this->assertEquals($copyContributionPage->goal_amount, 400, 'Check for goal amount.'); $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionPage->id]); $this->callAPISuccess('ContributionPage', 'delete', ['id' => $copyContributionPage->id]); From db33477f3a26cac0ab13311778da092d44c758ba Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Wed, 18 Jan 2023 19:28:24 +0000 Subject: [PATCH 090/106] [REF][PHP8.2] Declare property in CRM_Utils_ZipTest --- tests/phpunit/CRM/Utils/ZipTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/phpunit/CRM/Utils/ZipTest.php b/tests/phpunit/CRM/Utils/ZipTest.php index 9cb51eec2b36..e0cc7fe2113a 100644 --- a/tests/phpunit/CRM/Utils/ZipTest.php +++ b/tests/phpunit/CRM/Utils/ZipTest.php @@ -15,6 +15,12 @@ */ class CRM_Utils_ZipTest extends CiviUnitTestCase { + /** + * Reference to filename, to allow cleanup in tearDown + * @var string|false + */ + private $file = FALSE; + public function setUp(): void { parent::setUp(); $this->file = FALSE; From 5d909b8b59f3a184a0ee214024e17ff19f2ab27d Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Wed, 18 Jan 2023 19:54:27 +0000 Subject: [PATCH 091/106] [REF][PHP8.2] Avoid dynamic properties in api_v3_EventTest --- tests/phpunit/api/v3/EventTest.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index a9debb622a49..8cce80bc11c5 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -18,6 +18,16 @@ class api_v3_EventTest extends CiviUnitTestCase { protected $_apiversion; protected $_entity; + /** + * @var int[] + */ + protected $_eventIds = []; + + /** + * @var array + */ + protected $_events = []; + public function setUp(): void { parent::setUp(); $this->_apiversion = 3; @@ -72,8 +82,8 @@ public function setUp(): void { ], ]; - $this->events = []; - $this->eventIds = []; + $this->_events = []; + $this->_eventIds = []; foreach ($params as $event) { $result = $this->callAPISuccess('Event', 'Create', $event); $this->_events[] = $result; @@ -82,9 +92,6 @@ public function setUp(): void { } public function tearDown(): void { - foreach ($this->eventIds as $eventId) { - $this->eventDelete($eventId); - } $tablesToTruncate = [ 'civicrm_participant', 'civicrm_event', From a1f6e59084a39421fec9a90fe7bf96a3fba6eb54 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Wed, 18 Jan 2023 19:16:46 +0000 Subject: [PATCH 092/106] Paypal: Stop passing component when it exists on the class --- CRM/Core/Payment/PayPalImpl.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index acc2fe3aeb75..df8a8512dde8 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -500,11 +500,11 @@ public function doPayment(&$params, $component = 'contribute') { } if ($this->_paymentProcessor['billing_mode'] == 4) { - $this->doPaymentRedirectToPayPal($params, $component); + $this->doPaymentRedirectToPayPal($params); // redirect calls CiviExit() so execution is stopped } else { - $result = $this->doPaymentPayPalButton($params, $component); + $result = $this->doPaymentPayPalButton($params); if (is_array($result) && !isset($result['payment_status_id'])) { if (!empty($params['is_recur'])) { $result = $this->setStatusPaymentPending($result); @@ -537,12 +537,11 @@ public function doDirectPayment(&$params) { * @param array $params * Assoc array of input parameters for this transaction. * - * @param string $component * @return array * the result in an nice formatted array (or an error object) * @throws \Civi\Payment\Exception\PaymentProcessorException */ - public function doPaymentPayPalButton(&$params, $component = 'contribute') { + public function doPaymentPayPalButton(&$params) { $args = []; $result = $this->setStatusPaymentPending([]); @@ -590,7 +589,7 @@ public function doPaymentPayPalButton(&$params, $component = 'contribute') { $args['totalbillingcycles'] = $params['installments'] ?? NULL; $args['version'] = 56.0; $args['PROFILEREFERENCE'] = "" . - "i=" . $params['invoiceID'] . "&m=" . $component . + "i=" . $params['invoiceID'] . "&m=" . $this->_component . "&c=" . $params['contactID'] . "&r=" . $params['contributionRecurID'] . "&b=" . $params['contributionID'] . "&p=" . $params['contributionPageID']; } @@ -915,12 +914,11 @@ public function doTransferCheckout(&$params, $component = 'contribute') { /** * @param array $params - * @param string $component * * @throws Exception */ - public function doPaymentRedirectToPayPal(&$params, $component = 'contribute') { - $notifyParameters = ['module' => $component]; + public function doPaymentRedirectToPayPal(&$params) { + $notifyParameters = ['module' => $this->_component]; $notifyParameterMap = [ 'contactID' => 'contactID', 'contributionID' => 'contributionID', @@ -941,8 +939,8 @@ public function doPaymentRedirectToPayPal(&$params, $component = 'contribute') { $notifyURL = $this->getNotifyUrl(); $config = CRM_Core_Config::singleton(); - $url = ($component == 'event') ? 'civicrm/event/register' : 'civicrm/contribute/transact'; - $cancel = ($component == 'event') ? '_qf_Register_display' : '_qf_Main_display'; + $url = ($this->_component == 'event') ? 'civicrm/event/register' : 'civicrm/contribute/transact'; + $cancel = ($this->_component == 'event') ? '_qf_Register_display' : '_qf_Main_display'; $cancelUrlString = "$cancel=1&cancel=1&qfKey={$params['qfKey']}"; if (!empty($params['is_recur'])) { From 1f15ad571276c4973099c20675a097f7e7d9fa7d Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Wed, 18 Jan 2023 19:55:05 +0000 Subject: [PATCH 093/106] Paypal: Use getBaseReturnUrl() function --- CRM/Core/Payment/PayPalImpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index df8a8512dde8..87ed5d31fd20 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -939,7 +939,7 @@ public function doPaymentRedirectToPayPal(&$params) { $notifyURL = $this->getNotifyUrl(); $config = CRM_Core_Config::singleton(); - $url = ($this->_component == 'event') ? 'civicrm/event/register' : 'civicrm/contribute/transact'; + $url = $this->getBaseReturnUrl(); $cancel = ($this->_component == 'event') ? '_qf_Register_display' : '_qf_Main_display'; $cancelUrlString = "$cancel=1&cancel=1&qfKey={$params['qfKey']}"; From d6bf90ee7ec827019a8377c7a4174c043f56fc94 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Wed, 18 Jan 2023 20:00:33 +0000 Subject: [PATCH 094/106] Payment: getCancelUrl participant default value of NULL --- CRM/Core/Payment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 2280a1699f26..84e47800bcd8 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -1175,11 +1175,11 @@ protected function getAmount($params = []) { * Get url to return to after cancelled or failed transaction. * * @param string $qfKey - * @param int $participantID + * @param int|NULL $participantID * * @return string cancel url */ - public function getCancelUrl($qfKey, $participantID) { + public function getCancelUrl($qfKey, $participantID = NULL) { if (isset($this->cancelUrl)) { return $this->cancelUrl; } From 3d04e917eb04784bb40114f5d15448fc7907b35d Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Wed, 18 Jan 2023 20:01:16 +0000 Subject: [PATCH 095/106] Paypal (express): Pass participantID to getCancelUrl() if available --- CRM/Core/Payment/PayPalImpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index 87ed5d31fd20..220d4e9a2fd6 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -255,7 +255,7 @@ protected function setExpressCheckOut(&$params) { $args['desc'] = $params['description'] ?? NULL; $args['invnum'] = $params['invoiceID']; $args['returnURL'] = $this->getReturnSuccessUrl($params['qfKey']); - $args['cancelURL'] = $this->getCancelUrl($params['qfKey'], NULL); + $args['cancelURL'] = $this->getCancelUrl($params['qfKey'], $params['participantID'] ?? NULL); $args['version'] = '56.0'; $args['SOLUTIONTYPE'] = 'Sole'; From 9ffd78de31ed823edc6687054e1c7512234f32f7 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Wed, 18 Jan 2023 20:01:53 +0000 Subject: [PATCH 096/106] Paypal: Use standard functions for cancelUrl / notifyUrl --- CRM/Core/Payment/PayPalImpl.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index 220d4e9a2fd6..bbaa04114c52 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -936,30 +936,15 @@ public function doPaymentRedirectToPayPal(&$params) { $notifyParameters[$notifyName] = $params[$paramsName]; } } - $notifyURL = $this->getNotifyUrl(); - $config = CRM_Core_Config::singleton(); - $url = $this->getBaseReturnUrl(); - $cancel = ($this->_component == 'event') ? '_qf_Register_display' : '_qf_Main_display'; - - $cancelUrlString = "$cancel=1&cancel=1&qfKey={$params['qfKey']}"; - if (!empty($params['is_recur'])) { - $cancelUrlString .= "&isRecur=1&recurId={$params['contributionRecurID']}&contribId={$params['contributionID']}"; - } - - $cancelURL = CRM_Utils_System::url( - $url, - $cancelUrlString, - TRUE, NULL, FALSE - ); $paypalParams = [ 'business' => $this->_paymentProcessor['user_name'], - 'notify_url' => $notifyURL, + 'notify_url' => $this->getNotifyUrl(), 'item_name' => $this->getPaymentDescription($params, 127), 'quantity' => 1, 'undefined_quantity' => 0, - 'cancel_return' => $cancelURL, + 'cancel_return' => $this->getCancelUrl($params['qfKey'], $params['participantID'] ?? NULL), 'no_note' => 1, 'no_shipping' => 1, 'return' => $this->getReturnSuccessUrl($params['qfKey']), From 957707335de345698396a2922594656b4d3e2740 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 18 Jan 2023 15:59:18 -0800 Subject: [PATCH 097/106] (dev/core#4055) ClassLoader - Use separate cache IDs for different configurations of modules --- CRM/Extension/ClassLoader.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CRM/Extension/ClassLoader.php b/CRM/Extension/ClassLoader.php index 9ca81638bff8..7f84b083a955 100644 --- a/CRM/Extension/ClassLoader.php +++ b/CRM/Extension/ClassLoader.php @@ -179,7 +179,12 @@ private static function loadExtension(\Composer\Autoload\ClassLoader $loader, CR * @return string */ protected function getCacheFile() { - $envId = \CRM_Core_Config_Runtime::getId(); + $envId = md5(implode(',', array_merge( + [\CRM_Core_Config_Runtime::getId()], + array_column($this->mapper->getActiveModuleFiles(), 'prefix') + // dev/core#4055 - When toggling ext's on systems with opcode caching, you may get stale reads for a moment. + // New cache key ensures new data-set. + ))); $file = \Civi::paths()->getPath("[civicrm.compile]/CachedExtLoader.{$envId}.php"); return $file; } From f76dfa8883f90e3d1ce77edd755bc3100bd71883 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 19 Jan 2023 12:47:39 +1300 Subject: [PATCH 098/106] dev/core#4088 Superficial cleanup on Api4testBase --- .../Civi/Afform/AfformContactSummaryTest.php | 3 +- .../api/v4/SearchDisplay/SearchRunTest.php | 3 +- .../SearchRunWithCustomFieldTest.php | 3 +- .../CRM/Report/Form/ContactSummaryTest.php | 6 +- .../api/v4/Action/AutocompleteTest.php | 3 +- .../api/v4/Action/BasicActionsTest.php | 3 +- .../api/v4/Action/ContactIsDeletedTest.php | 3 +- tests/phpunit/api/v4/Api4TestBase.php | 92 ++++++++++--------- 8 files changed, 66 insertions(+), 50 deletions(-) diff --git a/ext/afform/core/tests/phpunit/Civi/Afform/AfformContactSummaryTest.php b/ext/afform/core/tests/phpunit/Civi/Afform/AfformContactSummaryTest.php index 21aafaeb5ffb..ab2aca9b4ffd 100644 --- a/ext/afform/core/tests/phpunit/Civi/Afform/AfformContactSummaryTest.php +++ b/ext/afform/core/tests/phpunit/Civi/Afform/AfformContactSummaryTest.php @@ -5,6 +5,7 @@ require_once __DIR__ . '/../../../../../../../tests/phpunit/api/v4/Api4TestBase.php'; use Civi\Api4\Afform; +use Civi\Test\CiviEnvBuilder; /** * @group headless @@ -19,7 +20,7 @@ class AfformContactSummaryTest extends \api\v4\Api4TestBase { 'contact_summary_test5', ]; - public function setUpHeadless() { + public function setUpHeadless(): CiviEnvBuilder { return \Civi\Test::headless()->installMe(__DIR__)->install('org.civicrm.search_kit')->apply(); } diff --git a/ext/search_kit/tests/phpunit/api/v4/SearchDisplay/SearchRunTest.php b/ext/search_kit/tests/phpunit/api/v4/SearchDisplay/SearchRunTest.php index 819d3b879f86..985d00024812 100644 --- a/ext/search_kit/tests/phpunit/api/v4/SearchDisplay/SearchRunTest.php +++ b/ext/search_kit/tests/phpunit/api/v4/SearchDisplay/SearchRunTest.php @@ -14,6 +14,7 @@ use Civi\Api4\SavedSearch; use Civi\Api4\SearchDisplay; use Civi\Api4\UFMatch; +use Civi\Test\CiviEnvBuilder; use Civi\Test\TransactionalInterface; /** @@ -22,7 +23,7 @@ class SearchRunTest extends Api4TestBase implements TransactionalInterface { use \Civi\Test\ACLPermissionTrait; - public function setUpHeadless() { + public function setUpHeadless(): CiviEnvBuilder { // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile(). // See: https://docs.civicrm.org/dev/en/latest/testing/phpunit/#civitest return \Civi\Test::headless() diff --git a/ext/search_kit/tests/phpunit/api/v4/SearchDisplay/SearchRunWithCustomFieldTest.php b/ext/search_kit/tests/phpunit/api/v4/SearchDisplay/SearchRunWithCustomFieldTest.php index 0e5bf6776946..9497758b1024 100644 --- a/ext/search_kit/tests/phpunit/api/v4/SearchDisplay/SearchRunWithCustomFieldTest.php +++ b/ext/search_kit/tests/phpunit/api/v4/SearchDisplay/SearchRunWithCustomFieldTest.php @@ -10,13 +10,14 @@ use Civi\Api4\Contact; use Civi\Api4\CustomField; use Civi\Api4\CustomGroup; +use Civi\Test\CiviEnvBuilder; /** * @group headless */ class SearchRunWithCustomFieldTest extends CustomTestBase { - public function setUpHeadless() { + public function setUpHeadless(): CiviEnvBuilder { return \Civi\Test::headless() ->installMe(__DIR__) ->apply(); diff --git a/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php b/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php index 83cc4cf686da..5fda40038fee 100644 --- a/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php +++ b/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php @@ -30,7 +30,7 @@ public function setUp(): void { /** * Ensure the new Odd/Event street number sort column works correctly */ - public function testOddEvenStreetNumber() { + public function testOddEvenStreetNumber(): void { $customLocationType = $this->callAPISuccess('LocationType', 'create', [ 'name' => 'Custom Location Type', 'display_name' => 'CiviTest Custom Location Type', @@ -195,9 +195,9 @@ public function testOddEvenStreetNumber() { } /** - * Test that Loation Type prints out a sensible piece of data + * Test that Location Type prints out a sensible piece of data */ - public function testLocationTypeIdHandling() { + public function testLocationTypeIdHandling(): void { $customLocationType = $this->callAPISuccess('LocationType', 'create', [ 'name' => 'Custom Location Type', 'display_name' => 'CiviTest Custom Location Type', diff --git a/tests/phpunit/api/v4/Action/AutocompleteTest.php b/tests/phpunit/api/v4/Action/AutocompleteTest.php index 5b81a57b378e..d26d18539e81 100644 --- a/tests/phpunit/api/v4/Action/AutocompleteTest.php +++ b/tests/phpunit/api/v4/Action/AutocompleteTest.php @@ -25,6 +25,7 @@ use Civi\Api4\MockBasicEntity; use Civi\Api4\SavedSearch; use Civi\Core\Event\GenericHookEvent; +use Civi\Test\CiviEnvBuilder; use Civi\Test\HookInterface; use Civi\Test\TransactionalInterface; @@ -54,7 +55,7 @@ public function on_civi_api_prepare(\Civi\API\Event\PrepareEvent $event) { } } - public function setUpHeadless() { + public function setUpHeadless(): CiviEnvBuilder { // TODO: search_kit should probably be part of the 'headless()' baseline. return \Civi\Test::headless()->install(['org.civicrm.search_kit'])->apply(); } diff --git a/tests/phpunit/api/v4/Action/BasicActionsTest.php b/tests/phpunit/api/v4/Action/BasicActionsTest.php index f9668e094d0e..fad0c8f079cc 100644 --- a/tests/phpunit/api/v4/Action/BasicActionsTest.php +++ b/tests/phpunit/api/v4/Action/BasicActionsTest.php @@ -23,6 +23,7 @@ use Civi\Api4\MockBasicEntity; use Civi\Api4\Utils\CoreUtil; use Civi\Core\Event\GenericHookEvent; +use Civi\Test\CiviEnvBuilder; use Civi\Test\HookInterface; use Civi\Test\TransactionalInterface; @@ -40,7 +41,7 @@ public function on_civi_api4_entityTypes(GenericHookEvent $e): void { $e->entities['MockBasicEntity'] = MockBasicEntity::getInfo(); } - public function setUpHeadless() { + public function setUpHeadless(): CiviEnvBuilder { // Ensure MockBasicEntity gets added via above listener \Civi::cache('metadata')->clear(); return parent::setUpHeadless(); diff --git a/tests/phpunit/api/v4/Action/ContactIsDeletedTest.php b/tests/phpunit/api/v4/Action/ContactIsDeletedTest.php index 82f92012058c..cc09b40a2693 100644 --- a/tests/phpunit/api/v4/Action/ContactIsDeletedTest.php +++ b/tests/phpunit/api/v4/Action/ContactIsDeletedTest.php @@ -20,6 +20,7 @@ namespace api\v4\Action; use api\v4\Api4TestBase; +use Civi\Test\CiviEnvBuilder; use Civi\Test\TransactionalInterface; /** @@ -27,7 +28,7 @@ */ class ContactIsDeletedTest extends Api4TestBase implements TransactionalInterface { - public function setUpHeadless() { + public function setUpHeadless(): CiviEnvBuilder { $relatedTables = [ 'civicrm_address', 'civicrm_email', diff --git a/tests/phpunit/api/v4/Api4TestBase.php b/tests/phpunit/api/v4/Api4TestBase.php index 41a7b7e59482..3cec8ce020d0 100644 --- a/tests/phpunit/api/v4/Api4TestBase.php +++ b/tests/phpunit/api/v4/Api4TestBase.php @@ -19,8 +19,10 @@ namespace api\v4; +use Civi\Api4\Generic\Result; use Civi\Api4\UFMatch; use Civi\Api4\Utils\CoreUtil; +use Civi\Test\CiviEnvBuilder; use Civi\Test\HeadlessInterface; /** @@ -47,16 +49,19 @@ public function __construct($name = NULL, array $data = [], $dataName = '') { error_reporting(E_ALL); } - public function setUpHeadless() { + public function setUpHeadless(): CiviEnvBuilder { return \Civi\Test::headless()->apply(); } /** + * Post test cleanup. + * + * @throws \CRM_Core_Exception */ public function tearDown(): void { - $impliments = class_implements($this); + $implements = class_implements($this); // If not created in a transaction, test records must be deleted - if (!in_array('Civi\Test\TransactionalInterface', $impliments, TRUE)) { + if (!in_array('Civi\Test\TransactionalInterface', $implements, TRUE)) { // Delete all test records in reverse order to prevent fk constraints foreach (array_reverse($this->testRecords) as $record) { $params = ['checkPermissions' => FALSE, 'where' => $record[1]]; @@ -78,28 +83,30 @@ public function tearDown(): void { * * @param array $params */ - public function cleanup($params) { + public function cleanup(array $params): void { $params += [ 'tablesToTruncate' => [], ]; - \CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS = 0;"); + \CRM_Core_DAO::executeQuery('SET FOREIGN_KEY_CHECKS = 0;'); foreach ($params['tablesToTruncate'] as $table) { \Civi::log()->info('truncating: ' . $table); $sql = "TRUNCATE TABLE $table"; \CRM_Core_DAO::executeQuery($sql); } - \CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS = 1;"); + \CRM_Core_DAO::executeQuery('SET FOREIGN_KEY_CHECKS = 1;'); } /** * Emulate a logged in user since certain functions use that. * value to store a record in the DB (like activity) + * * @see https://issues.civicrm.org/jira/browse/CRM-8180 * * @return int * Contact ID of the created user. + * @throws \CRM_Core_Exception */ - public function createLoggedInUser() { + public function createLoggedInUser(): int { $contactID = $this->createTestRecord('Contact')['id']; UFMatch::delete(FALSE)->addWhere('uf_id', '=', 6)->execute(); $this->createTestRecord('UFMatch', [ @@ -124,7 +131,7 @@ public function createLoggedInUser() { * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\NotImplementedException */ - public function createTestRecord(string $entityName, array $values = []) { + public function createTestRecord(string $entityName, array $values = []): ?array { return $this->saveTestRecords($entityName, ['records' => [$values]])->single(); } @@ -139,7 +146,7 @@ public function createTestRecord(string $entityName, array $values = []) { * @throws \CRM_Core_Exception * @throws \Civi\API\Exception\NotImplementedException */ - public function saveTestRecords(string $entityName, array $saveParams) { + public function saveTestRecords(string $entityName, array $saveParams): Result { $saveParams += [ 'checkPermissions' => FALSE, 'defaults' => [], @@ -163,7 +170,7 @@ public function saveTestRecords(string $entityName, array $saveParams) { * @param int $len * @return string */ - public function randomLetters(int $len = 10) { + public function randomLetters(int $len = 10): string { return \CRM_Utils_String::createRandom($len, implode('', range('a', 'z'))); } @@ -176,7 +183,7 @@ public function randomLetters(int $len = 10) { * @return array * @throws \CRM_Core_Exception */ - public function getRequiredValuesToCreate(string $entity, &$values = []) { + public function getRequiredValuesToCreate(string $entity, array &$values = []): array { $requiredFields = civicrm_api4($entity, 'getfields', [ 'action' => 'create', 'loadOptions' => TRUE, @@ -185,7 +192,7 @@ public function getRequiredValuesToCreate(string $entity, &$values = []) { ['OR', [ ['required', '=', TRUE], - // Include contitionally-required fields only if they don't create a circular FK reference + // Include conditionally-required fields only if they don't create a circular FK reference ['AND', [['required_if', 'IS NOT EMPTY'], ['fk_entity', '!=', $entity]]], ], ], @@ -226,51 +233,51 @@ public function getRequiredValuesToCreate(string $entity, &$values = []) { case 'CaseType': $extraValues['definition'] = [ - "activityTypes" => [ + 'activityTypes' => [ [ - "name" => "Open Case", - "max_instances" => "1", + 'name' => 'Open Case', + 'max_instances' => 1, ], [ - "name" => "Follow up", + 'name' => 'Follow up', ], ], - "activitySets" => [ + 'activitySets' => [ [ - "name" => "standard_timeline", - "label" => "Standard Timeline", - "timeline" => 1, - "activityTypes" => [ + 'name' => 'standard_timeline', + 'label' => 'Standard Timeline', + 'timeline' => 1, + 'activityTypes' => [ [ - "name" => "Open Case", - "status" => "Completed", + 'name' => 'Open Case', + 'status' => 'Completed', ], [ - "name" => "Follow up", - "reference_activity" => "Open Case", - "reference_offset" => "3", - "reference_select" => "newest", + 'name' => 'Follow up', + 'reference_activity' => 'Open Case', + 'reference_offset' => 3, + 'reference_select' => 'newest', ], ], ], ], - "timelineActivityTypes" => [ + 'timelineActivityTypes' => [ [ - "name" => "Open Case", - "status" => "Completed", + 'name' => 'Open Case', + 'status' => 'Completed', ], [ - "name" => "Follow up", - "reference_activity" => "Open Case", - "reference_offset" => "3", - "reference_select" => "newest", + 'name' => 'Follow up', + 'reference_activity' => 'Open Case', + 'reference_offset' => 3, + 'reference_select' => 'newest', ], ], - "caseRoles" => [ + 'caseRoles' => [ [ - "name" => "Parent of", - "creator" => "1", - "manager" => "1", + 'name' => 'Parent of', + 'creator' => 1, + 'manager' => 1, ], ], ]; @@ -288,7 +295,7 @@ public function getRequiredValuesToCreate(string $entity, &$values = []) { * @param array $field * * @return mixed - * @throws \Exception + * @throws \CRM_Core_Exception */ private function getRequiredValue(array $field) { if (!empty($field['options'])) { @@ -332,7 +339,7 @@ private function getRequiredValue(array $field) { * * @throws \CRM_Core_Exception */ - private function getFkID(string $fkEntity) { + private function getFkID(string $fkEntity): int { $params = ['checkPermissions' => FALSE]; // Be predictable about what type of contact we select if ($fkEntity === 'Contact') { @@ -351,6 +358,9 @@ private function getFkID(string $fkEntity) { * @param $dataType * * @return int|null|string + * + * @noinspection PhpUnhandledExceptionInspection + * @noinspection PhpDocMissingThrowsInspection */ private function getRandomValue($dataType) { switch ($dataType) { @@ -367,7 +377,7 @@ private function getRandomValue($dataType) { return $this->randomLetters(100); case 'Money': - return sprintf('%d.%2d', rand(0, 2000), rand(10, 99)); + return sprintf('%d.%2d', random_int(0, 2000), random_int(10, 99)); case 'Date': return '20100102'; From 29b825ac98adc828ccc2bfb9923f47376899d3b0 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Wed, 18 Jan 2023 20:16:02 -0500 Subject: [PATCH 099/106] undefined vars --- CRM/Case/Form/ActivityView.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CRM/Case/Form/ActivityView.php b/CRM/Case/Form/ActivityView.php index 771d33d498ba..44cae6ca68d7 100644 --- a/CRM/Case/Form/ActivityView.php +++ b/CRM/Case/Form/ActivityView.php @@ -90,6 +90,7 @@ public function preProcess() { $this->assign('latestRevisionID', $latestRevisionID); } else { + $this->assign('revs', 0); if (count($viewPriorActivities) > 1) { $this->assign('activityID', $activityID); } @@ -100,9 +101,7 @@ public function preProcess() { } $parentID = CRM_Activity_BAO_Activity::getParentActivity($activityID); - if ($parentID) { - $this->assign('parentID', $parentID); - } + $this->assign('parentID', $parentID ?? NULL); //viewing activity should get diplayed in recent list.CRM-4670 $activityTypeID = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, 'activity_type_id'); From 4f2c7623b16b1f74bbc3d1c2911e9ac86eb508de Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Wed, 18 Jan 2023 20:12:33 -0500 Subject: [PATCH 100/106] undefined array keys --- CRM/Case/Selector/Search.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CRM/Case/Selector/Search.php b/CRM/Case/Selector/Search.php index 9b430eea8bfd..d2f958f194bc 100644 --- a/CRM/Case/Selector/Search.php +++ b/CRM/Case/Selector/Search.php @@ -622,6 +622,8 @@ public static function actionLinks() { 'url' => 'civicrm/case/activity/view', 'qs' => 'reset=1&cid=%%cid%%&caseid=%%caseid%%&aid=%%aid%%', 'title' => ts('View'), + 'accessKey' => '', + 'ref' => 'View', ], CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), @@ -629,6 +631,8 @@ public static function actionLinks() { 'qs' => 'reset=1&cid=%%cid%%&caseid=%%caseid%%&id=%%aid%%&action=update%%cxt%%', 'title' => ts('Edit'), 'icon' => 'fa-pencil', + 'accessKey' => '', + 'ref' => 'Edit', ], CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), @@ -636,6 +640,8 @@ public static function actionLinks() { 'qs' => 'reset=1&cid=%%cid%%&caseid=%%caseid%%&id=%%aid%%&action=delete%%cxt%%', 'title' => ts('Delete'), 'icon' => 'fa-trash', + 'accessKey' => '', + 'ref' => 'Delete', ], CRM_Core_Action::RENEW => [ 'name' => ts('Restore'), @@ -643,6 +649,8 @@ public static function actionLinks() { 'qs' => 'reset=1&cid=%%cid%%&caseid=%%caseid%%&id=%%aid%%&action=renew%%cxt%%', 'title' => ts('Restore'), 'icon' => 'fa-undo', + 'accessKey' => '', + 'ref' => 'Restore', ], CRM_Core_Action::DETACH => [ 'name' => ts('Move To Case'), @@ -650,6 +658,7 @@ public static function actionLinks() { 'title' => ts('Move To Case'), 'extra' => 'onclick = "Javascript:fileOnCase( \'move\', %%aid%%, %%caseid%%, this ); return false;"', 'icon' => 'fa-clipboard', + 'accessKey' => '', ], CRM_Core_Action::COPY => [ 'name' => ts('Copy To Case'), @@ -657,6 +666,7 @@ public static function actionLinks() { 'title' => ts('Copy To Case'), 'extra' => 'onclick = "Javascript:fileOnCase( \'copy\', %%aid%%, %%caseid%%, this ); return false;"', 'icon' => 'fa-files-o', + 'accessKey' => '', ], ]; } From ab6a83ea9635ffed6305dccb28562a98f5b26f92 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 18 Jan 2023 23:49:25 -0800 Subject: [PATCH 101/106] (NFC) Mixin Tests - Add more typehints --- mixin/case-xml@1/example/tests/mixin/CaseTypeTest.php | 8 ++++---- .../example/tests/mixin/EntityTypesTest.php | 8 ++++---- mixin/menu-xml@1/example/tests/mixin/MenuXmlTest.php | 8 ++++---- .../mgd-php@1/example/tests/mixin/ManagedCaseTypeTest.php | 8 ++++---- mixin/mgd-php@1/example/tests/mixin/ManagedTest.php | 8 ++++---- .../example/tests/mixin/ScanClassesTest.php | 8 ++++---- mixin/setting-php@1/example/tests/mixin/SettingsTest.php | 8 ++++---- .../shimmy/tests/phpunit/E2E/Shimmy/LifecycleTest.php | 2 +- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/mixin/case-xml@1/example/tests/mixin/CaseTypeTest.php b/mixin/case-xml@1/example/tests/mixin/CaseTypeTest.php index 099a364d3bc7..1ea01841b516 100644 --- a/mixin/case-xml@1/example/tests/mixin/CaseTypeTest.php +++ b/mixin/case-xml@1/example/tests/mixin/CaseTypeTest.php @@ -12,11 +12,11 @@ */ class CaseTypeTest extends \PHPUnit\Framework\Assert { - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/xml/case/DuckDance.xml'), 'The shimmy extension must have a Case XML file.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'DuckDance']]]); $this->assertEquals('The mysterious case of the dancing duck', $items[0]['description']); $this->assertEquals('DuckDance', $items[0]['name']); @@ -35,7 +35,7 @@ public function testInstalled($cv) { $this->assertEquals(TRUE, $actTypes[0]['is_active'], 'ActivityType "Quack" should be auto enabled. It\'s inactive.'); } - public function testDisabled($cv) { + public function testDisabled($cv): void { $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'DuckDance']]]); $this->assertEquals('The mysterious case of the dancing duck', $items[0]['description']); $this->assertEquals('DuckDance', $items[0]['name']); @@ -44,7 +44,7 @@ public function testDisabled($cv) { $this->assertEquals(1, count($items)); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'DuckDance']]]); $this->assertEquals(0, count($items)); diff --git a/mixin/entity-types-php@1/example/tests/mixin/EntityTypesTest.php b/mixin/entity-types-php@1/example/tests/mixin/EntityTypesTest.php index b8e3cc35952c..a6013c8a9d28 100644 --- a/mixin/entity-types-php@1/example/tests/mixin/EntityTypesTest.php +++ b/mixin/entity-types-php@1/example/tests/mixin/EntityTypesTest.php @@ -18,26 +18,26 @@ class EntityTypesTest extends \PHPUnit\Framework\Assert { const EXAMPLE_NAME = 'ShimThing'; - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/xml/schema/CRM/Shimmy/ShimThing.xml'), 'The shimmy extension must have *.xml.'); $this->assertFileExists(static::getPath('/xml/schema/CRM/Shimmy/ShimThing.entityType.php'), 'The shimmy extension must have *.entityTYpe.php.'); $this->assertFileExists(static::getPath('/CRM/Shimmy/DAO/ShimThing.php'), 'The shimmy extension must have DAO.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { $this->assertEquals(self::EXAMPLE_NAME, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getBriefName', [self::EXAMPLE_DAO])); $this->assertEquals(self::EXAMPLE_TABLE, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getTableForClass', [self::EXAMPLE_DAO])); $this->assertEquals(self::EXAMPLE_NAME, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getEntityNameForTable', [self::EXAMPLE_TABLE])); $this->assertEquals('ShimThing ID', $cv->phpEval('return \CRM_Shimmy_DAO_ShimThing::fields()["id"]["title"];')); } - public function testDisabled($cv) { + public function testDisabled($cv): void { $this->assertEquals(NULL, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getBriefName', [self::EXAMPLE_DAO])); $this->assertEquals(NULL, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getTableForClass', [self::EXAMPLE_DAO])); $this->assertEquals(NULL, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getEntityNameForTable', [self::EXAMPLE_TABLE])); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { $this->assertEquals(NULL, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getBriefName', [self::EXAMPLE_DAO])); $this->assertEquals(NULL, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getTableForClass', [self::EXAMPLE_DAO])); $this->assertEquals(NULL, $cv->phpCall('CRM_Core_DAO_AllCoreTables::getEntityNameForTable', [self::EXAMPLE_TABLE])); diff --git a/mixin/menu-xml@1/example/tests/mixin/MenuXmlTest.php b/mixin/menu-xml@1/example/tests/mixin/MenuXmlTest.php index fc56b839691c..c3878c946b68 100644 --- a/mixin/menu-xml@1/example/tests/mixin/MenuXmlTest.php +++ b/mixin/menu-xml@1/example/tests/mixin/MenuXmlTest.php @@ -18,11 +18,11 @@ class MenuXmlTest extends \PHPUnit\Framework\Assert { */ protected $url; - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/xml/Menu/shimmy.xml'), 'The shimmy extension must have a Menu XML file.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { // The menu item is registered... $items = $cv->api4('Route', 'get', ['where' => [['path', '=', 'civicrm/shimmy/foobar']]]); $this->assertEquals('CRM_Shimmy_Page_FooBar', $items[0]['page_callback']); @@ -34,7 +34,7 @@ public function testInstalled($cv) { $this->assertRegExp(';hello world;', $response); } - public function testDisabled($cv) { + public function testDisabled($cv): void { $items = $cv->api4('Route', 'get', ['where' => [['path', '=', 'civicrm/shimmy/foobar']]]); $this->assertEmpty($items); @@ -44,7 +44,7 @@ public function testDisabled($cv) { $this->assertNotRegExp(';HTTP.*200.*;', $http_response_header[0]); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { // Same as disabled. $this->testDisabled($cv); } diff --git a/mixin/mgd-php@1/example/tests/mixin/ManagedCaseTypeTest.php b/mixin/mgd-php@1/example/tests/mixin/ManagedCaseTypeTest.php index 270a5faf7ab8..9137c5a2725a 100644 --- a/mixin/mgd-php@1/example/tests/mixin/ManagedCaseTypeTest.php +++ b/mixin/mgd-php@1/example/tests/mixin/ManagedCaseTypeTest.php @@ -12,11 +12,11 @@ */ class ManagedCaseTypeTest extends \PHPUnit\Framework\Assert { - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/CRM/BunnyDance.mgd.php'), 'The shimmy extension must have a Case MGD file.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'BunnyDance']]]); $this->assertEquals('The mysterious case of the dancing bunny', $items[0]['description']); $this->assertEquals('BunnyDance', $items[0]['name']); @@ -33,7 +33,7 @@ public function testInstalled($cv) { // $this->assertEquals(TRUE, $actTypes[0]['is_active'], 'ActivityType "Nibble" should be auto enabled. It\'s inactive.'); } - public function testDisabled($cv) { + public function testDisabled($cv): void { $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'BunnyDance']]]); $this->assertEquals('The mysterious case of the dancing bunny', $items[0]['description']); $this->assertEquals('BunnyDance', $items[0]['name']); @@ -42,7 +42,7 @@ public function testDisabled($cv) { $this->assertEquals(1, count($items)); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'BunnyDance']]]); $this->assertEquals(0, count($items)); diff --git a/mixin/mgd-php@1/example/tests/mixin/ManagedTest.php b/mixin/mgd-php@1/example/tests/mixin/ManagedTest.php index 0ac5cc657923..39d3e0684292 100644 --- a/mixin/mgd-php@1/example/tests/mixin/ManagedTest.php +++ b/mixin/mgd-php@1/example/tests/mixin/ManagedTest.php @@ -12,23 +12,23 @@ */ class ManagedTest extends \PHPUnit\Framework\Assert { - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/CRM/ShimmyGroup.mgd.php'), 'The shimmy extension must have a Menu XML file.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { $items = $cv->api4('OptionGroup', 'get', ['where' => [['name', '=', 'shimmy_group']]]); $this->assertEquals('Shimmy Group', $items[0]['title']); $this->assertEquals(TRUE, $items[0]['is_active']); } - public function testDisabled($cv) { + public function testDisabled($cv): void { $items = $cv->api4('OptionGroup', 'get', ['where' => [['name', '=', 'shimmy_group']]]); $this->assertEquals('Shimmy Group', $items[0]['title']); $this->assertEquals(FALSE, $items[0]['is_active']); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { $items = $cv->api4('OptionGroup', 'get', ['where' => [['name', '=', 'shimmy_group']]]); $this->assertEmpty($items); } diff --git a/mixin/scan-classes@1/example/tests/mixin/ScanClassesTest.php b/mixin/scan-classes@1/example/tests/mixin/ScanClassesTest.php index c664c96d1deb..47c5438572c8 100644 --- a/mixin/scan-classes@1/example/tests/mixin/ScanClassesTest.php +++ b/mixin/scan-classes@1/example/tests/mixin/ScanClassesTest.php @@ -12,11 +12,11 @@ */ class ScanClassesTest extends \PHPUnit\Framework\Assert { - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/CRM/Shimmy/ShimmyMessage.php'), 'The shimmy extension must have example PHP files.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { // Assert that WorkflowMessageInterface's are registered. $items = $cv->api4('WorkflowMessage', 'get', ['where' => [['name', '=', 'shimmy_message_example']]]); $this->assertEquals('CRM_Shimmy_ShimmyMessage', $items[0]['class']); @@ -33,7 +33,7 @@ public function testInstalled($cv) { $this->assertEquals($expectHookData, $hookData); } - public function testDisabled($cv) { + public function testDisabled($cv): void { // Assert that WorkflowMessageInterface's are removed. $items = $cv->api4('WorkflowMessage', 'get', ['where' => [['name', '=', 'shimmy_message_example']]]); $this->assertEmpty($items); @@ -43,7 +43,7 @@ public function testDisabled($cv) { $this->assertEquals([], $hookData); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { // Assert that WorkflowMessageInterface's are removed. $items = $cv->api4('WorkflowMessage', 'get', ['where' => [['name', '=', 'shimmy_message_example']]]); $this->assertEmpty($items); diff --git a/mixin/setting-php@1/example/tests/mixin/SettingsTest.php b/mixin/setting-php@1/example/tests/mixin/SettingsTest.php index 2ea5e9981bc0..f62380fb98df 100644 --- a/mixin/setting-php@1/example/tests/mixin/SettingsTest.php +++ b/mixin/setting-php@1/example/tests/mixin/SettingsTest.php @@ -12,11 +12,11 @@ */ class SettingsTest extends \PHPUnit\Framework\Assert { - public function testPreConditions($cv) { + public function testPreConditions($cv): void { $this->assertFileExists(static::getPath('/settings/Shimmy.setting.php'), 'The shimmy extension must have a Menu XML file.'); } - public function testInstalled($cv) { + public function testInstalled($cv): void { // The menu item is registered... $items = $cv->api4('Setting', 'getFields', ['where' => [['name', '=', 'shimmy_example']], 'loadOptions' => TRUE]); $this->assertEquals('shimmy_example', $items[0]['name']); @@ -34,7 +34,7 @@ public function testInstalled($cv) { $this->assertEquals('second', $value); } - public function testDisabled($cv) { + public function testDisabled($cv): void { $items = $cv->api4('Setting', 'getFields', ['where' => [['name', '=', 'shimmy_example']], 'loadOptions' => TRUE]); $this->assertEmpty($items); @@ -42,7 +42,7 @@ public function testDisabled($cv) { $this->assertEquals('second', $value); } - public function testUninstalled($cv) { + public function testUninstalled($cv): void { $items = $cv->api4('Setting', 'getFields', ['where' => [['name', '=', 'shimmy_example']], 'loadOptions' => TRUE]); $this->assertEmpty($items); diff --git a/tests/extensions/shimmy/tests/phpunit/E2E/Shimmy/LifecycleTest.php b/tests/extensions/shimmy/tests/phpunit/E2E/Shimmy/LifecycleTest.php index f80850e2654b..b4c3ebf02713 100644 --- a/tests/extensions/shimmy/tests/phpunit/E2E/Shimmy/LifecycleTest.php +++ b/tests/extensions/shimmy/tests/phpunit/E2E/Shimmy/LifecycleTest.php @@ -88,7 +88,7 @@ protected static function getPath($suffix = ''): string { return dirname(__DIR__, 4) . $suffix; } - protected function runMethods(string $method, ...$args) { + protected function runMethods(string $method, ...$args): void { if (empty($this->mixinTests)) { $this->fail('Cannot run methods. No mixin tests found.'); } From db1cf50b183c1013f0e140fbfb5a513e2e3bdc2c Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 19 Jan 2023 10:11:42 -0500 Subject: [PATCH 102/106] OptionGroup - Add paths metadata --- CRM/Core/DAO/OptionGroup.php | 12 +++++++++++- xml/schema/Core/OptionGroup.xml | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CRM/Core/DAO/OptionGroup.php b/CRM/Core/DAO/OptionGroup.php index 9f909157efc1..8d1e0b423ad3 100644 --- a/CRM/Core/DAO/OptionGroup.php +++ b/CRM/Core/DAO/OptionGroup.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/OptionGroup.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:1d5fad72032ebfdfdce93a4b29f97542) + * (GenCodeChecksum:cccb007e18d25b34d3af8fd583ade04b) */ /** @@ -37,6 +37,16 @@ class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO { */ public static $_log = TRUE; + /** + * Paths for accessing this entity in the UI. + * + * @var string[] + */ + protected static $_paths = [ + 'add' => 'civicrm/admin/options?action=add&reset=1', + 'update' => 'civicrm/admin/options?action=update&reset=1&id=[id]', + ]; + /** * Option Group ID * diff --git a/xml/schema/Core/OptionGroup.xml b/xml/schema/Core/OptionGroup.xml index 25469867cbd0..84c8db327682 100644 --- a/xml/schema/Core/OptionGroup.xml +++ b/xml/schema/Core/OptionGroup.xml @@ -6,6 +6,10 @@ civicrm_option_group 1.5 true + + civicrm/admin/options?action=add&reset=1 + civicrm/admin/options?action=update&reset=1&id=[id] + id Option Group ID From e98e62a53d8b6e1356c11fc58725bbac2fd5fb26 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Thu, 19 Jan 2023 20:41:44 +0000 Subject: [PATCH 103/106] [REF][PHP8.2] Avoid dynamic property in CRM_SMS_ProviderTest --- tests/phpunit/CRM/SMS/ProviderTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/SMS/ProviderTest.php b/tests/phpunit/CRM/SMS/ProviderTest.php index 9bf2993bb6eb..ba87f805ec23 100644 --- a/tests/phpunit/CRM/SMS/ProviderTest.php +++ b/tests/phpunit/CRM/SMS/ProviderTest.php @@ -21,7 +21,13 @@ class CRM_SMS_ProviderTest extends CiviUnitTestCase { /** - * Set Up Funtion + * ID of option_value record created in setUp + * @var int + */ + private $option_value; + + /** + * Set Up Function */ public function setUp(): void { parent::setUp(); @@ -42,7 +48,7 @@ public function tearDown(): void { * CRM-20238 Add test of the processInbound function for SMSs */ public function testProcessInbound() { - $testSourceContact = $this->individualCreate(['phone' => [1 => ['phone_type_id' => 'Phone', 'location_type_id' => 'Home', 'phone' => '+61487654321']]]); + $this->individualCreate(['phone' => [1 => ['phone_type_id' => 'Phone', 'location_type_id' => 'Home', 'phone' => '+61487654321']]]); $provider = new CiviTestSMSProvider('CiviTestSMSProvider'); $result = $provider->processInbound('+61412345678', 'This is a test message', '+61487654321'); $this->assertEquals('This is a test message', $result->details); From d43caadf5e94b9ed3608c4eda92992810e1f7bf2 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 20 Jan 2023 10:25:23 +1300 Subject: [PATCH 104/106] Make otherwise unused form function private --- CRM/Contribute/Form/ContributionBase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 80a51f4cb93f..c31e6ee9afb8 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -393,7 +393,7 @@ public function preProcess() { $pledgeId, 'campaign_id' ); - self::authenticatePledgeUser(); + $this->authenticatePledgeUser(); } } $this->set('values', $this->_values); @@ -1052,7 +1052,7 @@ public function overrideExtraTemplateFileName() { * * @throws \CRM_Core_Exception */ - public function authenticatePledgeUser() { + private function authenticatePledgeUser(): void { //get the userChecksum and contact id $userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this); $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); From 9726426b5f4b8a781c4291e327459d8912936c3d Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 20 Jan 2023 00:39:00 +0000 Subject: [PATCH 105/106] [REF][PHP8.2] Fix Deprecated Dynamic class properties in Legacy custom searches extension --- .../CRM/Contact/Form/Search/Custom/Group.php | 54 +++++++++++++++++++ .../phpunit/Civi/Searches/FullTextTest.php | 6 +++ 2 files changed, 60 insertions(+) diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/Group.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/Group.php index 7eabd91dadcd..f63bdb2f5a43 100644 --- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/Group.php +++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/Group.php @@ -67,6 +67,60 @@ class CRM_Contact_Form_Search_Custom_Group extends CRM_Contact_Form_Search_Custo protected $_aclFrom = NULL; protected $_aclWhere = NULL; + /** + * Include Groups + * @var array + */ + protected $_includeGroups; + + /** + * Exclude Groups + * @var array + */ + protected $_excludeGroups; + + /** + * Include Tags + * @var array + */ + protected $_includeTags; + + /** + * Exclude Tags + * @var array + */ + protected $_excludeTags; + + /** + * All Search + * @var bool + */ + protected $_allSearch; + + /** + * Does this search use groups + * @var bool + */ + protected $_groups; + + /** + * Does this search use tags + * @var bool + */ + protected $_tags; + + /** + * Is this search And or OR search + * @var string + */ + protected $_andOr; + + /** + * Search Columns + * @var array + */ + protected $_columns; + /** * Class constructor. * diff --git a/ext/legacycustomsearches/tests/phpunit/Civi/Searches/FullTextTest.php b/ext/legacycustomsearches/tests/phpunit/Civi/Searches/FullTextTest.php index bf2e9cd78968..47dce216fec2 100644 --- a/ext/legacycustomsearches/tests/phpunit/Civi/Searches/FullTextTest.php +++ b/ext/legacycustomsearches/tests/phpunit/Civi/Searches/FullTextTest.php @@ -29,6 +29,12 @@ */ class FullTextTest extends TestCase implements HeadlessInterface, HookInterface, TransactionalInterface { + /** + * Entity ids created as part of test + * @var array + */ + protected $ids; + use Test\ContactTestTrait; use Test\Api3TestTrait; From 2fa95a7966ab1e739da7326d84c79b6e0ff8a2e1 Mon Sep 17 00:00:00 2001 From: larssandergreen Date: Tue, 24 Jan 2023 11:39:25 -0700 Subject: [PATCH 106/106] Fix missing default values for event registration setup --- CRM/Event/Form/ManageEvent/Registration.php | 16 +++++++++------- .../CRM/Event/Form/ManageEvent/Registration.tpl | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CRM/Event/Form/ManageEvent/Registration.php b/CRM/Event/Form/ManageEvent/Registration.php index c2b186cddd4b..5b35e8ae87a0 100644 --- a/CRM/Event/Form/ManageEvent/Registration.php +++ b/CRM/Event/Form/ManageEvent/Registration.php @@ -116,8 +116,7 @@ public function setDefaultValues() { $defaults["custom_post_id_multiple[$key]"] = $value; } } - - $this->assign('profilePostMultiple', CRM_Utils_Array::value('custom_post', $defaults)); + $this->assign('profilePostMultiple', $defaults['custom_post'] ?? NULL); // CRM-17745: Make max additional participants configurable if (empty($defaults['max_additional_participants'])) { @@ -149,7 +148,7 @@ public function setDefaultValues() { $defaults["additional_custom_post_id_multiple[$key]"] = $value; } } - $this->assign('profilePostMultipleAdd', CRM_Utils_Array::value('additional_custom_post', $defaults, [])); + $this->assign('profilePostMultipleAdd', $defaults['additional_custom_post'] ?? []); } else { // Avoid PHP notices in the template @@ -161,10 +160,10 @@ public function setDefaultValues() { } // provide defaults for required fields if empty (and as a 'hint' for approval message field) - $defaults['registration_link_text'] = CRM_Utils_Array::value('registration_link_text', $defaults, ts('Register Now')); - $defaults['confirm_title'] = CRM_Utils_Array::value('confirm_title', $defaults, ts('Confirm Your Registration Information')); - $defaults['thankyou_title'] = CRM_Utils_Array::value('thankyou_title', $defaults, ts('Thank You for Registering')); - $defaults['approval_req_text'] = CRM_Utils_Array::value('approval_req_text', $defaults, ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.')); + $defaults['registration_link_text'] = $defaults['registration_link_text'] ?? ts('Register Now'); + $defaults['confirm_title'] = $defaults['confirm_title'] ?? ts('Confirm Your Registration Information'); + $defaults['thankyou_title'] = $defaults['thankyou_title'] ?? ts('Thank You for Registering'); + $defaults['approval_req_text'] = $defaults['approval_req_text'] ?? ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.'); return $defaults; } @@ -442,6 +441,9 @@ public function addRules() { public static function formRule($values, $files, $form) { if (!empty($values['is_online_registration'])) { + if (!$values['registration_link_text']) { + $errorMsg['registration_link_text'] = ts('Please enter Registration Link Text'); + } if (!$values['confirm_title']) { $errorMsg['confirm_title'] = ts('Please enter a Title for the registration Confirmation Page'); } diff --git a/templates/CRM/Event/Form/ManageEvent/Registration.tpl b/templates/CRM/Event/Form/ManageEvent/Registration.tpl index c3db65bb90d1..946aaa4ebf64 100644 --- a/templates/CRM/Event/Form/ManageEvent/Registration.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Registration.tpl @@ -50,7 +50,7 @@ {$form.registration_link_text.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='registration_link_text' id=$eventID}{/if} + width="20%">{$form.registration_link_text.label} *{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='registration_link_text' id=$eventID}{/if} {$form.registration_link_text.html} {help id="id-link_text"} {if !$isTemplate}