CRM-15931 CRM_Mailing_BAO_Mailing::report (and possibly other functions) are mis-categorizing mailing groups due to change in group_type string case

    Details

    • Type: Sub-task
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.5, 4.6
    • Fix Version/s: 4.5.7, 4.6
    • Component/s: CiviMail
    • Labels:
      None
    • Documentation Required?:
      None

      Description

      Symptom I noticed is when viewing the CiviMail Mailing Report (click on Report action link from a draft, scheduled or sent mailing) [civicrm/mailing/report?mid=1&reset=1] - the report shows both Included and Excluded groups as "Excluded".

      I narrowed this down to the code snippet below from CRM_Mailing_BAO_Mailing::report - which is expecting group_type = 'Included', 'Excluded' or 'Base'. In my DB, mailing_group.group_type strings are lower case (e.g. 'included', 'excluded'). This causes the if statement to fail.

      There are a few other spots in Mailing_BAO which also expect mixed case and I suspect they are also messing up. I tried to determine where the group_type strings are set - but couldn't find it.

      =======
      /* Rename hidden groups */

      if ($mailing->group_hidden == 1)

      { $row['name'] = "Search Results"; }

      if ($mailing->group_type == 'Include')

      { $report['group']['include'][] = $row; }

      elseif ($mailing->group_type == 'Base')

      { $report['group']['base'][] = $row; }

      else

      { $report['group']['exclude'][] = $row; }

        Attachments

          Activity

          [CRM-15931] CRM_Mailing_BAO_Mailing::report (and possibly other functions) are mis-categorizing mailing groups due to change in group_type string case
          Tim Otten added a comment -

          This smells like a regression in 4.5 – we changed the way in which enums are represented in SQL. In 4.4, that SQL column is declared as "enum('Include','Exclude','Base') COLLATE utf8_unicode_ci" – which I think means you can insert lower-case "include" and then get back capitalized "Include". In 4.5/4.6, we switched all enums to varchars – which means that case is preserved.

          Tim Otten added a comment -

          This seems to be the same underlying issue as CRM-15733. Given that CRM-15733 and CRM-15931 are both piecemeal symptom-fixes, my suspicion is that no one thought to do a broad search for places that might be sensitive to include/exclude. I lean toward going back to 'Include'. (I tried a quick grep on 'include' vs 'Include' to see if that might suggest that it's easier to push forward with 'include' or go back to 'Include', but that wasn't very helpful.)

          For 4.5: https://github.com/civicrm/civicrm-core/pull/5111
          For 4.6: https://github.com/civicrm/civicrm-core/pull/5112

          Note that I included upgrade steps for both 4.5 and 4.6. This should work for folks upgrading from 4.4, 4.5, or 4.6.alpha.

          David Greenberg added a comment -

          Tested PR's in both 4.5.6 and 4.6 sandbox.

            People

            • Assignee:
              David Greenberg
              Reporter:
              David Greenberg

              Dates

              • Created:
                Updated:
                Resolved: