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

fix: serialize arrays to persist them #31841

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -10135,6 +10135,12 @@ protected function setSaveQuery()
$queryarray[$field] = null;
}
}
} elseif ($this->isArray($info)) {
if (isset($this->{$field}) && !empty($this->{$field})) {
$queryarray[$field] = serialize($this->{$field});
} else {
$queryarray[$field] = null;
}
} else {
// Note: If $this->{$field} is not defined, it means there is a bug into definition of ->fields or a missing declaration of property
// We should keep the warning generated by this because it is a bug somewhere else in code, not here.
Expand Down Expand Up @@ -10201,6 +10207,12 @@ public function setVarsFromFetchObj(&$obj)
$this->$field = null;
}
}
} elseif ($this->isArray($info)) {
if (isset($obj->$field) && !empty($obj->$field)) {
$this->$field = unserialize($obj->$field);
} else {
$this->$field = array();
}
} else {
$this->$field = isset($obj->$field) ? $obj->$field : null;
}
Expand Down
Loading