Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-20855: Disabling "Search Primary Details Only" causes partial CiviMail delivery failure #10915

Merged
merged 1 commit into from
Sep 4, 2017

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Aug 29, 2017

Overview

Alternate to #10746, fixing a problem when some contacts are missed when the 'search primary details only' setting is disabled.

Before

When a contact has 2 emails & the setting for search primary only is off, calling the tokens query gets 2 rows but truncates by the number of contacts, resulting in one being lost.

After

Test in place demonstrating that the retrieval works.

Technical Details

Replaces #10746 - the unit tests in there replicate some or all of the problem. This is just stylistic changes on top of that.

Comments

I'm not 100% sure if this solves the whole problem or one manifestation - we should confirm when closing JIRA.


if ($primaryLocationOnly === NULL) {
$primaryLocationOnly = Civi::settings()->get('searchPrimaryDetailsOnly');
}
$this->_primaryLocation = $primaryLocationOnly;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out there is already a property for primary only so let's use that.

*/
public function __construct(
$params = NULL, $returnProperties = NULL, $fields = NULL,
$includeContactIds = FALSE, $strict = FALSE, $mode = 1,
$skipPermission = FALSE, $searchDescendentGroups = TRUE,
$smartGroupCache = TRUE, $displayRelationshipType = NULL,
$operator = 'AND',
$apiEntity = NULL
$apiEntity = NULL,
$primaryLocationOnly = NULL
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's pass in a var that says what we want to do, rather than overload one we don't really understand

$searchPrimary = "AND {$name}.is_primary = 1";
}

$limitToPrimaryClause = $primaryLocation ? "AND {$name}.is_primary = 1" : '';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this name for the var is closer. Let's always pass in $primaryLocation correctly & not try to derive in this function

@@ -1235,9 +1235,7 @@ public static function getTokenDetails(
}
}

$query = new CRM_Contact_BAO_Query($params, $returnProperties);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really - this is being substantiated & then called statically in a way that shows no benefit from the substantiation

@@ -603,7 +603,8 @@ function _civicrm_api3_get_query_object($params, $mode, $entity) {
$newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams, 0, FALSE, $entity);
$query = new CRM_Contact_BAO_Query($newParams, $returnProperties, NULL,
FALSE, FALSE, $mode,
empty($params['check_permissions'])
empty($params['check_permissions']),
TRUE, TRUE, NULL, 'AND', 'NULL', TRUE
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set extras explicitly including SearchPrimary

) {
if ($primaryLocationOnly === NULL) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this could just be FALSE ie. if it is FALSE then we check the setting & possibly update to TRUE. For TRUE always stay TRUE. I'm on the fence here

$contactIDs = array($contactID);

// when we are fetching contact details ON basis of primary address fields
$contactDetails = CRM_Utils_Token::getTokenDetails($contactIDs);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the one that involves passing in $extraParams because that is a weird funky way of passing stuff in. It is merged into $params & passed on so you don't really know what will wind up where

@eileenmcnaughton eileenmcnaughton changed the title Primary [wip]Primary Aug 29, 2017
@eileenmcnaughton eileenmcnaughton changed the title [wip]Primary RM-20855: Disabling "Search Primary Details Only" causes partial CiviMail delivery failure Aug 29, 2017
@eileenmcnaughton eileenmcnaughton changed the title RM-20855: Disabling "Search Primary Details Only" causes partial CiviMail delivery failure CRM-20855: Disabling "Search Primary Details Only" causes partial CiviMail delivery failure Aug 29, 2017
@monishdeb
Copy link
Member

@lcdservices this is a alternate PR #10746 , as per my test and added unit test and worked for me. I think it more accurate by introducing separate parameter and manipulate the underlying query fragments on basis of that. Would you like to test it?

@eileenmcnaughton
Copy link
Contributor Author

rebased

@eileenmcnaughton eileenmcnaughton force-pushed the primary branch 2 times, most recently from 64f3607 to 8b04115 Compare September 4, 2017 05:51
…iMail delivery failure

CRM-20855: Adjust variables for clarity

I'm concerned about the use of $apiEntity to mean 'do something unconnected' so suggest
a specific paramteter.
@monishdeb
Copy link
Member

Tested, working fine.

@monishdeb monishdeb merged commit d7bfc28 into civicrm:master Sep 4, 2017
@eileenmcnaughton eileenmcnaughton deleted the primary branch September 4, 2017 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants