summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-01-02 15:34:23 +0000
committerGreg Roach <fisharebest@webtrees.net>2019-01-02 15:34:23 +0000
commit8f9b0fb289eccd0c5057286c6cfe4391622acc59 (patch)
treeee1a433d82208348db8dbeda9b7502886eb49db9 /app
parent963fbaee2ae81aae0f69ffa68e429893688ed064 (diff)
downloadwebtrees-8f9b0fb289eccd0c5057286c6cfe4391622acc59.tar.gz
webtrees-8f9b0fb289eccd0c5057286c6cfe4391622acc59.tar.bz2
webtrees-8f9b0fb289eccd0c5057286c6cfe4391622acc59.zip
Tests
Diffstat (limited to 'app')
-rw-r--r--app/Tree.php22
1 files changed, 11 insertions, 11 deletions
diff --git a/app/Tree.php b/app/Tree.php
index a69955918d..d6026e9d47 100644
--- a/app/Tree.php
+++ b/app/Tree.php
@@ -896,27 +896,27 @@ class Tree
*/
public function significantIndividual(User $user): Individual
{
- static $individual; // Only query the DB once.
+ $individual = null;
- if (!$individual && $this->getUserPreference($user, 'rootid') !== '') {
+ if ($this->getUserPreference($user, 'rootid') !== '') {
$individual = Individual::getInstance($this->getUserPreference($user, 'rootid'), $this);
}
- if (!$individual && $this->getUserPreference($user, 'gedcomid') !== '') {
+
+ if ($individual === null && $this->getUserPreference($user, 'gedcomid') !== '') {
$individual = Individual::getInstance($this->getUserPreference($user, 'gedcomid'), $this);
}
- if (!$individual) {
+
+ if ($individual === null) {
$individual = Individual::getInstance($this->getPreference('PEDIGREE_ROOT_ID'), $this);
}
- if (!$individual) {
- $xref = (string) Database::prepare(
- "SELECT MIN(i_id) FROM `##individuals` WHERE i_file = :tree_id"
- )->execute([
- 'tree_id' => $this->id(),
- ])->fetchOne();
+ if ($individual === null) {
+ $xref = (string) DB::table('individuals')
+ ->where('i_file', '=', $this->id())
+ ->min('i_id');
$individual = Individual::getInstance($xref, $this);
}
- if (!$individual) {
+ if ($individual === null) {
// always return a record
$individual = new Individual('I', '0 @I@ INDI', null, $this);
}