Skip to content

Commit 9c2f4f1

Browse files
jasonvargaclaude
andcommitted
Fix redundant Fieldset::find() and null dereference in Tab
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3bc0da4 commit 9c2f4f1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Fields/Tab.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ private function expandedSections(): array
110110
$bufferedFields = [];
111111

112112
foreach ($fields as $field) {
113-
if (! $this->isSectionedFieldsetImport($field)) {
113+
$importedFieldset = $this->sectionedFieldsetImport($field);
114+
115+
if (! $importedFieldset) {
114116
$bufferedFields[] = $field;
115117

116118
continue;
@@ -121,9 +123,7 @@ private function expandedSections(): array
121123
$bufferedFields = [];
122124
}
123125

124-
$importedSections = FieldsetRepository::find($field['import'])->sections();
125-
126-
foreach ($importedSections as $importedSection) {
126+
foreach ($importedFieldset->sections() as $importedSection) {
127127
$carry->push($this->toImportedPublishSection($importedSection, $field));
128128
}
129129
}
@@ -136,19 +136,19 @@ private function expandedSections(): array
136136
}, collect())->all();
137137
}
138138

139-
private function isSectionedFieldsetImport(array $field): bool
139+
private function sectionedFieldsetImport(array $field): ?Fieldset
140140
{
141141
if (! isset($field['import'])) {
142-
return false;
142+
return null;
143143
}
144144

145145
if (($field['section_behavior'] ?? 'preserve') === 'flatten') {
146-
return false;
146+
return null;
147147
}
148148

149149
$fieldset = FieldsetRepository::find($field['import']);
150150

151-
return $fieldset && $fieldset->hasSections();
151+
return $fieldset && $fieldset->hasSections() ? $fieldset : null;
152152
}
153153

154154
private function toImportedPublishSection(array $section, array $import): array

0 commit comments

Comments
 (0)