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) »
  • ObjectID parameter in the preHook
Pages: [1]

Author Topic: ObjectID parameter in the preHook  (Read 786 times)

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
ObjectID parameter in the preHook
June 15, 2015, 03:14:34 am
When an entity is edited or deleted the parameter ObjectID is not always set in the pre hook.

For example I wanted to fetch the current state of an activity (before changes are saved). I used the pre hook to fetch this data from the database. But in the pre hook the objectId is not set. So I could not fetch this data. Is this on purpose or is it a core issue?

Jaap
Developer at Edeveloper / CiviCoop

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: ObjectID parameter in the preHook
June 15, 2015, 10:09:09 am
For the 'edit' and 'delete' actions, I agree that behavior is undesirable/inconsistent.

Doing a quick "rgrep Hook::pre CRM/Activity", it appears that deleteActivity() supports a bulk deletion mode (where it deletes by source_record_id and activity_type_id). The way it was written, the PHP code never has the ID# of the deleted activities. The function would probably need a rewrite to consistently support Hook::pre.

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: ObjectID parameter in the preHook
June 17, 2015, 12:12:06 am
So what would you suggest? Do I need to file a bug report and probably propose a fix?
Developer at Edeveloper / CiviCoop

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: ObjectID parameter in the preHook
June 17, 2015, 07:53:46 am
Yeah, that's a good path.

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: ObjectID parameter in the preHook
June 18, 2015, 12:23:57 am
Thanks, I have filed a bug report at: https://issues.civicrm.org/jira/browse/CRM-16721
Developer at Edeveloper / CiviCoop

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: ObjectID parameter in the preHook
June 22, 2015, 12:02:40 am
+1
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Kirk

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 2
  • CiviCRM version: 4.5.8
  • CMS version: Drupal 7.39
  • MySQL version: 5.5.44
  • PHP version: 5.6.13
Re: ObjectID parameter in the preHook
August 11, 2015, 03:31:17 am
+1

This is still a problem in version 4.6.6. When updating an activity, the $id parameter in the database pre hook is NULL when it should contain the ID of the activity being updated.

The issue (CRM-16721) currently has no-one assigned to fix it and no fix version set.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • ObjectID parameter in the preHook

This forum was archived on 2017-11-26.