Skip to content
Snippets Groups Projects
Commit 363567d2 authored by mattwire's avatar mattwire
Browse files

Enhance getErrorUrl function and fixes for CiviCRM 5.27+

parent cd36bfd1
No related branches found
No related tags found
No related merge requests found
...@@ -278,17 +278,25 @@ trait CRM_Core_Payment_MJWTrait { ...@@ -278,17 +278,25 @@ trait CRM_Core_Payment_MJWTrait {
*/ */
public function getErrorUrl($params) { public function getErrorUrl($params) {
// Get proper entry URL for returning on error. // Get proper entry URL for returning on error.
if (!$params->has('qfKey')) { if (!$params->has('qfKey') || !$params->has('entryURL')) {
// Probably not called from a civicrm form (e.g. webform) - // Probably not called from a civicrm form (e.g. webform) -
// will return error object to original api caller. // will return error object to original api caller.
return NULL; $errorUrl = NULL;
} }
else { else {
$qfKey = $params->getCustomProperty('qfKey'); $qfKey = $params->getCustomProperty('qfKey');
$parsed_url = parse_url($params->getCustomProperty('entryURL')); $parsedUrl = parse_url($params->getCustomProperty('entryURL'));
$url_path = substr($parsed_url['path'], 1); $urlPath = substr($parsedUrl['path'], 1);
return CRM_Utils_System::url($url_path, $parsed_url['query'] . "&_qf_Main_display=1&qfKey={$qfKey}", FALSE, NULL, FALSE); $query = $parsedUrl['query'];
if (strpos($query, '_qf_Main_display=1') === FALSE) {
$query .= '&_qf_Main_display=1';
}
if (strpos($query, 'qfKey=') === FALSE) {
$query .= "&qfKey={$qfKey}";
}
$errorUrl = CRM_Utils_System::url($urlPath, $query, FALSE, NULL, FALSE);
} }
return $errorUrl;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment