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

Contribution page widget broken on Drupal installations

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7
    • Fix Version/s: 4.7.5
    • Component/s: CiviContribute
    • Labels:
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code

      Description

      The widget code generated for a contribution page fails trying to retrieve the json page data from the server. The output from http://<server>/sites/all/modules/civicrm/extern/widget.php is:

      Fatal error: Call to undefined function drupal_add_http_header() in /<civihome>/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php on line 789

      This happens because Drupal is not booted when extern/widget.php runs, and CRM_Core_Page_AJAX::setJsHeaders() calls CRM_Utils_System_Drupal::setHttpHeader() which attempts to call drupal_add_http_header().

      To reproduce on the demo site:
      Enable the widget on the "Help Support CiviCRM!" contribution page.
      Find the javascript source url at the bottom of the generated code:
      http://dmaster.demo.civicrm.org/sites/all/modules/civicrm//extern/widget.php?cpageId=1&widgetId=1&format=3
      Copy and paste the url into a browser to view what should be the json output, but instead:
      Fatal error: Call to undefined function drupal_add_http_header() in /srv/buildkit/build/dmaster/sites/all/modules/civicrm/CRM/Utils/System/Drupal.php on line 789

      To fix the problem, I added a call to loadBootStrap() in CRM_Utils_System_Drupal::setHttpHeader()

        public function setHttpHeader($name, $value) {
          self::loadBootStrap(NULL, FALSE);
          drupal_add_http_header($name, $value);
        }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              marty Marty Wright
            • Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: