Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data objects: saving relations, exclude non-relational fields from condition #16598

Open
wants to merge 2 commits into
base: 11.2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions models/DataObject/Concrete/Dao.php
Expand Up @@ -187,17 +187,19 @@ public function update(bool $isUpdate = null): void
$db = Db::get();

foreach ($fieldDefinitions as $fieldName => $fd) {
if ($fd instanceof LazyLoadingSupportInterface && $fd->getLazyLoading()) {
if (!$this->model->isLazyKeyLoaded($fieldName) || $fd instanceof DataObject\ClassDefinition\Data\ReverseObjectRelation) {
//this is a relation subject to lazy loading - it has not been loaded
$untouchable[] = $fieldName;
if($fd instanceof DataObject\ClassDefinition\Data\Relations\AbstractRelations) {
Copy link
Contributor

@kingjia90 kingjia90 Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please share some insights behind this change?

By following the $untouchable var usages, ended up in this case in URL Slug data type

if (isset($params['isUntouchable']) && $params['isUntouchable']) {
return;
}

Before PR it's true, after PR is always false, not sure if there was something legacy leftover but looks like a potential behavior change

if ($fd->getLazyLoading()) {
if (!$this->model->isLazyKeyLoaded($fieldName) || $fd instanceof DataObject\ClassDefinition\Data\ReverseObjectRelation) {
//this is a relation subject to lazy loading - it has not been loaded
$untouchable[] = $fieldName;
}
}
}

if (!DataObject::isDirtyDetectionDisabled() && $fd->supportsDirtyDetection()) {
if ($this->model instanceof Model\Element\DirtyIndicatorInterface && !$this->model->isFieldDirty($fieldName)) {
if (!in_array($fieldName, $untouchable)) {
$untouchable[] = $fieldName;
if (!DataObject::isDirtyDetectionDisabled() && $fd->supportsDirtyDetection()) {
if ($this->model instanceof Model\Element\DirtyIndicatorInterface && !$this->model->isFieldDirty($fieldName)) {
if (!in_array($fieldName, $untouchable)) {
$untouchable[] = $fieldName;
}
}
}
}
Expand Down