Skip to content

Commit

Permalink
Merge pull request civicrm#17182 from eileenmcnaughton/dep
Browse files Browse the repository at this point in the history
Remove deprecated calls to optionValueQuery and no-longer-need param
  • Loading branch information
colemanw authored Apr 28, 2020
2 parents 2f93a1e + bf0f0d1 commit 940285d
Showing 1 changed file with 15 additions and 55 deletions.
70 changes: 15 additions & 55 deletions CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2181,8 +2181,7 @@ public function restWhere(&$values) {
'CRM_Contact_DAO_Contact',
$field,
$field['title'],
CRM_Utils_Type::typeToString($dataType),
TRUE
CRM_Utils_Type::typeToString($dataType)
);
if ($name === 'gender_id') {
self::$_openedPanes[ts('Demographics')] = TRUE;
Expand Down Expand Up @@ -2211,8 +2210,7 @@ public function restWhere(&$values) {
NULL,
$field,
ts('World Region'),
'Positive',
TRUE
'Positive'
);
}
elseif ($name === 'is_deceased') {
Expand Down Expand Up @@ -2257,36 +2255,6 @@ public function restWhere(&$values) {
$this->_where[$grouping][] = $ceWhereClause;
$this->_qill[$grouping][] = "$field[title] $op \"$value\"";
}
elseif ($name === 'email_greeting') {
CRM_Core_Error::deprecatedFunctionWarning('pass in email_greeting_id or email_greeting_display');
$filterCondition = ['greeting_type' => 'email_greeting'];
$this->optionValueQuery(
$name, $op, $value, $grouping,
CRM_Core_PseudoConstant::greeting($filterCondition),
$field,
ts('Email Greeting')
);
}
elseif ($name === 'postal_greeting') {
CRM_Core_Error::deprecatedFunctionWarning('pass in postal_greeting_id or postal_greeting_display');
$filterCondition = ['greeting_type' => 'postal_greeting'];
$this->optionValueQuery(
$name, $op, $value, $grouping,
CRM_Core_PseudoConstant::greeting($filterCondition),
$field,
ts('Postal Greeting')
);
}
elseif ($name === 'addressee') {
CRM_Core_Error::deprecatedFunctionWarning('pass in addressee_id or addressee_display');
$filterCondition = ['greeting_type' => 'addressee'];
$this->optionValueQuery(
$name, $op, $value, $grouping,
CRM_Core_PseudoConstant::greeting($filterCondition),
$field,
ts('Addressee')
);
}
elseif (substr($name, 0, 4) === 'url-') {
$tName = 'civicrm_website';
$this->_whereTables[$tName] = $this->_tables[$tName] = "\nLEFT JOIN civicrm_website ON ( civicrm_website.contact_id = contact_a.id )";
Expand Down Expand Up @@ -5882,8 +5850,6 @@ public static function componentPresent(&$returnProperties, $prefix) {
* @param string $label
* The label for this field element.
* @param string $dataType
* The data type for this element.
* @param bool $useIDsOnly
*
* @throws \CRM_Core_Exception
*/
Expand All @@ -5895,8 +5861,7 @@ public function optionValueQuery(
$daoName = NULL,
$field,
$label,
$dataType = 'String',
$useIDsOnly = FALSE
$dataType = 'String'
) {

$pseudoFields = [
Expand All @@ -5905,27 +5870,22 @@ public function optionValueQuery(
'addressee',
];

if ($useIDsOnly) {
list($tableName, $fieldName) = explode('.', $field['where'], 2);
if ($tableName == 'civicrm_contact') {
$wc = "contact_a.$fieldName";
list($tableName, $fieldName) = explode('.', $field['where'], 2);
if ($tableName == 'civicrm_contact') {
$wc = "contact_a.$fieldName";
}
else {
// Special handling for on_hold, so that we actually use the 'where'
// property in order to limit the query by the on_hold status of the email,
// instead of using email.id which would be nonsensical.
if ($field['name'] === 'on_hold') {
$wc = $field['where'];
}
else {
// Special handling for on_hold, so that we actually use the 'where'
// property in order to limit the query by the on_hold status of the email,
// instead of using email.id which would be nonsensical.
if ($field['name'] === 'on_hold') {
$wc = $field['where'];
}
else {
$wc = "$tableName.id";
}
$wc = "$tableName.id";
}
}
else {
CRM_Core_Error::deprecatedFunctionWarning('pass $ids to this method');
$wc = "{$field['where']}";
}

if (in_array($name, $pseudoFields)) {
$wc = "contact_a.{$name}_id";
$dataType = 'Positive';
Expand Down

0 comments on commit 940285d

Please sign in to comment.