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 (Moderator: Donald Lobo) »
  • data pre hook issue
Pages: [1]

Author Topic: data pre hook issue  (Read 1202 times)

dougall

  • Guest
data pre hook issue
June 03, 2008, 04:24:08 am
Hi,

The data hook documentation (http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification) for hook_civicrm_pre implies that the return value can prevent the operation occuring:
Quote
* @return mixed             based on op. pre-hooks return a boolean and/or
*                                  an error message which aborts the operation

I am attempting to prevent the deletion of a contact under certain circumstances (dependant upon results from a seperate drupal package) so I looked for where Hook::pre is called in civicrm.

CRM\Contact\BAO\Contact.php line 993 reads:
Code: [Select]
CRM_Utils_Hook::pre( 'delete', $contactType, $id, CRM_Core_DAO::$_nullArray );

...so contrary to what the docs imply the return value from the hook call is simply discarded, the same applies to all the other calls to CRM_Utils_Hook.

Perhaps I should add this as an issue?

Meanwhile can anyone suggest another approach which will allow me to prevent deletion of a contact?

Thanks,
  Dougall


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: data pre hook issue
June 03, 2008, 02:35:52 pm

I've fixed the documentation and deleted the "abort" statements.  I think aborting stuff in a nice manner will be quite hard until we move to a complete exception based error handling scheme (which will happen in CiviCRM v3.0 when we move to the Zend Framework from the PEAR library). Doing a fatal abort does not really make sense in this case (since folks can do a fatal abort in their code also)

There is an issue and a patch for this here: http://issues.civicrm.org/jira/browse/CRM-2415

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • data pre hook issue

This forum was archived on 2017-11-26.