Skip to content

Commit

Permalink
Fix: #3904 - update XREFs in blocks (e.g. stories) after merging
Browse files Browse the repository at this point in the history
  • Loading branch information
fisharebest committed May 24, 2021
1 parent ee51991 commit ecc5b3c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/Http/RequestHandlers/MergeFactsAction.php
Expand Up @@ -101,7 +101,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
), 'info');
$gedcom = str_replace('@' . $xref2 . '@', '@' . $xref1 . '@', $record->gedcom());
$gedcom = preg_replace(
'/(\n1.*@.+@.*(?:(?:\n[2-9].*)*))((?:\n1.*(?:\n[2-9].*)*)*\1)/',
'/(\n1.*@.+@.*(?:\n[2-9].*)*)((?:\n1.*(?:\n[2-9].*)*)*\1)/',
'$2',
$gedcom
);
Expand All @@ -116,6 +116,12 @@ public function handle(ServerRequestInterface $request): ResponseInterface
->where('setting_value', '=', $xref2)
->update(['setting_value' => $xref1]);

// Merge stories, etc.
DB::table('block')
->where('gedcom_id', '=', $tree->id())
->where('xref', '=', $xref2)
->update(['xref' => $xref1]);

// Merge hit counters
$hits = DB::table('hit_counter')
->where('gedcom_id', '=', $tree->id())
Expand Down

0 comments on commit ecc5b3c

Please sign in to comment.