CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • V2 API Problem
Pages: [1]

Author Topic: V2 API Problem  (Read 1596 times)

FredJones

  • Guest
V2 API Problem
September 14, 2008, 01:55:18 am
I have a custom Drupal 5 module which uses:

Code: [Select]
require_once 'api/v2/Event.php';

and then

Code: [Select]
civicrm_event_search

to use the API in CiviCRM 2.0.4 Drupal PHP5. Until last week, it was working fine. This week, when I call that function, execution of my script stops.

I traced through the code carefully and found that the last line being executed is the one just before this one:

Code: [Select]
                    $customOption = CRM_Core_BAO_CustomOption::getCustomOption($field['id'], $inactiveNeeded);

which is line 853 of CRM\Core\BAO\CustomGroup.php in the section "case 'CheckBox':" of "static function setDefaults"

I determined that I previously had no custom checkbox fields, but we indeed added one last week to a custom group which is used for events. Seems to me that since adding that field, the API doesn't work. I am unable to run an API call on the demo site (AFAIK) so I can't recreate this for you.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: V2 API Problem
September 14, 2008, 07:31:58 am
Can you elaborate a bit more on "execution of my script stops."? Does it throw an error on the screen / drupal watchdog table / php error log? if so what is the error. Is it missing a

require_once 'CRM/Core/BAO/CustomOption.php';

on line 852? Most likely it is, here is a patch for 2.1, something similar will work for 2.0.x

Code: [Select]
--- CRM/Core/BAO/CustomGroup.php        (revision 17061)
+++ CRM/Core/BAO/CustomGroup.php        (working copy)
@@ -797,6 +797,7 @@
 
     static function setDefaults( &$groupTree, &$defaults, $viewMode = false, $inactiveNeeded = false )
     {
+        require_once 'CRM/Core/BAO/CustomOption.php';
         foreach ( $groupTree as $id => $group ) {
             if ( $id === 'info' ) {
                 continue;


lobo
« Last Edit: September 14, 2008, 07:35:14 am by Donald Lobo »
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

FredJones

  • Guest
Re: V2 API Problem
September 14, 2008, 10:29:32 am
You are precisely correct. I ran it first on another server which has better error reporting, and the error indeed is:

Code: [Select]
Fatal error: Class 'CRM_Core_BAO_CustomOption' not found in E:\ApacheRoot\mYsite\sites\all\modules\civicrm\CRM\Core\BAO\CustomGroup.php on line 854

Adding your patch fixed it. Thank you very much!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • V2 API Problem

This forum was archived on 2017-11-26.