summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Http/RequestHandlers/DataFixUpdateAll.php6
-rw-r--r--app/Module/FixCemeteryTag.php7
-rw-r--r--app/Module/FixDuplicateLinks.php30
-rw-r--r--app/Module/FixMissingDeaths.php6
-rw-r--r--app/Module/FixMissingMarriedNames.php6
-rw-r--r--app/Module/FixNameSlashesAndSpaces.php6
-rw-r--r--app/Module/FixNameTags.php4
-rw-r--r--app/Module/FixPlaceNames.php6
-rw-r--r--app/Module/FixPrimaryTag.php3
-rw-r--r--app/Module/FixSearchAndReplace.php9
-rw-r--r--app/Module/ModuleDataFixTrait.php169
11 files changed, 193 insertions, 59 deletions
diff --git a/app/Http/RequestHandlers/DataFixUpdateAll.php b/app/Http/RequestHandlers/DataFixUpdateAll.php
index 52e6e33d91..457f2c5eae 100644
--- a/app/Http/RequestHandlers/DataFixUpdateAll.php
+++ b/app/Http/RequestHandlers/DataFixUpdateAll.php
@@ -41,7 +41,7 @@ use function response;
class DataFixUpdateAll implements RequestHandlerInterface
{
// Process this number of records in each HTTP request
- private const CHUNK_SIZE = 100;
+ private const CHUNK_SIZE = 250;
/** @var DataFixService */
private $data_fix_service;
@@ -92,9 +92,7 @@ class DataFixUpdateAll implements RequestHandlerInterface
}
/** @var Collection<GedcomRecord> $records */
- $records = $rows->filter(static function (stdClass $row) use ($start, $end): bool {
- return $row->xref >= $start && $row->xref <= $end;
- })->map(function (stdClass $row) use ($tree): ?GedcomRecord {
+ $records = $rows->map(function (stdClass $row) use ($tree): ?GedcomRecord {
return $this->data_fix_service->getRecordByType($row->xref, $tree, $row->type);
})->filter(static function (?GedcomRecord $record) use ($module, $params): bool {
return $record instanceof GedcomRecord && !$record->isPendingDeletion() && $module->doesRecordNeedUpdate($record, $params);
diff --git a/app/Module/FixCemeteryTag.php b/app/Module/FixCemeteryTag.php
index e2a6bc8c9b..52fad6c13f 100644
--- a/app/Module/FixCemeteryTag.php
+++ b/app/Module/FixCemeteryTag.php
@@ -2,7 +2,7 @@
/**
* webtrees: online genealogy
- * Copyright (C) 2019 webtrees development team
+ * Copyright (C) 2020 webtrees development team
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -24,7 +24,6 @@ use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Services\DataFixService;
use Fisharebest\Webtrees\Tree;
-use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Collection;
@@ -106,9 +105,7 @@ class FixCemeteryTag extends AbstractModule implements ModuleDataFixInterface
*/
protected function individualsToFix(Tree $tree, array $params): ?Collection
{
- // No DB querying possible? Select all.
- return DB::table('individuals')
- ->where('i_file', '=', $tree->id())
+ return $this->individualsToFixQuery($tree, $params)
->where(static function (Builder $query): void {
$query
->where('i_gedcom', 'LIKE', "%\n2 CEME%")
diff --git a/app/Module/FixDuplicateLinks.php b/app/Module/FixDuplicateLinks.php
index 5dff70dd4e..b559193341 100644
--- a/app/Module/FixDuplicateLinks.php
+++ b/app/Module/FixDuplicateLinks.php
@@ -2,7 +2,7 @@
/**
* webtrees: online genealogy
- * Copyright (C) 2019 webtrees development team
+ * Copyright (C) 2020 webtrees development team
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -21,12 +21,8 @@ namespace Fisharebest\Webtrees\Module;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\I18N;
-use Fisharebest\Webtrees\Note;
-use Fisharebest\Webtrees\Repository;
use Fisharebest\Webtrees\Services\DataFixService;
-use Fisharebest\Webtrees\Submitter;
use Fisharebest\Webtrees\Tree;
-use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Support\Collection;
use function preg_match;
@@ -86,8 +82,7 @@ class FixDuplicateLinks extends AbstractModule implements ModuleDataFixInterface
protected function familiesToFix(Tree $tree, array $params): Collection
{
// No DB querying possible? Select all.
- return DB::table('families')
- ->where('f_file', '=', $tree->id())
+ return $this->familiesToFixQuery($tree, $params)
->pluck('f_id');
}
@@ -103,8 +98,7 @@ class FixDuplicateLinks extends AbstractModule implements ModuleDataFixInterface
protected function individualsToFix(Tree $tree, array $params): ?Collection
{
// No DB querying possible? Select all.
- return DB::table('individuals')
- ->where('i_file', '=', $tree->id())
+ return $this->individualsToFixQuery($tree, $params)
->pluck('i_id');
}
@@ -120,8 +114,7 @@ class FixDuplicateLinks extends AbstractModule implements ModuleDataFixInterface
protected function mediaToFix(Tree $tree, array $params): Collection
{
// No DB querying possible? Select all.
- return DB::table('media')
- ->where('m_file', '=', $tree->id())
+ return $this->mediaToFixQuery($tree, $params)
->pluck('m_id');
}
@@ -137,9 +130,7 @@ class FixDuplicateLinks extends AbstractModule implements ModuleDataFixInterface
protected function notesToFix(Tree $tree, array $params): Collection
{
// No DB querying possible? Select all.
- return DB::table('other')
- ->where('o_file', '=', $tree->id())
- ->where('o_type', '=', Note::RECORD_TYPE)
+ return $this->notesToFixQuery($tree, $params)
->pluck('o_id');
}
@@ -155,9 +146,7 @@ class FixDuplicateLinks extends AbstractModule implements ModuleDataFixInterface
protected function repositoriesToFix(Tree $tree, array $params): Collection
{
// No DB querying possible? Select all.
- return DB::table('other')
- ->where('o_file', '=', $tree->id())
- ->where('o_type', '=', Repository::RECORD_TYPE)
+ return $this->repositoriesToFixQuery($tree, $params)
->pluck('o_id');
}
@@ -173,8 +162,7 @@ class FixDuplicateLinks extends AbstractModule implements ModuleDataFixInterface
protected function sourcesToFix(Tree $tree, array $params): Collection
{
// No DB querying possible? Select all.
- return DB::table('sources')
- ->where('s_file', '=', $tree->id())
+ return $this->sourcesToFixQuery($tree, $params)
->pluck('s_id');
}
@@ -190,9 +178,7 @@ class FixDuplicateLinks extends AbstractModule implements ModuleDataFixInterface
protected function submittersToFix(Tree $tree, array $params): Collection
{
// No DB querying possible? Select all.
- return DB::table('other')
- ->where('o_file', '=', $tree->id())
- ->where('o_type', '=', Submitter::RECORD_TYPE)
+ return $this->submittersToFixQuery($tree, $params)
->pluck('o_id');
}
diff --git a/app/Module/FixMissingDeaths.php b/app/Module/FixMissingDeaths.php
index 31a61a763b..af9bd879b4 100644
--- a/app/Module/FixMissingDeaths.php
+++ b/app/Module/FixMissingDeaths.php
@@ -2,7 +2,7 @@
/**
* webtrees: online genealogy
- * Copyright (C) 2019 webtrees development team
+ * Copyright (C) 2020 webtrees development team
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -25,7 +25,6 @@ use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Services\DataFixService;
use Fisharebest\Webtrees\Tree;
-use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Support\Collection;
/**
@@ -81,8 +80,7 @@ class FixMissingDeaths extends AbstractModule implements ModuleDataFixInterface
*/
protected function individualsToFix(Tree $tree, array $params): ?Collection
{
- $query = DB::table('individuals')
- ->where('i_file', '=', $tree->id());
+ $query = $this->individualsToFixQuery($tree, $params);
foreach (Gedcom::DEATH_EVENTS as $event) {
$query->where('i_gedcom', 'NOT LIKE', "%\n1 " . $event . '%');
diff --git a/app/Module/FixMissingMarriedNames.php b/app/Module/FixMissingMarriedNames.php
index bce2637a4c..a8d21aea64 100644
--- a/app/Module/FixMissingMarriedNames.php
+++ b/app/Module/FixMissingMarriedNames.php
@@ -25,7 +25,6 @@ use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Services\DataFixService;
use Fisharebest\Webtrees\Tree;
-use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Support\Collection;
use function array_merge;
@@ -114,9 +113,8 @@ class FixMissingMarriedNames extends AbstractModule implements ModuleDataFixInte
*/
protected function individualsToFix(Tree $tree, array $params): ?Collection
{
- // No DB querying possible? Select all.
- return DB::table('individuals')
- ->where('i_file', '=', $tree->id())
+ // No DB querying possible? Select all females.
+ return $this->individualsToFixQuery($tree, $params)
->where('i_sex', '=', 'F')
->pluck('i_id');
}
diff --git a/app/Module/FixNameSlashesAndSpaces.php b/app/Module/FixNameSlashesAndSpaces.php
index 6b0d238812..ee6a92696b 100644
--- a/app/Module/FixNameSlashesAndSpaces.php
+++ b/app/Module/FixNameSlashesAndSpaces.php
@@ -2,7 +2,7 @@
/**
* webtrees: online genealogy
- * Copyright (C) 2019 webtrees development team
+ * Copyright (C) 2020 webtrees development team
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -23,7 +23,6 @@ use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Services\DataFixService;
use Fisharebest\Webtrees\Tree;
-use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Support\Collection;
use function preg_match;
@@ -83,8 +82,7 @@ class FixNameSlashesAndSpaces extends AbstractModule implements ModuleDataFixInt
protected function individualsToFix(Tree $tree, array $params): ?Collection
{
// No DB querying possible? Select all.
- return DB::table('individuals')
- ->where('i_file', '=', $tree->id())
+ return $this->individualsToFixQuery($tree, $params)
->pluck('i_id');
}
diff --git a/app/Module/FixNameTags.php b/app/Module/FixNameTags.php
index 79332d3f06..8415cc850c 100644
--- a/app/Module/FixNameTags.php
+++ b/app/Module/FixNameTags.php
@@ -24,7 +24,6 @@ use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Services\DataFixService;
use Fisharebest\Webtrees\Tree;
-use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Collection;
@@ -106,8 +105,7 @@ class FixNameTags extends AbstractModule implements ModuleDataFixInterface
*/
public function individualsToFix(Tree $tree, array $params): Collection
{
- return DB::table('individuals')
- ->where('i_file', '=', $tree->id())
+ return $this->individualsToFixQuery($tree, $params)
->where(static function (Builder $query): void {
foreach (array_keys(self::CONVERT) as $tag) {
$query->orWhere('i_gedcom', 'LIKE', "%\n2 " . $tag . " %");
diff --git a/app/Module/FixPlaceNames.php b/app/Module/FixPlaceNames.php
index f62c5f55af..28ed6ed969 100644
--- a/app/Module/FixPlaceNames.php
+++ b/app/Module/FixPlaceNames.php
@@ -23,7 +23,6 @@ use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Services\DataFixService;
use Fisharebest\Webtrees\Tree;
-use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Support\Collection;
use function addcslashes;
@@ -103,8 +102,7 @@ class FixPlaceNames extends AbstractModule implements ModuleDataFixInterface
$search = '%' . addcslashes($params['search'], '\\%_') . '%';
- return DB::table('families')
- ->where('f_file', '=', $tree->id())
+ return $this->familiesToFixQuery($tree, $params)
->where('f_gedcom', 'LIKE', $search)
->pluck('f_id');
}
@@ -126,7 +124,7 @@ class FixPlaceNames extends AbstractModule implements ModuleDataFixInterface
$search = '%' . addcslashes($params['search'], '\\%_') . '%';
- return DB::table('individuals')
+ return $this->individualsToFixQuery($tree, $params)
->where('i_file', '=', $tree->id())
->where('i_gedcom', 'LIKE', $search)
->pluck('i_id');
diff --git a/app/Module/FixPrimaryTag.php b/app/Module/FixPrimaryTag.php
index 4784a75298..8dc4a8ff7b 100644
--- a/app/Module/FixPrimaryTag.php
+++ b/app/Module/FixPrimaryTag.php
@@ -24,7 +24,6 @@ use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Tree;
-use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Support\Collection;
use function e;
@@ -70,7 +69,7 @@ class FixPrimaryTag extends AbstractModule implements ModuleDataFixInterface
*/
public function mediaToFix(Tree $tree, array $params): Collection
{
- return DB::table('media')
+ return $this->mediaToFixQuery($tree, $params)
->where('m_file', '=', $tree->id())
->where('m_gedcom', 'LIKE', "%\n1 _PRIM %")
->pluck('m_id');
diff --git a/app/Module/FixSearchAndReplace.php b/app/Module/FixSearchAndReplace.php
index cf50cf1ca6..0a285a546a 100644
--- a/app/Module/FixSearchAndReplace.php
+++ b/app/Module/FixSearchAndReplace.php
@@ -2,7 +2,7 @@
/**
* webtrees: online genealogy
- * Copyright (C) 2019 webtrees development team
+ * Copyright (C) 2020 webtrees development team
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -255,8 +255,7 @@ class FixSearchAndReplace extends AbstractModule implements ModuleDataFixInterfa
return null;
}
- $query = DB::table('sources')
- ->where('s_file', '=', $tree->id());
+ $query = $this->sourcesToFixQuery($tree, $params);
$this->recordQuery($query, 's_gedcom', $params);
@@ -278,9 +277,7 @@ class FixSearchAndReplace extends AbstractModule implements ModuleDataFixInterfa
return null;
}
- $query = DB::table('other')
- ->where('o_file', '=', $tree->id())
- ->where('o_type', '=', Submitter::RECORD_TYPE);
+ $query = $this->submittersToFixQuery($tree, $params);
$this->recordQuery($query, 'o_gedcom', $params);
diff --git a/app/Module/ModuleDataFixTrait.php b/app/Module/ModuleDataFixTrait.php
index de4042675d..16d1ace350 100644
--- a/app/Module/ModuleDataFixTrait.php
+++ b/app/Module/ModuleDataFixTrait.php
@@ -2,7 +2,7 @@
/**
* webtrees: online genealogy
- * Copyright (C) 2019 webtrees development team
+ * Copyright (C) 2020 webtrees development team
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -22,6 +22,7 @@ namespace Fisharebest\Webtrees\Module;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Location;
use Fisharebest\Webtrees\Media;
use Fisharebest\Webtrees\Note;
use Fisharebest\Webtrees\Repository;
@@ -63,6 +64,7 @@ trait ModuleDataFixTrait
{
$families = $this->familiesToFix($tree, $params);
$individuals = $this->individualsToFix($tree, $params);
+ $locations = $this->locationsToFix($tree, $params);
$media = $this->mediaToFix($tree, $params);
$notes = $this->notesToFix($tree, $params);
$repositories = $this->repositoriesToFix($tree, $params);
@@ -79,6 +81,10 @@ trait ModuleDataFixTrait
$records = $records->concat($this->mergePendingRecords($individuals, $tree, Individual::RECORD_TYPE));
}
+ if ($locations !== null) {
+ $records = $records->concat($this->mergePendingRecords($locations, $tree, Location::RECORD_TYPE));
+ }
+
if ($media !== null) {
$records = $records->concat($this->mergePendingRecords($media, $tree, Media::RECORD_TYPE));
}
@@ -158,6 +164,24 @@ trait ModuleDataFixTrait
}
/**
+ * @param Tree $tree
+ * @param array<string,string> $params
+ *
+ * @return Builder
+ */
+ protected function familiesToFixQuery(Tree $tree, array $params): Builder
+ {
+ $query = DB::table('families')
+ ->where('i_file', '=', $tree->id());
+
+ if (isset($params['start'], $params['end'])) {
+ $query->whereBetween('i_id', [$params['start'], $params['end']]);
+ }
+
+ return $query;
+ }
+
+ /**
* XREFs of individual records that might need fixing.
*
* @param Tree $tree
@@ -171,6 +195,56 @@ trait ModuleDataFixTrait
}
/**
+ * @param Tree $tree
+ * @param array<string,string> $params
+ *
+ * @return Builder
+ */
+ protected function individualsToFixQuery(Tree $tree, array $params): Builder
+ {
+ $query = DB::table('individuals')
+ ->where('i_file', '=', $tree->id());
+
+ if (isset($params['start'], $params['end'])) {
+ $query->whereBetween('i_id', [$params['start'], $params['end']]);
+ }
+
+ return $query;
+ }
+
+ /**
+ * XREFs of location records that might need fixing.
+ *
+ * @param Tree $tree
+ * @param array<string,string> $params
+ *
+ * @return Collection<string>|null
+ */
+ protected function locationsToFix(Tree $tree, array $params): ?Collection
+ {
+ return null;
+ }
+
+ /**
+ * @param Tree $tree
+ * @param array<string,string> $params
+ *
+ * @return Builder
+ */
+ protected function locationsToFixQuery(Tree $tree, array $params): Builder
+ {
+ $query = DB::table('other')
+ ->where('o_type', '=', Location::RECORD_TYPE)
+ ->where('o_file', '=', $tree->id());
+
+ if (isset($params['start'], $params['end'])) {
+ $query->whereBetween('o_id', [$params['start'], $params['end']]);
+ }
+
+ return $query;
+ }
+
+ /**
* XREFs of media records that might need fixing.
*
* @param Tree $tree
@@ -184,6 +258,24 @@ trait ModuleDataFixTrait
}
/**
+ * @param Tree $tree
+ * @param array<string,string> $params
+ *
+ * @return Builder
+ */
+ protected function mediaToFixQuery(Tree $tree, array $params): Builder
+ {
+ $query = DB::table('media')
+ ->where('m_file', '=', $tree->id());
+
+ if (isset($params['start'], $params['end'])) {
+ $query->whereBetween('m_id', [$params['start'], $params['end']]);
+ }
+
+ return $query;
+ }
+
+ /**
* XREFs of note records that might need fixing.
*
* @param Tree $tree
@@ -197,6 +289,25 @@ trait ModuleDataFixTrait
}
/**
+ * @param Tree $tree
+ * @param array<string,string> $params
+ *
+ * @return Builder
+ */
+ protected function notesToFixQuery(Tree $tree, array $params): Builder
+ {
+ $query = DB::table('other')
+ ->where('o_type', '=', Note::RECORD_TYPE)
+ ->where('o_file', '=', $tree->id());
+
+ if (isset($params['start'], $params['end'])) {
+ $query->whereBetween('o_id', [$params['start'], $params['end']]);
+ }
+
+ return $query;
+ }
+
+ /**
* XREFs of repository records that might need fixing.
*
* @param Tree $tree
@@ -210,6 +321,25 @@ trait ModuleDataFixTrait
}
/**
+ * @param Tree $tree
+ * @param array<string,string> $params
+ *
+ * @return Builder
+ */
+ protected function repositoriesToFixQuery(Tree $tree, array $params): Builder
+ {
+ $query = DB::table('other')
+ ->where('o_type', '=', Repository::RECORD_TYPE)
+ ->where('o_file', '=', $tree->id());
+
+ if (isset($params['start'], $params['end'])) {
+ $query->whereBetween('o_id', [$params['start'], $params['end']]);
+ }
+
+ return $query;
+ }
+
+ /**
* XREFs of source records that might need fixing.
*
* @param Tree $tree
@@ -223,6 +353,24 @@ trait ModuleDataFixTrait
}
/**
+ * @param Tree $tree
+ * @param array<string,string> $params
+ *
+ * @return Builder
+ */
+ protected function sourcesToFixQuery(Tree $tree, array $params): Builder
+ {
+ $query = DB::table('sources')
+ ->where('s_file', '=', $tree->id());
+
+ if (isset($params['start'], $params['end'])) {
+ $query->whereBetween('s_id', [$params['start'], $params['end']]);
+ }
+
+ return $query;
+ }
+
+ /**
* XREFs of submitter records that might need fixing.
*
* @param Tree $tree
@@ -236,6 +384,25 @@ trait ModuleDataFixTrait
}
/**
+ * @param Tree $tree
+ * @param array<string,string> $params
+ *
+ * @return Builder
+ */
+ protected function submittersToFixQuery(Tree $tree, array $params): Builder
+ {
+ $query = DB::table('other')
+ ->where('o_type', '=', Submitter::RECORD_TYPE)
+ ->where('o_file', '=', $tree->id());
+
+ if (isset($params['start'], $params['end'])) {
+ $query->whereBetween('o_id', [$params['start'], $params['end']]);
+ }
+
+ return $query;
+ }
+
+ /**
* Merge pending changes of a given type. We need to check all pending records.
*
* @param Collection<string> $records