Skip to content

Commit 0e2d676

Browse files
Fix GEDCOM import not populating people and family tables
- BelongsToTenant::getTenantId() now uses null-safe ?-> operators so it returns null safely when auth()->user() is null (queue job context). - Global scope now guards with auth()->check() before calling getTenantId() so the Error path is never reached. - ImportGedcom and ImportGrampsXml now pass config('database.default') instead of $job->getConnectionName() (which returned null) to the GedcomParser, avoiding null-to-string coercion deprecations. Co-authored-by: delicatacurtis <247246500+delicatacurtis@users.noreply.github.com>
1 parent f159583 commit 0e2d676

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

app/Jobs/ImportGedcom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function handle(): int
5252
]);
5353
$parser = new GedcomParser();
5454
$team_id = $this->user->currentTeam?->id;
55-
$parser->parse($job->getConnectionName(), $this->filePath, $slug, true, $team_id);
55+
$parser->parse(config('database.default'), $this->filePath, $slug, true, $team_id);
5656
// with(new GedcomParser())->parse($tenant->connectionName(), $this->filePath, $slug, true);
5757

5858
// File::delete($this->filePath);

app/Jobs/ImportGrampsXml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function handle(): int
6666
// Use existing GEDCOM parser
6767
$parser = new GedcomParser();
6868
$team_id = $this->user->currentTeam?->id;
69-
$parser->parse($job->getConnectionName(), $tempGedcomPath, $slug, true, $team_id);
69+
$parser->parse(config('database.default'), $tempGedcomPath, $slug, true, $team_id);
7070

7171
// Clean up temp file
7272
File::delete($tempGedcomPath);

app/Traits/BelongsToTenant.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ protected static function booted(): void
1212
{
1313
static::addGlobalScope('team', function (Builder $query): void {
1414
// Only apply scope when a tenant is available and the model's table has a team_id column
15+
if (! auth()->check()) {
16+
return;
17+
}
1518
$tenantId = static::getTenantId();
16-
if (! auth()->check() || empty($tenantId)) {
19+
if (empty($tenantId)) {
1720
return;
1821
}
1922

@@ -44,6 +47,6 @@ public function team()
4447

4548
private static function getTenantId()
4649
{
47-
return auth()->user()->currentTeam->id ?? null;
50+
return auth()->user()?->currentTeam?->id;
4851
}
4952
}

0 commit comments

Comments
 (0)