Answers.Body: <p>Sorry but it's the intended behavior. Generally pre and post hooks just pass whatever happens to be loaded in that object rather than taking the performance hit of doing a full database load for the sake of a hook which may or may not be implemented and may or may not care.</p>
  
  <p>I recommend not relying on the object being passed to pre/post hooks and doing your own api lookup using the provided id.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-13T16:44:05.843Z
Answers.Text: Thanks for confirming, Coleman. I think this is the first case I've come across of a post hook not receiving a populated object for op = 'edit'. However hook_civicrm_enableDisable wasn't receiving one, so in that sense I'm no worse off. Better be extra-careful with post hooks now though.
Answers.UserDisplayName: davejenx
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-13T16:32:12.033Z
Answers.LastActivityDate: 2015-07-13T16:32:12.033Z
Answers.UserDisplayName: Coleman
Body: <p>I'm porting some code using Civi hooks from Civi 4.4 to 4.6 . The code needs to know when a relationship becomes active or inactive, regardless of how that happens, including via the enable/disable links on the Relationships tab.</p>
  
  <p>My implementation for 4.4 used both hook_civicrm_post and hook_civicrm_enableDisable. In Civi 4.6, <a href="http://wiki.civicrm.org/confluence/pages/viewpage.action?pageId=124813469" rel="nofollow">hook_civicrm_enableDisable has been removed</a>. I've found that hook_civicrm_post gets called when the enable/disable links are used but the CRM_Contact_DAO_Relationship object passed in only has the id field populated, all the other fields are blank.</p>
  
  <p>Is this a bug and so should be addressed in core, or intended behaviour and so something I have to work around in my hook implementation?</p>
  
  <p>I'm using CiviCRM 4.6.4 with Drupal 7.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-14T08:53:48.923Z
Comments.Text: I've run into this before: https://issues.civicrm.org/jira/browse/CRM-15914
Comments.UserDisplayName: DaveFF
Tags: <hooks><relationships>
Title: Should civicrm_post hook receive populated Relationship object following relationship enable/disable in UI?
ThreadText: # Should civicrm_post hook receive populated Relationship object following relationship enable/disable in UI?
  
  (Asked by: username_0 on 2015-07-13)
  
  I'm porting some code using Civi hooks from Civi 4.4 to 4.6 . The code needs to know when a relationship becomes active or inactive, regardless of how that happens, including via the enable/disable links on the Relationships tab.
  
  My implementation for 4.4 used both hook\_civicrm\_post and hook\_civicrm\_enableDisable. In Civi 4.6, [hook\_civicrm\_enableDisable has been removed](http://wiki.civicrm.org/confluence/pages/viewpage.action?pageId=124813469). I've found that hook\_civicrm\_post gets called when the enable/disable links are used but the CRM\_Contact\_DAO\_Relationship object passed in only has the id field populated, all the other fields are blank.
  
  Is this a bug and so should be addressed in core, or intended behaviour and so something I have to work around in my hook implementation?
  
  I'm using CiviCRM 4.6.4 with Drupal 7.
  
  **Tags:** hooks, relationships
  
  > **Comments:**
  > **username_1**: I've run into this before: https://issues.civicrm.org/jira/browse/CRM-15914  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-07-13. Score: 2
  
  Sorry but it's the intended behavior. Generally pre and post hooks just pass whatever happens to be loaded in that object rather than taking the performance hit of doing a full database load for the sake of a hook which may or may not be implemented and may or may not care.
  
  I recommend not relying on the object being passed to pre/post hooks and doing your own api lookup using the provided id.
  
  > **Comments:**
  > **username_0**: Thanks for confirming, username_2. I think this is the first case I've come across of a post hook not receiving a populated object for op = 'edit'. However hook_civicrm_enableDisable wasn't receiving one, so in that sense I'm no worse off. Better be extra-careful with post hooks now though.  
  
  ---
  
  