-
Bug
-
Resolution: Fixed
-
Minor
-
3.6.5, 3.7.1, 3.8, 3.8.2, 3.9
-
MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
-
MOODLE_38_STABLE
-
Doing some preliminary tests with php74, there are some warnings leading to phpunit failures like this:
mod_quiz_attempt_walkthrough_from_csv_testcase::test_walkthrough_from_csv with data set #0 (array('00', 'deferredfeedback'), array(PHPUnit\DbUnit\DataSet\DefaultTable Object (...), PHPUnit\DbUnit\DataSet\DefaultTable Object (...), PHPUnit\DbUnit\DataSet\DefaultTable Object (...)))
|
Creating default object from empty value
|
|
/var/www/html/question/type/multianswer/questiontype.php:67
|
/var/www/html/lib/questionlib.php:939
|
/var/www/html/lib/questionlib.php:1008
|
/var/www/html/mod/quiz/attemptlib.php:164
|
/var/www/html/mod/quiz/locallib.php:169
|
/var/www/html/mod/quiz/tests/attempt_walkthrough_from_csv_test.php:271
|
/var/www/html/mod/quiz/tests/attempt_walkthrough_from_csv_test.php:152
|
/var/www/html/mod/quiz/tests/attempt_walkthrough_from_csv_test.php:69
|
/var/www/html/lib/phpunit/classes/advanced_testcase.php:80
|
php74 is more picky about situations like that (and that's a good thing, I think).
So, looking over all qtypes... I've observed that a number of them, having the get_question_options() method do use to call to parent one (that is in charge of initialising the question->options object:
$ ag 'on get_question_options\(' -l | xargs ag 'parent::get_question_options' -l
|
randomsamatch/questiontype.php
|
gapselect/questiontypebase.php
|
numerical/questiontype.php
|
match/questiontype.php
|
ddimageortext/questiontypebase.php
|
multichoice/questiontype.php
|
essay/questiontype.php
|
But other qtypes aren't calling parent ever (like multianswer above in the failure):
$ ag 'on get_question_options\(' -l | xargs ag 'parent::get_question_options' -L
|
multianswer/questiontype.php
|
truefalse/questiontype.php
|
calculated/questiontype.php
|
random/questiontype.php
|
questiontypebase.php
|
So, this is about to decide one of:
1) Each qtype is responsible of initialising options its own 100%.
2) Each qtype should be always calling to parent, apart from any other own and particular init needed.
In any of the cases the outcome is clear, to have everything available before trying to access to it or php74 will cry (well done).
(for some reason, ensuring that parent is always called, aka 2, sounds better here, but I don't know the internals enough)
Ciao
PS: Feel free to consider this an improvement, i've initially classified it as bug.