Skip to content

Commit

Permalink
Fix: #4497 - only delete one-person family records when there are no …
Browse files Browse the repository at this point in the history
…facts
  • Loading branch information
fisharebest committed Jul 7, 2022
1 parent d40f78e commit 588fd84
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/Http/RequestHandlers/DeleteRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$old_gedcom = $linker->gedcom();
$new_gedcom = $this->removeLinks($old_gedcom, $record->xref());
if ($old_gedcom !== $new_gedcom) {
// If we have removed a link from a family to an individual, and it now has only one member
if ($linker instanceof Family && preg_match_all('/\n1 (HUSB|WIFE|CHIL) @(' . Gedcom::REGEX_XREF . ')@/', $new_gedcom, $match) === 1) {
// If we have removed a link from a family to an individual, and it now has only one member and no genealogy facts
if (
$linker instanceof Family &&
preg_match('/\n1 (ANUL|CENS|DIV|DIVF|ENGA|MAR[BCLRS]|RESI|EVEN)/', $new_gedcom, $match) !== 1 &&
preg_match_all('/\n1 (HUSB|WIFE|CHIL) @(' . Gedcom::REGEX_XREF . ')@/', $new_gedcom, $match) === 1
) {
// Delete the family
/* I18N: %s is the name of a family group, e.g. “Husband name + Wife name” */
FlashMessages::addMessage(I18N::translate('The family “%s” has been deleted because it only has one member.', $linker->fullName()));
Expand Down

0 comments on commit 588fd84

Please sign in to comment.