Skip to content

FOUR-32114 / FOUR-32202: Correct user signals on restore and delete#8893

Open
eiresendez wants to merge 2 commits into
developfrom
bugfix/FOUR-32114
Open

FOUR-32114 / FOUR-32202: Correct user signals on restore and delete#8893
eiresendez wants to merge 2 commits into
developfrom
bugfix/FOUR-32114

Conversation

@eiresendez

@eiresendez eiresendez commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Issue & Reproduction Steps

User lifecycle actions could emit redundant user signals when package-advanced-user-manager is installed:

  • FOUR-32114: Restoring a soft-deleted user emitted two user_update events because the model callback saved once and Laravel SoftDeletes saved again.
  • FOUR-32202: Deleting a user emitted user_update before user_delete because the deleting callback saved status = INACTIVE with normal model events.

To reproduce the delete issue:

  1. Enable user-signal.update and user-signal.delete.
  2. Configure processes that listen for user_update and user_delete.
  3. Delete a user through Admin > Users or DELETE /api/1.0/users/{user}.
  4. Observe both signals instead of only user_delete.

Solution

  • Removed the extra save() from User::restoring and let Laravel persist status = ACTIVE with deleted_at = null in its restore save.
  • Changed User::deleting to saveQuietly(), preserving status = INACTIVE without emitting an updated event before deletion.
  • Kept the normal deleted event so package-advanced-user-manager still emits user_delete.
  • Made the core regression tests self-contained by asserting Eloquent lifecycle events instead of requiring an optional package.

No routes, payloads, configuration, database schema, or public APIs were changed.

How to Test

Automated checks run:

  • php -l ProcessMaker/Models/User.php
  • php -l tests/Feature/Api/UsersTest.php
  • vendor/bin/phpunit tests/Feature/Api/UsersTest.php --filter=testRestoreSoftDeletedUserDispatchesOneUpdatedEvent
  • vendor/bin/phpunit tests/Feature/Api/UsersTest.php --filter=testDeleteUserDispatchesDeletedWithoutUpdatedEvent
  • vendor/bin/phpunit tests/Feature/Api/UsersTest.php
  • git diff --check

Result: 29 tests passed with 370 assertions in UsersTest.php.

Manual QA:

  1. Restore a soft-deleted user and confirm exactly one user_update.
  2. Delete a user and confirm no user_update and exactly one user_delete.
  3. Confirm the deleted user remains soft-deleted with status = INACTIVE and is removed from its groups.

Related Tickets & Packages

ci:deploy

.

@eiresendez
eiresendez requested a review from CarliPinell July 2, 2026 21:55
@eiresendez eiresendez self-assigned this Jul 2, 2026

@CarliPinell CarliPinell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.
No observations were found.

@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-e1313a8493.engk8s.processmaker.net

@eiresendez eiresendez changed the title FOUR-32114: Prevent duplicate user update signal on restore FOUR-32114 / FOUR-32202: Correct user signals on restore and delete Jul 15, 2026
@eiresendez
eiresendez requested a review from CarliPinell July 15, 2026 16:10
@eiresendez

eiresendez commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

FOUR-32202 is now included in this PR as a separate commit. The delete path persists status = INACTIVE quietly, so it no longer emits user_update before user_delete. The core user API suite passes (29 tests, 370 assertions).

@processmaker-sonarqube

Copy link
Copy Markdown

@eiresendez
eiresendez requested a review from mcraeteisha July 15, 2026 16:24
@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-e1313a8493.engk8s.processmaker.net

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants