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) »
  • Membership API v3 - ucfirst() requires capitalized membership types - Why?
Pages: [1]

Author Topic: Membership API v3 - ucfirst() requires capitalized membership types - Why?  (Read 619 times)

bitflippings

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: Drupal 6.20
  • MySQL version: 5.0
  • PHP version: 5.2
Membership API v3 - ucfirst() requires capitalized membership types - Why?
August 30, 2012, 09:00:39 am
Why does #civicrm use ucfirst() to require Membership Types be capitalized in v3 Membership API? Haven't found any explanation in docs. Am I missing something?

I set up the membership types in all lower case, imported contacts and memberships, and then the Membership Status Processor (CRM_Member_BAO_Membership::updateAllMembershipStatus()) called the v3 API to update the Memberships with new statuses according to dates, and the API threw errors on all of them because it compares db values against an arbitrarily-capitalized version of the value.

Does anyone know why the API requires Membership Types to begin with capital letters (i.e. why the ucfirst() function is called during create/update of Memberships)?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Membership API v3 - ucfirst() requires capitalized membership types - Why?
August 30, 2012, 04:27:56 pm
I think it's probably legacy behaviour that has stayed in there. I presume the code still makes sense without that?
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

bitflippings

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: Drupal 6.20
  • MySQL version: 5.0
  • PHP version: 5.2
Re: Membership API v3 - ucfirst() requires capitalized membership types - Why?
August 30, 2012, 08:26:15 pm
The function and its immediate caller make sense without the ucfirst() call.

I was wondering whether there might be some requirement for the capitalization in another part of Civi. (However, we'd been using lower-case membership types for a year prior to attempting to use the Membership Status Update function and not noticed any problems.)

We discussed overriding the function but decided against it since it was so deep in the API. Therefore we'll just capitalize our membership types. On a positive note, after capitalizing them, their links to our lower-case Drupal roles were preserved. The Civi - Drupal role synchronization must match using ids rather than names/descriptions.

Thank you for your input. It's encouraging to hear that Civi has been around long enough to have "legacy" code. Be proud.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Membership API v3 - ucfirst() requires capitalized membership types - Why?
September 03, 2012, 01:33:30 am
Quote from: bitflippings on August 30, 2012, 08:26:15 pm
We discussed overriding the function but decided against it since it was so deep in the API.

Not that deep, that's just at the surface of the specific code for this api ;)

I would encourage you to patch this and create an issue with it, so it's fixed in the next versions of Civ (and you can backport it right now)
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Membership API v3 - ucfirst() requires capitalized membership types - Why?

This forum was archived on 2017-11-26.