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

CiviReport uses report field name to export data from BAO/DAO file instead of real database field name

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.1.0, 4.1.1
    • Fix Version/s: 4.2.0
    • Component/s: CiviReport
    • Labels:

      Description

      Each table array in the $this->columns array may contain these arrays: 'fields', 'filters', 'group_bys', and 'order_bys'. Each of those arrays is an array of report field names. These report field names are very often equal to the real database field names, but they don't have to be. If a report field name is not equal to the real database field name, then the real database field name is specified with the 'name' key. For example:

      $this->_columns = array('civicrm_email' => array('dao' => 'CRM_Core_DAO_Email','fields' => array('primary_email' => array('name' => 'email'))))

      In this example, the report field name is 'primary_email', but the actual database field name is 'email'.

      The Form.php script uses the report field name to export characteristics of that field from the associated BAO/DAO file, instead of using the real database field name. If the report field name is the same as the real database field name, everything works. In this example, however, Form.php would try to export data about the field 'primary_email' and find nothing. This causes problems with filters not knowing the data type of a field.

      I have attached a sample report (bug.php) that demonstrates this problem. If you type something in the campaign or survey filter boxes, the report will crash.

      I have attached a patch to Form.php (Form.Bug.diff) that fixes Form.php to use the real database field names to export field characteristics.

      If the 'name' key is specified in the 'fields' array, I think it would be handy if that information would carry over to the 'filters', 'group_bys', and 'order_bys' arrays also. I have also attached a patch to Form.php (Form.Enh.diff) that fixes the bug described above and also carries over the 'name' and 'alias' keys from the 'filters' array to the other arrays, if those arrays don't have a value specified. This is probably more of an enhancement that a bug fix, but the same code is being changed.

        Attachments

        1. Bug.php
          1 kB
          Michael Labriola
        2. Form.php.diff
          2 kB
          Michael Labriola

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              mhlabriola Michael Labriola
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: