MDL-76362 core: Use empty default string when getting prefs
The json_decode function does not accept a null, which is the traditional default for get_user_preferences. By passing a default of am empty string we avoid issues in PHP 8.1.
This commit is contained in:
+2
-3
@@ -573,7 +573,7 @@ class flexible_table {
|
||||
global $SESSION;
|
||||
if (isset($SESSION->flextable[$uniqueid])) {
|
||||
$prefs = $SESSION->flextable[$uniqueid];
|
||||
} else if (!$prefs = json_decode(get_user_preferences('flextable_' . $uniqueid), true)) {
|
||||
} else if (!$prefs = json_decode(get_user_preferences("flextable_{$uniqueid}", ''), true)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -1463,7 +1463,7 @@ class flexible_table {
|
||||
|
||||
// Load any existing user preferences.
|
||||
if ($this->persistent) {
|
||||
$this->prefs = json_decode(get_user_preferences('flextable_' . $this->uniqueid) ?? '', true);
|
||||
$this->prefs = json_decode(get_user_preferences("flextable_{$this->uniqueid}", ''), true);
|
||||
$oldprefs = $this->prefs;
|
||||
} else if (isset($SESSION->flextable[$this->uniqueid])) {
|
||||
$this->prefs = $SESSION->flextable[$this->uniqueid];
|
||||
@@ -2346,4 +2346,3 @@ class table_dataformat_export_format extends table_default_export_format_parent
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user