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

"Getting Started" dashlet can break upgrade to Civi >= 4.6.12

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.6.12, 4.6.14, 4.7.4
    • Fix Version/s: 4.6.15, 4.7.5
    • Component/s: Core CiviCRM
    • Labels:
      None
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code

      Description

      I just (inadvertently) replicated the bug described on this ticket: http://civicrm.stackexchange.com/questions/9407/db-upgrade-fails-when-creating-getting-started-dashlet

      The upgrade script for 4.6.12 contains the following SQL:
      INSERT INTO `civicrm_dashboard_contact` (dashboard_id, contact_id, column_no, is_active) SELECT (SELECT MAX(id) FROM `civicrm_dashboard`), contact_id, 0, IF (SUM(is_active) > 0, 1, 0) FROM `civicrm_dashboard_contact` WHERE 1 GROUP BY contact_id;

      The intent is to create a "Getting Started" dashlet for any contacts that have at least one dashlet defined. However, there's a foreign key constraint that prevents creating records without an associated record in civicrm_contact. This causes a problem if you already have civicrm_dashboard_contact records that don't have an associated contactThat constraint was added in Civi 3.1, so I think this may only affect databases that have existed since before then.

      The solution is simple, add a join:
      INSERT INTO `civicrm_dashboard_contact` (dashboard_id, contact_id, column_no, is_active) SELECT (SELECT MAX(id) FROM `civicrm_dashboard`), contact_id, 0, IF (SUM(is_active) > 0, 1, 0) FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_contact.contact_id = civicrm_contact.id GROUP BY contact_id;

      However, I've never had to fix an upgrade-related bug before. Is it sufficient to just submit this PR on 4.7 and LTS? I don't think you typically reissue previous releases, so we don't go back and fix, e.g., 4.6.12. Right?

        Attachments

          Activity

            People

            • Assignee:
              palantejon Jon K Goldberg
              Reporter:
              palantejon Jon K Goldberg
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: