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

If too many custom fields at a time are evaluated for tokens, query crashes with "too many tables" error

    Details

    • Type: Bug
    • Status: In Progress
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 4.4.13
    • Fix Version/s: None
    • Component/s: Core CiviCRM
    • Labels:
      None
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      If too many custom fields (or rather, if custom fields from too many groups?) are requested in the $returnProperties parameter to CRM_Utils_Token::getTokenDetails, the single call to CRM_Contact_BAO_Query::apiQuery performs a query that joins too many tables.

      The request then crashes with MySQL error 1116 "Too many tables; MySQL can only use 61 tables in a join". If the query is dumped, the large number of LEFT JOINs can be seen.

      I have a solution that works for me, which is to replace the line

      $details = $query->apiQuery($params, $returnProperties, NULL, NULL, 0, $numberofContacts);
      

      with code that slices $returnProperties into manageable chunks, does separate apiQuery calls, and merges the results of each into $details.

      Thanks,
      David

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              DaveFF David Knoll
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: