0

I am running Drupal 7 and CiviCRM 4.7.1. Since upgrade, my contribution widgets are not displaying properly, they just show placeholder. I was able to recreate the issue in the sandbox.

Console shows the following error: ReferenceError: jsondata4 is not defined

At a loss of where to search next. Thought it might be related to modsecurity or .htaccess, but since the sandbox experienced the same issue, not so sure anymore.

Suggestions please...

0

Thanks to Marty Wright for reporting the bug and providing a solution.

https://issues.civicrm.org/jira/si/jira.issueviews:issue-html/CRM-17965/CRM-17965.html

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

Fatal error: Call to undefined function drupal_add_http_header() in //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_System_Utils_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_System_Utils_Drupal::setHttpHeader()

  public function setHttpHeader($name, $value) {
    self::loadBootStrap(NULL, FALSE);
    drupal_add_http_header($name, $value);
  }
1
  • I'm having the same problem. Where do you add this code? – Alyx Perry Oct 5 '20 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.