MDL-75116 mod_feedback: Check array values exist before using them

Without this, the @list will emit a PHP warning under php8.0+ when the array
doesn't have a second element to assign.
This commit is contained in:
Adam Olley
2022-07-05 09:18:10 +09:30
parent fda6e143af
commit 83e6407074
2 changed files with 16 additions and 4 deletions
+8 -2
View File
@@ -437,14 +437,20 @@ class feedback_item_multichoice extends feedback_item_base {
$info->horizontal = false;
$parts = explode(FEEDBACK_MULTICHOICE_TYPE_SEP, $item->presentation);
@list($info->subtype, $info->presentation) = $parts;
$info->subtype = $parts[0];
if (count($parts) > 1) {
$info->presentation = $parts[1];
}
if (!isset($info->subtype)) {
$info->subtype = 'r';
}
if ($info->subtype != 'd') {
$parts = explode(FEEDBACK_MULTICHOICE_ADJUST_SEP, $info->presentation);
@list($info->presentation, $info->horizontal) = $parts;
$info->presentation = $parts[0];
if (count($parts) > 1) {
$info->horizontal = $parts[1];
}
if (isset($info->horizontal) AND $info->horizontal == 1) {
$info->horizontal = true;
} else {
+8 -2
View File
@@ -377,7 +377,10 @@ class feedback_item_multichoicerated extends feedback_item_base {
$info->horizontal = false;
$parts = explode(FEEDBACK_MULTICHOICERATED_TYPE_SEP, $item->presentation);
@list($info->subtype, $info->presentation) = $parts;
$info->subtype = $parts[0];
if (count($parts) > 1) {
$info->presentation = $parts[1];
}
if (!isset($info->subtype)) {
$info->subtype = 'r';
@@ -385,7 +388,10 @@ class feedback_item_multichoicerated extends feedback_item_base {
if ($info->subtype != 'd') {
$parts = explode(FEEDBACK_MULTICHOICERATED_ADJUST_SEP, $info->presentation);
@list($info->presentation, $info->horizontal) = $parts;
$info->presentation = $parts[0];
if (count($parts) > 1) {
$info->horizontal = $parts[1];
}
if (isset($info->horizontal) AND $info->horizontal == 1) {
$info->horizontal = true;