Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-19625

Relative dates in “smart groups” are not working as expected

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Important
    • Resolution: Duplicate
    • Affects Version/s: 4.7.13
    • Fix Version/s: None
    • Component/s: Core CiviCRM
    • Labels:
      None
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      Hi,

      Since 709355aa5 (CRM-19250), relative dates are properly stored in “smart groups”. But this new code doesn’t work in all situations and smart group won’t store the correct results.

      Here are the steps to reproduce the issue:

      • search for people that have a “membership” since “this year”;
      • from the result, create a new smart group;
      • go to the newly created smart group.

      If you are using CiviCRM’s sample data (or the demo instance), results from the search and the resulting group won’t be identical (you’ll have more contacts in the “smart group”).

      When using a relative date, member_join_date_relative should be converted into two a _high and _low variables. But this operation doesn’t work (see below) and only the _high value is kept in the final SQL query.

      The problem comes from CRM_Contact_BAO_Query::convertFormValues(). On line, 1623, CRM_Contact_BAO_Query::fixDateValues() is called and will update the content of $formValues. But since the main “foreach” loop in CRM_Contact_BAO_Query::convertFormValues() already iterated over the _low value (which was empty), this value will be missed.

      I don’t know how to solve cleanly this issue (and I don’t know how it worked in the pre-4.7 versions). Maybe should we have a special treatment for relative dates.

      Cheers,
      Olivier;

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                otetard Olivier Tétard
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: