Skip to content

Commit

Permalink
Refs #40326, Add handling to parse numeric string values in contribut…
Browse files Browse the repository at this point in the history
…ion status.
  • Loading branch information
apple843119 committed Apr 19, 2024
1 parent eb3dce4 commit 275e85f
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions CRM/Contribute/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,31 @@ static function whereClauseSingle(&$values, &$query) {
return;

case 'contribution_status_id':
case 'contribution_status':
require_once "CRM/Core/OptionGroup.php";
$statusValues = CRM_Core_OptionGroup::values("contribution_status");
if ($name == 'contribution_status') {
$statusIndex = null;
if (is_numeric($value) || ctype_digit($value)) {
$value = CRM_Utils_Type::escape($value, 'Integer');
if (isset($statusValues[$value])) {
$statusIndex = $value;
}
}
elseif (is_string($value)) {
$value = CRM_Utils_Type::escape($value, 'String');
$statusIndex = array_search($value, $statusValues);
}

// Check contribution status exit or not
if ($statusIndex !== null) {
$value = $statusIndex;
}
else {
unset($value);
}
}

if (is_array($value)) {
foreach ($value as $k => $v) {
if ($v) {
Expand All @@ -472,9 +497,6 @@ static function whereClauseSingle(&$values, &$query) {
$status = $value;
}

require_once "CRM/Core/OptionGroup.php";
$statusValues = CRM_Core_OptionGroup::values("contribution_status");

$names = array();
if (is_array($val)) {
foreach ($val as $id => $dontCare) {
Expand Down

0 comments on commit 275e85f

Please sign in to comment.