From 63b1851d18dc5df8dcb1a599116a3831998ab96c Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Fri, 19 Nov 2021 17:57:46 +0000 Subject: Fix: pending deletions can break the changes report --- app/Report/ReportParserGenerate.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'app/Report') diff --git a/app/Report/ReportParserGenerate.php b/app/Report/ReportParserGenerate.php index 7fed3c9c7d..b8c13d6490 100644 --- a/app/Report/ReportParserGenerate.php +++ b/app/Report/ReportParserGenerate.php @@ -1833,7 +1833,7 @@ class ReportParserGenerate extends ReportParserBase // Some filters/sorts can be applied using SQL, while others require PHP switch ($listname) { case 'pending': - $xrefs = DB::table('change') + $this->list = DB::table('change') ->whereIn('change_id', function (Builder $query): void { $query->select(new Expression('MAX(change_id)')) ->from('change') @@ -1841,13 +1841,12 @@ class ReportParserGenerate extends ReportParserBase ->where('status', '=', 'pending') ->groupBy(['xref']); }) - ->pluck('xref'); - - $this->list = []; - foreach ($xrefs as $xref) { - $this->list[] = Registry::gedcomRecordFactory()->make($xref, $this->tree); - } + ->get() + ->map(fn (object $row): ?GedcomRecord => Registry::gedcomRecordFactory()->make($row->xref, $this->tree, $row->new_gedcom ?: $row->old_gedcom)) + ->filter() + ->all(); break; + case 'individual': $query = DB::table('individuals') ->where('i_file', '=', $this->tree->id()) -- cgit v1.3