From afa4f120182ba676179f21d1974cc5a28f2a2e9a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 10 Jun 2022 12:08:52 -0400 Subject: [PATCH] Deduepe - Fix form buttons (again) Fixes dev/core#3421 Also see dev/core#3135 And the original cause: a6f2a80 --- CRM/Contact/Form/Merge.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/CRM/Contact/Form/Merge.php b/CRM/Contact/Form/Merge.php index 0dca67a009..ef27927a44 100644 --- a/CRM/Contact/Form/Merge.php +++ b/CRM/Contact/Form/Merge.php @@ -328,14 +328,13 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { CRM_Core_Session::setStatus($message, ts('Contacts Merged'), 'success'); $urlParams = ['reset' => 1, 'cid' => $this->_cid, 'rgid' => $this->_rgid, 'gid' => $this->_gid, 'limit' => $this->limit, 'criteria' => $this->criteria]; - $contactViewUrl = CRM_Utils_System::url('civicrm/contact/view', ['reset' => 1, 'cid' => $this->_cid]); + // When clicking "Merge and go to listing" if (!empty($formValues['_qf_Merge_submit'])) { $urlParams['action'] = "update"; - CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/contact/dedupefind', - $urlParams - )); + CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlParams)); } + // When clicking "Merge and go to next pair" elseif ($this->next && $this->_mergeId && empty($formValues['_qf_Merge_done'])) { $cacheKey = CRM_Dedupe_Merger::getMergeCacheKeyString($this->_rgid, $this->_gid, json_decode($this->criteria, TRUE), TRUE, $this->limit); @@ -353,12 +352,15 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $urlParams['oid'] = $pos['next']['id2']; $urlParams['mergeId'] = $pos['next']['mergeId']; $urlParams['action'] = 'update'; - CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/contact/merge', $urlParams)); + CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/merge', $urlParams)); } } - else { - CRM_Core_Session::singleton()->pushUserContext($contactViewUrl); - } + // When clicking "Merge and View Result" or when used from search forms + // Note: search might load this action in a popup, so cannot use a redirect. + $contactViewUrl = CRM_Utils_System::url('civicrm/contact/view', ['reset' => 1, 'cid' => $this->_cid]); + CRM_Core_Session::singleton()->pushUserContext($contactViewUrl); + // I think this bit is needed because this is a multi-step form. + $this->controller->setDestination($contactViewUrl); } /** -- 2.25.1