Skip to content

Commit 75706ba

Browse files
committed
fix get records
1 parent 39d83b6 commit 75706ba

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

files/lib/system/wsdb/form/option/DatabaseRelationOption.class.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class DatabaseRelationOption extends AbstractFormOption
2222
/**
2323
* @var array<int, array<int, string>>
2424
*/
25-
private array $records;
25+
private array $records = [];
2626

2727
#[\Override]
2828
public function getConfigurationFormFields(): array
@@ -101,7 +101,9 @@ public function unserializeValue(string $value): mixed
101101
*/
102102
private function getRecords(int $databaseID): array
103103
{
104-
if (!isset($this->records)) {
104+
if (!isset($this->records[$databaseID])) {
105+
$this->records[$databaseID] = [];
106+
105107
$recordList = new RecordList();
106108
$recordList->getConditionBuilder()->add('databaseID = ?', [$databaseID]);
107109
$recordList->sqlSelects = "(
@@ -117,16 +119,14 @@ private function getRecords(int $databaseID): array
117119
$recordList->sqlOrderBy = 'title';
118120
$recordList->readObjects();
119121

120-
$records = [];
121122
foreach ($recordList as $record) {
122123
if (!$record->canRead()) {
123124
continue;
124125
}
125-
$records[$record->databaseID][$record->recordID] = $record->getTitle();
126+
$this->records[$record->databaseID][$record->recordID] = $record->getTitle();
126127
}
127-
$this->records = $records;
128128
}
129129

130-
return $this->records[$databaseID] ?? [];
130+
return $this->records[$databaseID];
131131
}
132132
}

0 commit comments

Comments
 (0)