Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.1.0
-
Fix Version/s: 4.1.0
-
Component/s: None
-
Labels:None
Description
I just did a grep of functions that call api functions directly from outside of the api folder & found an alarming number in trunk. In fact there are 72 in the CRM folder. API functions are to be called using the api wrapper civicrm_api();
Somehow the v2 functions got 'migrated' in an unsupported way
e.g. ForwardMailing.php calls
$result = civicrm_api3_mailing_event_forward( $params );
- should be civicrm_api('mailing_event','forward', $params);
AND
if ( civicrm_api3_error( $contact ) )
should be civicrm_error()
There are a few functions that maybe need to move to BAO in order for us to be able to enforce no external functions directly calling the api.
$dao = _civicrm_api3_load_DAO($objectName);
I'm probably more bothered by things like
$formatError = _civicrm_api3_contribute_formatted_param( $paramValues, $formatted, true);
If formatting needs to be done it should be handled /supported within the api function – civicrm_api('contribution', 'create', $params) — or by the calling function but not by directly calling an api util function (I actually thought I'd removed _civicrm_api3_contribute_formatted_param but I guess I hadn't yet - pretty sure I'd been hacking away at the other function on in the contribute file which mostly duplicates it and is called from the api).
I realise the press it to get 4.1 out but I think it would be better to ship with core calling api v2 than to switch to apiv3 without doing it in a way that is consistent with the effort we put into establishing api3. Can we do it slowly & properly rather than in a mad rush that implements v3 in name only?