Add History Logging for Family Merge and Detach Operations#790
Open
vahidbazzaz wants to merge 5 commits intomasterfrom
Open
Add History Logging for Family Merge and Detach Operations#790vahidbazzaz wants to merge 5 commits intomasterfrom
vahidbazzaz wants to merge 5 commits intomasterfrom
Conversation
Contributor
Author
HaGuesto
requested changes
Dec 2, 2025
Member
There was a problem hiding this comment.
@Vahid I tested this a bit more in depth and would say we need another iteration:
from the functional test:
- the lastModified date in the people table is somehow not updated could you maybe adapt the definition of the
simpleBulkSaveChangeHistoryto do this too?
from the code review
- since we do not show the history messages anywhere, I'm happy how they look like atm, but it would be great if you could move the
fromandtovalues out of thechangemessage into the right bits ofsimpleBulkSaveChangeHistory($table, $records, $changes, $from = [], $to = []) - maybe put "parent_id;" in front in the
changemessage to make clear that the parent_id in the record was changed.
I left comments in the code to make it clearer
HaGuesto
reviewed
Dec 2, 2025
| } | ||
| } | ||
| }); | ||
| simpleBulkSaveChangeHistory('people', $ids, 'merged to family (head: '.$oldest.')'); |
Member
There was a problem hiding this comment.
this should maybe be simpleBulkSaveChangeHistory('people', $ids, 'parent_id; merged to family', [], ['int'=> <parent_id>);
HaGuesto
reviewed
Dec 2, 2025
| db_query('UPDATE people SET parent_id = NULL WHERE id = :id', ['id' => $id]); | ||
| } | ||
| }); | ||
| simpleBulkSaveChangeHistory('people', $ids, 'detached from family'); |
Member
There was a problem hiding this comment.
this should maybe be simpleBulkSaveChangeHistory('people', $ids, 'parent_id; detached from family', ['int'=> <parent_id>, []);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds comprehensive history logging for family merge and detach operations in the beneficiary management system. Previously, when families were merged or detached (either via action buttons or drag & drop), no audit trail was created in the history table. This made it impossible to investigate cases where beneficiaries (including small children) were unexpectedly deactivated or moved between families.
Changes Made
1. In Manage Beneficiaries add history log if beneficiary is added to a family via drag & drop
include/people.php:503added to family via drag & drop2. In Manage Beneficiaries add history log if beneficiary is removed from a family via drag & drop
include/people.php:506removed from family via drag & drop3. In Manage Beneficiaries add history log if beneficiaries are merged to a family via selection and action button
include/people.php:442merged to family (head: [id])4. In Manage Beneficiaries add history log if beneficiaries are detached from a family via selection and action button
include/people.php:468detached from family5. Drag & Drop Implementation Details
library/lib/list.php:58-94listBulkMove()to track parent_id changes during drag & drop operations6. Cypress Tests
cypress/support/database.js,cypress/e2e/1_feature_tests/5_3_Manage_Beneficiaries.jscheckHistoryLog()command to verify history entries exist in databasegetBeneficiaryIdFromRow()command to extract beneficiary IDs from DOMlibrary/ajax/testhistorycheck.phpfor test verificationTesting
✅ All Cypress tests passing: