Skip to content

Commit

Permalink
Merge pull request #21032 from seamuslee001/master
Browse files Browse the repository at this point in the history
5.40 up merge
  • Loading branch information
seamuslee001 authored Aug 5, 2021
2 parents 0f3c4f4 + 706bfa2 commit bb45b1f
Show file tree
Hide file tree
Showing 16 changed files with 220 additions and 46 deletions.
2 changes: 2 additions & 0 deletions CRM/Admin/Form/ScheduleReminders.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ public function parseActionSchedule($values) {
'end_frequency_interval',
'end_action',
'end_date',
'effective_end_date',
'effective_start_date',
];

if (empty($params['absolute_date'])) {
Expand Down
62 changes: 48 additions & 14 deletions CRM/Contact/BAO/GroupContactCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,14 @@ public static function load($group, $force = FALSE) {
self::invalidateGroupContactCache($group->id);
}

$locks = self::getLocksForRefreshableGroupsTo([$groupID]);
foreach ($locks as $groupID => $lock) {
$lockedGroups = self::getLocksForRefreshableGroupsTo([$groupID]);
foreach ($lockedGroups as $groupID) {
$groupContactsTempTable = CRM_Utils_SQL_TempTable::build()
->setCategory('gccache')
->setMemory();
self::buildGroupContactTempTable([$groupID], $groupContactsTempTable);
self::updateCacheFromTempTable($groupContactsTempTable, [$groupID]);
$lock->release();
self::releaseGroupLocks([$groupID]);
}
}

Expand All @@ -402,9 +402,8 @@ protected static function getLocksForRefreshableGroupsTo(array $groupIDs): array
$locks = [];
$groupIDs = self::getGroupsNeedingRefreshing($groupIDs);
foreach ($groupIDs as $groupID) {
$lock = Civi::lockManager()->acquire("data.core.group.{$groupID}");
if ($lock->isAcquired()) {
$locks[$groupID] = $lock;
if (self::getGroupLock($groupID)) {
$locks[] = $groupID;
}
}
return $locks;
Expand Down Expand Up @@ -709,9 +708,9 @@ public static function populateTemporaryTableWithContactsInGroups(array $groupID
$groupContactsTempTable = CRM_Utils_SQL_TempTable::build()
->setCategory('gccache')
->setMemory();
$locks = self::getLocksForRefreshableGroupsTo($smartGroups);
if (!empty($locks)) {
self::buildGroupContactTempTable(array_keys($locks), $groupContactsTempTable);
$lockedGroups = self::getLocksForRefreshableGroupsTo($smartGroups);
if (!empty($lockedGroups)) {
self::buildGroupContactTempTable($lockedGroups, $groupContactsTempTable);
// Note in theory we could do this transfer from the temp
// table to the group_contact_cache table out-of-process - possibly by
// continuing on after the browser is released (which seems to be
Expand All @@ -725,11 +724,8 @@ public static function populateTemporaryTableWithContactsInGroups(array $groupID
// Also - if we switched to the 'triple union' approach described above
// we could throw a try-catch around this line since best-effort would
// be good enough & potentially improve user experience.
self::updateCacheFromTempTable($groupContactsTempTable, array_keys($locks));

foreach ($locks as $lock) {
$lock->release();
}
self::updateCacheFromTempTable($groupContactsTempTable, $lockedGroups);
self::releaseGroupLocks($lockedGroups);
}

$smartGroups = implode(',', $smartGroups);
Expand Down Expand Up @@ -900,4 +896,42 @@ protected static function insertGroupContactsIntoTempTable(string $tempTableName
}
}

/**
* Get a lock, if available, for the given group.
*
* @param int $groupID
*
* @return bool
* @throws \CRM_Core_Exception
*/
protected static function getGroupLock(int $groupID): bool {
$cacheKey = "data.core.group.$groupID";
if (isset(Civi::$statics["data.core.group.$groupID"])) {
// Loop avoidance for a circular parent-child situation.
// This would occur where the parent is a criteria of the child
// but needs to resolve the child to resolve itself.
// This has a unit test - testGroupWithParentInCriteria
return FALSE;
}
$lock = Civi::lockManager()->acquire($cacheKey);
if ($lock->isAcquired()) {
Civi::$statics["data.core.group.$groupID"] = $lock;
return TRUE;
}
return FALSE;
}

/**
* Release locks on the groups.
*
* @param array $groupIDs
*/
protected static function releaseGroupLocks(array $groupIDs): void {
foreach ($groupIDs as $groupID) {
$lock = Civi::$statics["data.core.group.$groupID"];
$lock->release();
unset(Civi::$statics["data.core.group.$groupID"]);
}
}

}
10 changes: 3 additions & 7 deletions CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -5791,7 +5791,7 @@ public function filterRelatedContacts(&$from, &$where, &$having) {
INNER JOIN $tableName transform_temp ON ( transform_temp.contact_id = displayRelType.contact_id_a OR transform_temp.contact_id = displayRelType.contact_id_b )
";
$qcache['where'] = "
AND displayRelType.relationship_type_id = {$this->_displayRelationshipType}
WHERE displayRelType.relationship_type_id = {$this->_displayRelationshipType}
AND displayRelType.is_active = 1
";
}
Expand All @@ -5812,7 +5812,7 @@ public function filterRelatedContacts(&$from, &$where, &$having) {
";
}
$qcache['where'] = "
AND displayRelType.relationship_type_id = $relType
WHERE displayRelType.relationship_type_id = $relType
AND displayRelType.is_active = 1
";
}
Expand All @@ -5836,14 +5836,10 @@ public function filterRelatedContacts(&$from, &$where, &$having) {
else {
$from .= $qcache['from'];
}
if (!strlen($where)) {
$where = " WHERE 1 ";
}
$where .= $qcache['where'];
$where = $qcache['where'];
if (!empty($this->_tables['civicrm_case'])) {
// Change the join on CiviCRM case so that it joins on the right contac from the relationship.
$from = str_replace("ON civicrm_case_contact.contact_id = contact_a.id", "ON civicrm_case_contact.contact_id = transform_temp.contact_id", $from);
$where = str_replace("AND civicrm_case_contact.contact_id = contact_a.id", "AND civicrm_case_contact.contact_id = transform_temp.contact_id", $where);
$where .= " AND displayRelType.case_id = civicrm_case_contact.case_id ";
}
if (!empty($this->_permissionFromClause) && !stripos($from, 'aclContactCache')) {
Expand Down
4 changes: 3 additions & 1 deletion CRM/Contribute/Form/Task/TaskTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public function getIDs() {
* @throws \CRM_Core_Exception
*/
protected function calculateIDS() {
if ($this->controller->get('id')) {
// contact search forms use the id property to store the selected uf_group_id
// rather than entity (contribution) IDs, so don't use the property in that case
if (!$this->controller instanceof CRM_Contact_Controller_Search && $this->controller->get('id')) {
return explode(',', $this->controller->get('id'));
}
$ids = $this->getSelectedIDs($this->getSearchFormValues());
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ public function buildEventFeeForm($form) {

//retrieve custom information
$form->_values = [];
CRM_Event_Form_Registration::initEventFee($form, $event['id']);
CRM_Event_Form_Registration::initEventFee($form, $event['id'], FALSE);
CRM_Event_Form_Registration_Register::buildAmount($form, TRUE, $form->_discountId);
$lineItem = [];
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
Expand Down
2 changes: 1 addition & 1 deletion CRM/Price/BAO/PriceSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,11 @@ public static function getSetDetail($setID, $required = TRUE, $doNotIncludeExpir
$where = "
WHERE price_set_id = %1
AND is_active = 1
AND ( active_on IS NULL OR active_on <= {$currentTime} )
";
$dateSelect = '';
if ($doNotIncludeExpiredFields) {
$dateSelect = "
AND ( active_on IS NULL OR active_on <= {$currentTime} )
AND ( expire_on IS NULL OR expire_on >= {$currentTime} )
";
}
Expand Down
2 changes: 1 addition & 1 deletion ext/recaptcha/recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function recaptcha_civicrm_entityTypes(&$entityTypes) {
* Implements hook_civicrm_navigationMenu().
*/
function recaptcha_civicrm_navigationMenu(&$menu) {
_recaptcha_civix_insert_navigation_menu($menu, 'Administer/Customize Data and Screens', [
_recaptcha_civix_insert_navigation_menu($menu, 'Administer/System Settings', [
'label' => E::ts('reCAPTCHA Settings'),
'name' => 'recaptcha_settings',
'url' => 'civicrm/admin/setting/recaptcha',
Expand Down
2 changes: 2 additions & 0 deletions ext/recaptcha/xml/Menu/recaptcha.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<item>
<path>civicrm/admin/setting/recaptcha</path>
<title>reCAPTCHA Settings</title>
<desc>Configure anti-abuse/bot-prevention service</desc>
<page_callback>CRM_Admin_Form_Generic</page_callback>
<access_arguments>administer CiviCRM</access_arguments>
<adminGroup>System Settings</adminGroup>
</item>
</menu>
10 changes: 7 additions & 3 deletions js/crm.ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
mode = CRM.config && CRM.config.isFrontend ? 'front' : 'back';
}
query = query || '';
var url,
frag = path.split('?');
var url, frag, hash = '';
if (path.indexOf('#') > -1) {
hash = '#' + path.split('#')[1];
path = path.split('#')[0];
}
frag = path.split('?');
// Encode url path only if slashes in placeholder were also encoded
if (tplURL[mode].indexOf('civicrm/placeholder-url-path') >= 0) {
url = tplURL[mode].replace('civicrm/placeholder-url-path', frag[0]);
Expand All @@ -39,7 +43,7 @@
if (frag[1]) {
url += (url.indexOf('?') < 0 ? '?' : '&') + frag[1];
}
return url;
return url + hash;
};

$.fn.crmURL = function () {
Expand Down
10 changes: 9 additions & 1 deletion release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Other resources for identifying changes are:

## CiviCRM 5.40.0

Released August 4, 2021
Released August 5, 2021

- **[Synopsis](release-notes/5.40.0.md#synopsis)**
- **[Features](release-notes/5.40.0.md#features)**
Expand All @@ -26,6 +26,14 @@ Released August 4, 2021
- **[Credits](release-notes/5.40.0.md#credits)**
- **[Feedback](release-notes/5.40.0.md#feedback)**

## CiviCRM 5.39.1

Released August 5, 2021

- **[Synopsis](release-notes/5.39.1.md#synopsis)**
- **[Bugs resolved](release-notes/5.39.1.md#bugs)**
- **[Credits](release-notes/5.39.1.md#credits)**
- **[Feedback](release-notes/5.39.1.md#feedback)**

## CiviCRM 5.39.0

Expand Down
45 changes: 45 additions & 0 deletions release-notes/5.39.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# CiviCRM 5.39.1

Released August 5, 2021

- **[Synopsis](#synopsis)**
- **[Bugs resolved](#bugs)**
- **[Credits](#credits)**
- **[Feedback](#feedback)**

## <a name="synopsis"></a>Synopsis

| *Does this version...?* | |
| --------------------------------------------------------------- | -------- |
| Change the database schema? | no |
| Alter the API? | no |
| Require attention to configuration options? | no |
| Fix problems installing or upgrading to a previous version? | no |
| Introduce features? | no |
| **Fix bugs?** | **yes** |

## <a name="bugs"></a>Bugs resolved

* **_ACLs_: Circular group resolution ([dev/core#2725](https://lab.civicrm.org/dev/core/-/issues/2725): [#21012](https://github.com/civicrm/civicrm-core/pull/21012))**
* **_Advanced Search_: Related contacts are not displayed ([dev/core#2707](https://lab.civicrm.org/dev/core/-/issues/2707): [#21016](https://github.com/civicrm/civicrm-core/pull/21016))**
* **_CiviContribute_: Search-tasks sometimes receive wrong contribution IDs ([dev/core#2739](https://lab.civicrm.org/dev/core/-/issues/2739): [#21014](https://github.com/civicrm/civicrm-core/pull/21014))**
* **_CiviEvent_: Always expose price fields on backend ([dev/event#62](https://lab.civicrm.org/dev/event/-/issues/62): [#21028](https://github.com/civicrm/civicrm-core/pull/21028))**
* **_ReCAPTCHA_: Restore administrative hyperlink ([dev/core#2728](https://lab.civicrm.org/dev/core/-/issues/2728): [#21017](https://github.com/civicrm/civicrm-core/pull/21017))**
* **_Smart Groups_: Scheduled job fails with error "must be of the type int" ([dev/core#2687](https://lab.civicrm.org/dev/core/-/issues/2687): [#20835](https://github.com/civicrm/civicrm-core/pull/20835))**
* **_WordPress_: Fix generation of URL fragments ([#21020](https://github.com/civicrm/civicrm-core/pull/21020/))**

## <a name="credits"></a>Credits

This release was developed by the following authors and reviewers:

Wikimedia Foundation - Eileen McNaughton; Tadpole Collective - Kevin Cristiano; Progressive Technology Project - Jamie
McClelland; pcurrier; Megaphone Technology Consulting - Jon Goldberg; MJW Consulting - Matthew Wire; Lighthouse
Consulting and Design - Brian Shaughnessy; John Gehrig; JMA Consulting - Seamus Lee; Greenpeace Central and Eastern
Europe - Patrick Figel; Gahrt; Fuzion - Peter Davis; Francesc Bassas i Bullich; Dave Tarrant; Dave D; CiviCoop - Jaap
Jansma; CiviCRM - Coleman Watts, Tim Otten; Centrale Organisatie van Voetbal Scheidsrechters (COVS) - Ed van Leeuwen

## <a name="feedback"></a>Feedback

These release notes are edited by Tim Otten and Andrew Hunt. If you'd like to
provide feedback on them, please login to https://chat.civicrm.org/civicrm and
contact `@agh1`.
6 changes: 5 additions & 1 deletion release-notes/5.40.0.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CiviCRM 5.40.0

Released August 4, 2021
Released August 5, 2021

- **[Synopsis](#synopsis)**
- **[Features](#features)**
Expand Down Expand Up @@ -454,6 +454,10 @@ Released August 4, 2021

### CiviContribute

- **Error submitting contribution form if ""is_monetary=0""
([dev/wordpress#109](https://lab.civicrm.org/dev/wordpress/-/issues/109):
[#20929](https://github.com/civicrm/civicrm-core/pull/20929))**

- **Can't remove previously-added currencies
([dev/financial#175](https://lab.civicrm.org/dev/financial/-/issues/175):
[20627](https://github.com/civicrm/civicrm-core/pull/20627))**
Expand Down
10 changes: 5 additions & 5 deletions tests/phpunit/CRM/Case/BAO/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,16 @@ public function testFindCasesQuery() {
*
* @throws \Exception
*/
public function testAdvancedSearchWithDisplayRelationshipsAndCaseType() {
// Preperation
$benefitRelationshipTypeId = civicrm_api3('RelationshipType', 'getvalue', ['return' => 'id', 'name_a_b' => 'Benefits Specialist is']);
public function testAdvancedSearchWithDisplayRelationshipsAndCaseType(): void {
$this->markTestIncomplete('temporarily disabled as https://github.com/civicrm/civicrm-core/pull/20002 reverted for now');
$benefitRelationshipTypeId = $this->callAPISuccess('RelationshipType', 'getvalue', ['return' => 'id', 'name_a_b' => 'Benefits Specialist is']);
$clientContactID = $this->individualCreate(['first_name' => 'John', 'last_name' => 'Smith']);
$benefitSpecialist1 = $this->individualCreate(['Individual', 'first_name' => 'Alexa', 'last_name' => 'Clarke']);
$benefitSpecialist2 = $this->individualCreate(['Individual', 'first_name' => 'Sandra', 'last_name' => 'Johnson']);
$housingSupportCase = $this->createCase($clientContactID, NULL, ['case_type' => 'housing_support', 'case_type_id' => 1]);
$adultDayCareReferralCase = $this->createCase($clientContactID, NULL, ['case_type' => 'adult_day_care_referral', 'case_type_id' => 2]);
civicrm_api3('Relationship', 'create', ['contact_id_a' => $clientContactID, 'contact_id_b' => $benefitSpecialist1, 'relationship_type_id' => $benefitRelationshipTypeId, 'case_id' => $housingSupportCase->id]);
civicrm_api3('Relationship', 'create', ['contact_id_a' => $clientContactID, 'contact_id_b' => $benefitSpecialist2, 'relationship_type_id' => $benefitRelationshipTypeId, 'case_id' => $adultDayCareReferralCase->id]);
$this->callAPISuccess('Relationship', 'create', ['contact_id_a' => $clientContactID, 'contact_id_b' => $benefitSpecialist1, 'relationship_type_id' => $benefitRelationshipTypeId, 'case_id' => $housingSupportCase->id]);
$this->callAPISuccess('Relationship', 'create', ['contact_id_a' => $clientContactID, 'contact_id_b' => $benefitSpecialist2, 'relationship_type_id' => $benefitRelationshipTypeId, 'case_id' => $adultDayCareReferralCase->id]);

// Search setup
$formValues = ['display_relationship_type' => $benefitRelationshipTypeId . '_b_a', 'case_type_id' => 1];
Expand Down
Loading

0 comments on commit bb45b1f

Please sign in to comment.