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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • should we introduce civicrm_api3
Pages: 1 [2]

Author Topic: should we introduce civicrm_api3  (Read 2656 times)

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: should we introduce civicrm_api3
June 30, 2013, 03:21:36 am
Quote from: xavier on June 27, 2013, 10:06:23 am
Plan B: we remove version as a mandatory field and default to version 3 we keep civicrm_api, CRM.api and {crmAPI} as v3 only and if/when api 4 is there, we introduce civicrm_api4 CRM.api4 and crmAPI4 at that time?

+1 on this. It's more writable/readable for API-consumers.

Talked a little more about this with Eileen on IRC. I lean softly in favor of throwing an exception in the civicrm_api3 -- but with a few questions/thoughts:

a) I'm a little nervous that we have too many possible entry points for PHP developers ("function civicrm_api", "function civicrm_api3", "class civicrm_api3"). How can we update the documentation to make the distinction intuitive? (Aside: it's a little counter-intuitive that the procedural facade will use exceptions while the OOP facade won't, but... it's still good to make incremental progress...)

b) It's not going to be feasible (with APIv3 / Civi 4.x) for civicrm_api3() to throw exceptions with meaningful class names (e.g. CRM_API_MissingArgumentException) -- it would need to throw some generic exception class (like "API_Exception", "CRM_Core_Exception", etc). The exception class will be part of the public interface, so it should be something that we're comfortable supporting in future versions. Are we comfortable with something like "CiviCRM_API3_Exception" or "civicrm_api3_Exception" or "CRM_API_APIv3Exception"?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: should we introduce civicrm_api3
July 05, 2013, 12:33:27 am
I have made a cut at this

https://github.com/eileenmcnaughton/civicrm-core/commit/02a8d8f18cdb7caaa431bee10cb6d31eb63e5629

The cut is on 4.2 but you should be able to cherry pick it easily to 4.3 or master as it doesn't touch much.

If we are going to do this we need to do it in time for 4.3.5 / 4.2.10 or deliberately NOT do it until such time as we can ensure it is in available cross-version. We don't want to be encouraging a situation where published extensions don't work across multiple versions.

Note that this is only additional code - no existing code is changed. The exception is being handled very shallowly & I would think that might change in master to have an exception passed up the ranks rather than being converted at that level. However, the key thing is that once added the inputs & outputs need to remain consistent.
« Last Edit: July 05, 2013, 12:35:08 am by Eileen »
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • should we introduce civicrm_api3

This forum was archived on 2017-11-26.