diff --git a/libraries/src/Versioning/VersionableModelTrait.php b/libraries/src/Versioning/VersionableModelTrait.php index 4f8d18470f6e3..7d15df8364120 100644 --- a/libraries/src/Versioning/VersionableModelTrait.php +++ b/libraries/src/Versioning/VersionableModelTrait.php @@ -80,8 +80,14 @@ public function loadHistory($versionId, Table $table) $table->load($rowArray[$key]); } - $rowArray['checked_out'] = $this->getCurrentUser()->id; - $rowArray['checked_out_time'] = (new Date())->toSql(); + // We set checked_out to the current user + if ($table->hasField('checked_out')) { + $rowArray[$table->getColumnAlias('checked_out')] = $this->getCurrentUser()->id; + } + + if ($table->hasField('checked_out_time')) { + $rowArray[$table->getColumnAlias('checked_out_time')] = (new Date())->toSql(); + } // Fix null ordering when restoring history if (\array_key_exists('ordering', $rowArray) && $rowArray['ordering'] === null) {