summaryrefslogtreecommitdiff
path: root/app/Http/RequestHandlers/DeleteRecord.php
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2022-07-07 20:26:27 +0100
committerGreg Roach <greg@subaqua.co.uk>2022-07-07 20:26:27 +0100
commit588fd84b23cb5ea494febc6974507917b1688368 (patch)
tree402352fa895a8dfd59ca51cf09aa66f7e4db85d1 /app/Http/RequestHandlers/DeleteRecord.php
parentd40f78ed19c3aff91b2f80a56051dba5d124da0e (diff)
downloadwebtrees-588fd84b23cb5ea494febc6974507917b1688368.tar.gz
webtrees-588fd84b23cb5ea494febc6974507917b1688368.tar.bz2
webtrees-588fd84b23cb5ea494febc6974507917b1688368.zip
Fix: #4497 - only delete one-person family records when there are no facts
Diffstat (limited to 'app/Http/RequestHandlers/DeleteRecord.php')
-rw-r--r--app/Http/RequestHandlers/DeleteRecord.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/Http/RequestHandlers/DeleteRecord.php b/app/Http/RequestHandlers/DeleteRecord.php
index c5b483d44a..51019eef05 100644
--- a/app/Http/RequestHandlers/DeleteRecord.php
+++ b/app/Http/RequestHandlers/DeleteRecord.php
@@ -73,8 +73,12 @@ class DeleteRecord implements RequestHandlerInterface
$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()));