Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After_Save Hook on Prospect Lists is executed twice #9602

Closed
eojedapilchik opened this issue May 31, 2022 · 1 comment
Closed

After_Save Hook on Prospect Lists is executed twice #9602

eojedapilchik opened this issue May 31, 2022 · 1 comment
Labels
Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Type: Bug Bugs within the core SuiteCRM codebase

Comments

@eojedapilchik
Copy link
Contributor

Issue

Creating an after save hook on ProspectLists (Target List) will run twice. The after_save logic hook will be executed before the Save on the modules\ProspectLists\Save.php which calls the save() method (on line 79) of the focus (prospect list) triggering the after_save hook again.

Expected Behavior

The after_save hook is called after the save() method of the bean has been executed and no other save() method is being called.

Actual Behavior

The current sequence is save() -> after_save hooks -> save -> after_save hooks (again).
If an after_save hook is created any logic there will be executed twice, causing side effects.

Possible Fix

Remove the $focus->save(); on line 79 of modules\ProspectLists\Save.php and change the way the relationship are handle on that file (line 76 : $focus->set_relationship('prospect_lists_prospects', $rel, true);)

Steps to Reproduce

  1. Create and after_save logic hook on the ProspectLists module
  2. Add some logic to the after_save. Could be $GLOBALS['log']->fatal('SAVED') or create any type of record
  3. Check log or record created, it is executed twice

Your Environment

  • SuiteCRM Version used: 7.12
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Any
  • Environment name and version (e.g. MySQL, PHP 7): PHP 7.4
  • Operating System and version (e.g Ubuntu 16.04): Ubunt 20.04
@johnM2401 johnM2401 added Type: Bug Bugs within the core SuiteCRM codebase Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds labels Jun 3, 2022
@eojedapilchik
Copy link
Contributor Author

PR #9642

eojedapilchik pushed a commit to eojedapilchik/SuiteCRM that referenced this issue Sep 22, 2022
eojedapilchik pushed a commit to eojedapilchik/SuiteCRM that referenced this issue Feb 24, 2023
… issue

The save function is unnecessary and create a duplication of ater_save hooks on duplicate records
eojedapilchik added a commit to eojedapilchik/SuiteCRM that referenced this issue Feb 25, 2023
… issue

The save function is unnecessary and create a duplication of ater_save hooks on duplicate records
jack7anderson7 pushed a commit that referenced this issue Apr 24, 2023
The save function is unnecessary and create a duplication of ater_save hooks on duplicate records
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Type: Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

No branches or pull requests

2 participants