Skip to content

Commit

Permalink
secure broken dc ref fields against copy and sort calls (#8600)
Browse files Browse the repository at this point in the history
  • Loading branch information
iszmais authored Dec 3, 2024
1 parent 1f63785 commit 5af5d52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public function getRecordQuerySortObject(
global $DIC;
$ilDB = $DIC['ilDB'];

if ($this->hasProperty(self::PROP_N_REFERENCE)) {
if (
$this->hasProperty(self::PROP_N_REFERENCE) ||
$this->getProperty(self::PROP_REFERENCE) === null ||
ilDclCache::getFieldCache($this->getProperty(self::PROP_REFERENCE))->getTableId() === 0
) {
return null;
}

Expand Down
3 changes: 3 additions & 0 deletions Modules/DataCollection/classes/Table/class.ilDclTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,9 @@ public function cloneStructure(ilDclTable $original): void
if (!$orig_field->isStandardField()) {
$class_name = get_class($orig_field);
$new_field = new $class_name();
if ($new_field instanceof ilDclReferenceFieldModel && $new_field->getFieldRef()->getTableId() === 0) {
continue;
}
$new_field->setTableId($this->getId());
$new_field->cloneStructure((int) $orig_field->getId());
$new_fields[$orig_field->getId()] = $new_field;
Expand Down

0 comments on commit 5af5d52

Please sign in to comment.