Skip to content

Commit d5385e3

Browse files
authored
Add check if fields exist in versioning (#46009)
1 parent dd3f516 commit d5385e3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

libraries/src/Versioning/VersionableModelTrait.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,14 @@ public function loadHistory($versionId, Table $table)
8080
$table->load($rowArray[$key]);
8181
}
8282

83-
$rowArray['checked_out'] = $this->getCurrentUser()->id;
84-
$rowArray['checked_out_time'] = (new Date())->toSql();
83+
// We set checked_out to the current user
84+
if ($table->hasField('checked_out')) {
85+
$rowArray[$table->getColumnAlias('checked_out')] = $this->getCurrentUser()->id;
86+
}
87+
88+
if ($table->hasField('checked_out_time')) {
89+
$rowArray[$table->getColumnAlias('checked_out_time')] = (new Date())->toSql();
90+
}
8591

8692
// Fix null ordering when restoring history
8793
if (\array_key_exists('ordering', $rowArray) && $rowArray['ordering'] === null) {

0 commit comments

Comments
 (0)