MDL-67114 core: php74 fix. Fix use of scalar as array in core
There are various places where it's not guaranteed that the variable being used is array, and instead, can be null, bool, int... We need to check that because php74 warns about it. Where possible we have used the coalesce operator as replacement for isset() ternary operations.
This commit is contained in:
@@ -701,7 +701,7 @@ class question_usage_by_activity {
|
||||
// Behaviour vars should not be processed by question type, just add prefix.
|
||||
$behaviourvars = $this->get_question_attempt($slot)->get_behaviour()->get_expected_data();
|
||||
foreach (array_keys($responsedata) as $responsedatakey) {
|
||||
if ($responsedatakey[0] === '-') {
|
||||
if (is_string($responsedatakey) && $responsedatakey[0] === '-') {
|
||||
$behaviourvarname = substr($responsedatakey, 1);
|
||||
if (isset($behaviourvars[$behaviourvarname])) {
|
||||
// Expected behaviour var found.
|
||||
|
||||
Reference in New Issue
Block a user