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

Report custom data table retrieval fails when tables are more than 1024 characters

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7.2, 4.7.3, 4.7.4
    • Fix Version/s: 4.7.5
    • Component/s: CiviReport
    • Labels:
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code

      Description

      CRM-17837 includes a rewrite of the custom data table processing for inclusion in the report query.

      https://github.com/civicrm/civicrm-core/commit/55f71fa785c6a5d2cd756074e89d69b15e372ed4

      @@ -3614,11 +3620,10 @@ public function customDataFrom() {
              return;
           }
           $mapper = CRM_Core_BAO_CustomQuery::$extendsMap;
      +    $customTables = explode(',', CRM_Core_DAO::singleValueQuery("SELECT GROUP_CONCAT(table_name) FROM civicrm_custom_group"));
       
           foreach ($this->_columns as $table => $prop) {
      -      if (substr($table, 0, 13) == 'civicrm_value' ||
      -        substr($table, 0, 12) == 'custom_value'
      -      ) {
      +      if (in_array($table, $customTables)) {
               $extendsTable = $mapper[$prop['extends']];
       
               // check field is in params
      

      The issue is that GROUP_CONCAT defaults to 1024 characters, so installs with lots of custom data sets can get truncated and the report returns with no such field errors because the needed table hasn't been joined. Of course this variable can be changed, but that won't be possible in some environments. Would there be any issues migrating from the singleValueQuery() to executeQuery() for generating the custom tables array?

      @@ -3658,7 +3658,10 @@ ORDER BY cg.weight, cf.weight";
             return;
           }
           $mapper = CRM_Core_BAO_CustomQuery::$extendsMap;
      -    $customTables = explode(',', CRM_Core_DAO::singleValueQuery("SELECT GROUP_CONCAT(table_name) FROM civicrm_custom_group"));
      +    $customTablesDAO = CRM_Core_DAO::executeQuery("SELECT table_name FROM civicrm_custom_group", CRM_Core_DAO::$_nullArray);
      +    while ($customTablesDAO->fetch()) {
      +      $customTables[] = $customTablesDAO->table_name;
      +    }
       
           foreach ($this->_columns as $table => $prop) {
             if (in_array($table, $customTables)) {
      

        Attachments

          Activity

            People

            • Assignee:
              eileen Eileen McNaughton
              Reporter:
              jlacey Joseph Lacey
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: