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

Advanced Search issue when display results as Mailings

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7
    • Fix Version/s: 4.7.12
    • Component/s: None
    • Labels:
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      Testing on clean installation set up with buildkit (Drupal + CiviCRM 4.7.9-rc) :
      civibuild create hr216 --type drupal-demo --civi-ver 4.7.9-rc --web-root /home/kacper/www/hr216

      Searching Contacts using Advanced Search with specified "Display results as" as "Mailings" causes SQL error if CiviMail components is disabled.

      Reason

      When CiviMail component is disabled there is no SQL JOIN to `civicrm_mailing_recipients` table and then this SQL error appears:
      SELECT count( DISTINCT civicrm_mailing_recipients.id ) FROM civicrm_contact contact_a LEFT JOIN civicrm_hrjobcontract hrjobcontract ON hrjobcontract.contact_id = contact_a.id AND hrjobcontract.deleted = 0 LEFT JOIN civicrm_hrjobcontract_revision rev ON rev.jobcontract_id = hrjobcontract.id AND ( rev.id = (SELECT id FROM civicrm_hrjobcontract_revision WHERE jobcontract_id = hrjobcontract.id AND (effective_end_date >= '2016-09-05' OR effective_end_date IS NULL) AND deleted = 0 AND overrided = 0 ORDER BY effective_date ASC LIMIT 1) ) LEFT JOIN civicrm_hrjobroles ON hrjobcontract.id = civicrm_hrjobroles.job_contract_id WHERE (contact_a.is_deleted = 0) [nativecode=1054 ** Unknown column '*civicrm_mailing_recipients*.id' in 'field list']

      Possible solution

      Available 'modes' for 'Display results as' field (on Advanced Search criteria form) are set in hardcoded PHP array in setModeValues() method. Without any validation if required components are available (CiviMail for example).
      The solution would require to exclude disabled components (like CiviMail) from $componentModes array in:
      CRM/Contact/Form/Search/Criteria.php file.

        Attachments

          Activity

            People

            • Assignee:
              seamuslee Seamus Lee
              Reporter:
              coldrunKacper Kacper Warda
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: