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) »
  • post create MembershipPayment contribution issue
Pages: [1]

Author Topic: post create MembershipPayment contribution issue  (Read 673 times)

konadave

  • I’m new here
  • *
  • Posts: 19
  • Karma: 0
  • CiviCRM version: 4.2.6
  • CMS version: Drupal 7.17
  • MySQL version: 5.1.66
  • PHP version: 5.3.19
post create MembershipPayment contribution issue
August 20, 2014, 10:54:23 am
This is an issue that has come up with this extension, not that it really matters. Started after upgrading from 4.2.15 to 4.4.6.

function hook_civicrm_post($op, $objectName, $objectId, &$objectRef) {

	
if ((
$op == 'create') && ($objectName == 'MembershipPayment')) {
	
	
$api = new civicrm_api3();
	
	
$api->Contribution->Get(array('id' => $objectRef->contribution_id));
	
}
	
/** var_dump($api->result)

	
object(stdClass)#223 (4) {
	
  ["is_error"]=>
	
  int(0)
	
  ["version"]=>
	
  int(3)
	
  ["count"]=>
	
  int(0)
	
  ["values"]=>
	
  array(0) {
	
  }
	
}

     */
}

The result does not indicate that there was an error, but at the same time does not return the contribution object. The contribution was returned successfully before the upgrade.

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: post create MembershipPayment contribution issue
August 20, 2014, 01:30:09 pm
What are the results of checking that the $objectRef actually contains the data you want?  Try one or both of the following before your "if"?
Code: [Select]
CRM_Core_Error::debug('objectRef', $objectRef);
CRM_Core_Error::debug('contribution_id', $objectRef->contribution_id);

That way we can isolate if the problem is the API call or the hook?
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

konadave

  • I’m new here
  • *
  • Posts: 19
  • Karma: 0
  • CiviCRM version: 4.2.6
  • CMS version: Drupal 7.17
  • MySQL version: 5.1.66
  • PHP version: 5.3.19
Re: post create MembershipPayment contribution issue
August 20, 2014, 01:36:23 pm
This is the $objectRef that was passed to the hook.

Code: [Select]
object(CRM_Member_DAO_MembershipPayment)#188 (15) {
  ["id"]=>
  int(279060)
  ["membership_id"]=>
  string(6) "130176"
  ["contribution_id"]=>
  int(327856)
  ["_DB_DataObject_version"]=>
  string(6) "1.8.12"
  ["__table"]=>
  string(26) "civicrm_membership_payment"
  ["N"]=>
  int(0)
  ["_database_dsn"]=>
  string(0) ""
  ["_database_dsn_md5"]=>
  string(32) "3bd068a76eb675a7c1e8484e38292248"
  ["_database"]=>
  string(12) "imba_civicrm"
  ["_query"]=>
  array(7) {
    ["condition"]=>
    string(0) ""
    ["group_by"]=>
    string(0) ""
    ["order_by"]=>
    string(0) ""
    ["having"]=>
    string(0) ""
    ["limit_start"]=>
    string(0) ""
    ["limit_count"]=>
    string(0) ""
    ["data_select"]=>
    string(1) "*"
  }
  ["_DB_resultid"]=>
  int(301)
  ["_resultFields"]=>
  bool(false)
  ["_link_loaded"]=>
  bool(false)
  ["_join"]=>
  string(0) ""
  ["_lastError"]=>
  bool(false)
}

joanne

  • Administrator
  • Ask me questions
  • *****
  • Posts: 852
  • Karma: 83
  • CiviCRM version: 4.4.16
  • CMS version: Drupal 7
Re: post create MembershipPayment contribution issue
August 20, 2014, 06:22:13 pm
As a non-coder this is a stab in the dark, but it sounds rather like a problem we have had.  Is https://issues.civicrm.org/jira/browse/CRM-15148 relevant?

konadave

  • I’m new here
  • *
  • Posts: 19
  • Karma: 0
  • CiviCRM version: 4.2.6
  • CMS version: Drupal 7.17
  • MySQL version: 5.1.66
  • PHP version: 5.3.19
Re: post create MembershipPayment contribution issue
August 20, 2014, 07:53:09 pm
Quote from: joanne on August 20, 2014, 06:22:13 pm
As a non-coder this is a stab in the dark, but it sounds rather like a problem we have had.  Is https://issues.civicrm.org/jira/browse/CRM-15148 relevant?
Thanks for the pointer. I'm not a civi expert so I can't rule it out, but I don't believe that it's relevant.

[edit]Remove broken logic I spewed out last night.[/edit]
« Last Edit: August 21, 2014, 09:49:21 am by konadave »

konadave

  • I’m new here
  • *
  • Posts: 19
  • Karma: 0
  • CiviCRM version: 4.2.6
  • CMS version: Drupal 7.17
  • MySQL version: 5.1.66
  • PHP version: 5.3.19
Re: post create MembershipPayment contribution issue
August 21, 2014, 09:51:06 am
Quote from: joanne on August 20, 2014, 06:22:13 pm
As a non-coder this is a stab in the dark, but it sounds rather like a problem we have had.  Is https://issues.civicrm.org/jira/browse/CRM-15148 relevant?

I thought about it more and decided that it might actually be relevant. I copied api/v3/utils.php into the extension and made the two line fix. Everything is back in working order.

Thank you so much for pointing this out.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • post create MembershipPayment contribution issue

This forum was archived on 2017-11-26.