summaryrefslogtreecommitdiff
path: root/app/Services
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2025-06-03 14:26:09 +0100
committerGreg Roach <greg@subaqua.co.uk>2025-06-03 14:36:43 +0100
commit85077687541941260bc4696c678259aa583d91ba (patch)
tree10bd0eb57573600224215eed834542b9a674f943 /app/Services
parentac2380f4b6c5d3d3b64e96340e062e496a22d826 (diff)
downloadwebtrees-85077687541941260bc4696c678259aa583d91ba.tar.gz
webtrees-85077687541941260bc4696c678259aa583d91ba.tar.bz2
webtrees-85077687541941260bc4696c678259aa583d91ba.zip
Fix: #5099 - wrong binding order in querybuilder
Diffstat (limited to 'app/Services')
-rw-r--r--app/Services/AdminService.php17
1 files changed, 10 insertions, 7 deletions
diff --git a/app/Services/AdminService.php b/app/Services/AdminService.php
index bd49e017a4..d7157e7b0e 100644
--- a/app/Services/AdminService.php
+++ b/app/Services/AdminService.php
@@ -62,9 +62,12 @@ class AdminService
*/
public function countCommonXrefs(Tree $tree1, Tree $tree2): int
{
- $subquery1 = DB::table('individuals')
- ->where('i_file', '=', $tree1->id())
- ->select(['i_id AS xref'])
+ $subquery1 = DB::table('change')
+ ->where('gedcom_id', '=', $tree1->id())
+ ->select(['xref AS xref1'])
+ ->union(DB::table('individuals')
+ ->where('i_file', '=', $tree1->id())
+ ->select(['i_id AS xref']))
->union(DB::table('families')
->where('f_file', '=', $tree1->id())
->select(['f_id AS xref']))
@@ -81,7 +84,7 @@ class AdminService
$subquery2 = DB::table('change')
->where('gedcom_id', '=', $tree2->id())
- ->select(['xref AS other_xref'])
+ ->select(['xref AS xref2'])
->union(DB::table('individuals')
->where('i_file', '=', $tree2->id())
->select(['i_id AS xref']))
@@ -99,9 +102,9 @@ class AdminService
->whereNotIn('o_type', [Header::RECORD_TYPE, 'TRLR'])
->select(['o_id AS xref']));
- return DB::table(new Expression('(' . $subquery1->toSql() . ') AS sub1'))
- ->mergeBindings($subquery1)
- ->joinSub($subquery2, 'sub2', 'other_xref', '=', 'xref')
+ return DB::query()
+ ->fromSub($subquery1, 'sub1')
+ ->joinSub($subquery2, 'sub2', 'xref1', '=', 'xref2')
->count();
}