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

CiviMember Roles Sync module causes PHP errors in Drupal log

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.4.7, 3.4.8
    • Fix Version/s: 4.1.0
    • Component/s: CiviMember
    • Labels:
      None

      Description

      The following two PHP errors are recorded in the Drupal log each time civimail.cronjob.php or EmailProcessor.php is run, but only when CiviCRM is configured to use the Drupal wysiwyg editor (this only occurs on Drupal 6).

      1. Invalid argument supplied for foreach() in /<drupal root>/modules/filter/filter.module on line 306.

      2. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OR format = 1' at line 1 query: SELECT * FROM filter_formats WHERE OR format = 1 in /<drupal root>/includes/database.mysqli.inc on line 134.

      Here are the steps to reproduce (I'm using Drupal 6.22 and CiviCRM 3.4.7):
      Enable the CiviMember Roles Sync module.
      Set the WYSIWYG Editor in the CiviCRM Site Preferences to Drupal Default Editor (I'm using TinyMCE).
      Run the civimail.cronjob.php script.
      View the Drupal log to view the PHP errors (/admin/reports/dblog).

      The problem is in the CiviMember Roles Sync module (drupal/modules/civicrm_member_roles/civicrm_member_roles.module) in the implementation of hook_user (civicrm_member_roles_user( )). When the cron script runs, it first authenticates the user resulting in a call to the hook_user function with the action "load". The first thing the hook function does is call civicrm_initialize( ) which in turn initializes the Druapl WYSIWIG editor by calling Drupal filter_formats( ). The trouble is that filter_formats( ) uses global $user which is not initialized during the "load" action, resulting in the PHP errors.

      Since the CiviMember Roles Sync hook_user function only acts on login, logout, and insert actions, it doesn't need to (and shouldn't) initialize CiviCRM during the load action. The solution is to simply remove the call to civicrm_initialize( ) from the hook because it is called later in _civicrm_member_roles_sync( ) after testing for the login, logout, and insert actions.

      I've attached a patch against the 3.4 branch.

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              marty Marty Wright
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: