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

civicrm_search() API conflicts with Drupal hook_search()

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Critical
    • Resolution: Fixed/Completed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.5
    • Labels:
      None

      Description

      The CiviCRM API function civicrm_search() (found in api/Search.php) conflicts with Drupal's hook_search, and will break Drupal Core's search.module if CiviCRM is initialized.

      Symptoms:
      – admin/settings/search page in Drupal does not render
      – you get PHP errors like these:
      [code]

      • warning: Invalid argument supplied for foreach() in /home/rtoren/Torenware/Website/beta.torenware.com/docs/modules/civicrm/CRM/Contact/BAO/Query.php on line 332.
      • warning: array_keys() [function.array-keys]: The first argument should be an array in /home/rtoren/Torenware/Website/beta.torenware.com/docs/modules/civicrm/CRM/Contact/BAO/Query.php on line 889.
      • warning: Invalid argument supplied for foreach() in /home/rtoren/Torenware/Website/beta.torenware.com/docs/modules/civicrm/CRM/Contact/BAO/Query.php on line 889.
        [/code]

      [b]Cause:[/b]

      When a function of the search module are called (either to execute a search, or to look at the Search module's settings), Search is finding the public API call civicrm_search, and calling it as follows:

      civicrm_search($op = 'search', $keys = null)

      Since this API is not really an implementation of hook_search, it confuses the hell out of Drupal, since Drupal is not expecting to get a list of CiviCRM search results.

      [b]Duplicating The Bug[/b]

      Write a trivial drupal module that calls civicrm_initialize(TRUE) in hook_init(), as so:

      <?php
      // in file "trivial_module.module"....
      function trivial_module_init(){
      civicrm_initialize(TRUE);
      }
      ?>

      Activate the module, and try accessing admin/settings/search, or try running a Drupal search.

      [b]Recommended Fix:[/b]

      Change the name of civicrm_search() to make the conflict go away. No other way, since hook_search is a fundamental Drupal hook that isn't going away.

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              torenware Rob Thorne
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: