MDL-36690 Do not cache objects inside course.modinfo as they may fail to serialize
convert moodle_url (all other fields are numbers or strings) to string before caching and then back to moodle_url when restoring. Otherwise serialized modinfo can contain \0 byte which cause problems in Postgres DB
This commit is contained in:
+3
-1
@@ -958,7 +958,9 @@ function get_array_of_activities($courseid) {
|
||||
$mod[$seq]->extraclasses = $info->extraclasses;
|
||||
}
|
||||
if (!empty($info->iconurl)) {
|
||||
$mod[$seq]->iconurl = $info->iconurl;
|
||||
// Convert URL to string as it's easier to store. Also serialized object contains \0 byte and can not be written to Postgres DB.
|
||||
$url = new moodle_url($info->iconurl);
|
||||
$mod[$seq]->iconurl = $url->out(false);
|
||||
}
|
||||
if (!empty($info->onclick)) {
|
||||
$mod[$seq]->onclick = $info->onclick;
|
||||
|
||||
+2
-1
@@ -1099,7 +1099,8 @@ class cm_info extends stdClass {
|
||||
$this->indent = isset($mod->indent) ? $mod->indent : 0;
|
||||
$this->extra = isset($mod->extra) ? $mod->extra : '';
|
||||
$this->extraclasses = isset($mod->extraclasses) ? $mod->extraclasses : '';
|
||||
$this->iconurl = isset($mod->iconurl) ? $mod->iconurl : '';
|
||||
// iconurl may be stored as either string or instance of moodle_url.
|
||||
$this->iconurl = isset($mod->iconurl) ? new moodle_url($mod->iconurl) : '';
|
||||
$this->onclick = isset($mod->onclick) ? $mod->onclick : '';
|
||||
$this->content = isset($mod->content) ? $mod->content : '';
|
||||
$this->icon = isset($mod->icon) ? $mod->icon : '';
|
||||
|
||||
Reference in New Issue
Block a user