Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • C CiviCRM Core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,374
    • Issues 1,374
    • List
    • Boards
    • Service Desk
    • Milestones
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • CiviCRM Core
  • Issues
  • #161

Closed
Open
Created Jun 04, 2018 by omar_compucorp@omar_compucorp

Adding preSave_table_name hook

Currently there is only postSave_table_name hook that run after a write operation on a core table that has an associated DAO. But in some cases it is useful to have a hook that run before the write operation.

An example whwre such hook is useful is when you cancel a membership contribution then the membership status will also change to Cancelled, but the cancellation of the membership does not trigger hook_civicrm_pre nor hook_civicrm_post hooks because this is how civicrm change the membership status when you cancel the membership :

https://github.com/civicrm/civicrm-core/blob/cbaa9a31f02afda8d2e19610da823fd0c4d28a16/CRM/Contribute/BAO/Contribution.php#L1049-L1052

hence that hook_civicrm_pre and hook_civicrm_post are invoked in the BAO class create method so doing anything using DAO directly as in the example above won't invoke any of these hooks and if you are planning to do any operation before editing the membership table in the case above then you are out of luck.

A new hook similar to postSave_table_name hook with the name preSave_table_name should be added to solve the issue mentioned issue.

Edited Oct 28, 2019 by omar_compucorp
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking