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) »
  • API v3 mailing_group event_subscribe requires unnecessary keys?
Pages: [1]

Author Topic: API v3 mailing_group event_subscribe requires unnecessary keys?  (Read 993 times)

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
API v3 mailing_group event_subscribe requires unnecessary keys?
August 03, 2011, 12:58:57 pm
In CiviCRM 3.4 branch (from SVN), API v3 returns the error, "Mandatory key(s) missing from params array: hash, time_stamp" when called as follows if those keys are not included in $params:
Code: [Select]
civicrm_api('mailing_group', 'event_subscribe', $params);
I don't think the API should be requiring these keys. Populating these keys with dummy values allows things to continue normally, though I'm not at all sure of side effects.

If I understand this correctly, the problem seems to be that the API function is allowing DAO required fields to be considered as required, even though they're not really all required in the API context.  If that's right, a patch like this might be the right solution, or at least a starting point:

Code: [Select]
Index: api/v3/MailingGroup.php
===================================================================
--- api/v3/MailingGroup.php (revision 35591)
+++ api/v3/MailingGroup.php (working copy)
@@ -136,7 +136,7 @@
 function civicrm_api3_mailing_group_event_subscribe($params)
 {
 
-        civicrm_api3_verify_mandatory ( $params,'CRM_Mailing_Event_DAO_Subscribe', array('email', 'group_id') );
+        civicrm_api3_verify_mandatory ( $params,'CRM_Mailing_Event_DAO_Subscribe', array('email', 'group_id', 'contact_id'), FALSE );
           
         $email      = $params['email'];
         $group_id   = $params['group_id'];
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: API v3 mailing_group event_subscribe requires unnecessary keys?
August 04, 2011, 12:07:04 am
Please file an issue and attached the patch

Thanks
Kurund
Found this reply helpful? Support CiviCRM

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: API v3 mailing_group event_subscribe requires unnecessary keys?
August 04, 2011, 03:31:54 am
Should CRM_Mailing_Event_DAO_Subscribe have the fields hash, time_stamp as mantory in the first place?

If not, fix the xml DAO definition and leave the code like that.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Re: API v3 mailing_group event_subscribe requires unnecessary keys?
August 04, 2011, 07:45:23 am
Issue posted here, including mention of Xavier's suggestion to consider changing the DAO requirement for those columns: http://issues.civicrm.org/jira/browse/CRM-8608

Thanks,
Allen
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • API v3 mailing_group event_subscribe requires unnecessary keys?

This forum was archived on 2017-11-26.