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

updateGreeting performance issue

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.1.1
    • Fix Version/s: Unscheduled
    • Component/s: Core CiviCRM
    • Labels:
    • Documentation Required?:
      None
    • Funding Source:
      Core Team Funds

      Description

      Updating the Adressee greeting using the available job documented at http://wiki.civicrm.org/confluence/display/CRMDOC41/Managing+Scheduled+Jobs seems to hang forever if the number of contacts is too high.
      In particular, the script seems to 'freeze' while executing the query called in CRM/Utils/Token.php at line 957, since the $params array has a high number of items (more than 15000 in my case):

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

      A possible workaround would be to limit the number of contacts that will be updated by simply adding a LIMIT in the SQL query at line 954 of CRM_Contact_BAO_Contact_Utils::updateGreeting() though I don't know if it will have any impact on other components. Of course the update will be limited to these contacts only so perhaps adding a limit parameter would be a better option.

      $sql = "SELECT DISTINCT id, $idFldName FROM civicrm_contact WHERE contact_type = %1
      AND ( {$idFldName} IS NULL OR ( {$idFldName} IS NOT NULL AND {$displayFldName} IS NULL ) ) LIMIT 1000 ";

      This workaround has been tested on my local CiviCRM instance and seems to fix the issue (the 1000 first matched contacts are updated). Patch attached.

      For reference, here is the executed CLI command:
      user@server:[drupal root]/sites/all/modules/civicrm/bin$ php cli.php -j -u [user] -p [password] -e Job -s [site] -a update_greeting --ct=Individual --gt=addressee

      Executing the job using the URL method results in a fatal error due to the exceeded maximum execution time (even if increased to 600 seconds).

        Attachments

        1. updategreeting.patch
          0.8 kB
          Jean-François Hovinne

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jfhovinne Jean-François Hovinne
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: