bdaloukas / moodle-mod_game

moodle-mod_game
GNU General Public License v3.0
15 stars 40 forks source link

Missing property initialization for $type->type in "function mod_game_get_course_content_items_type" in lib.php #67

Open NJahreis opened 2 months ago

NJahreis commented 2 months ago

The deletion of the following line https://github.com/bdaloukas/moodle-mod_game/blob/f9e1717c62c05247baac885a50402cf3d98f4ab4/lib.php#L1240 in lib.php by commit bb7ef29 leads to the following PHP warning as the property "type" of the stdClass object is no longer initialized:

Got error 'PHP message: 
PHP Warning:  Undefined property: stdClass::$type in /moodle/apache2/htdocs/mod/game/lib.php on line 1248PHP message:
PHP Warning:  Undefined property: stdClass::$type in /moodle/apache2/htdocs/mod/game/lib.php on line 1248PHP message:
PHP Warning:  Undefined property: stdClass::$type in /moodle/apache2/htdocs/mod/game/lib.php on line 1248PHP message:
PHP Warning:  Undefined property: stdClass::$type in /moodle/apache2/htdocs/mod/game/lib.php on line 1248PHP message:
PHP Warning:  Undefined property: stdClass::$type in /moodle/apache2/htdocs/mod/game/lib.php on line 1248PHP message:
PHP Warning:  Undefined property: stdClass::$type in /moodle/apache2/htdocs/mod/game/lib.php on line 1248PHP message:
PHP Warning:  Undefined property: stdClass::$type in /moodle/apache2/htdocs/mod/game/lib.php on line 1248PHP message:
PHP Warning:  Undefined property: stdClass::$type in /moodle/apache2/htdocs/mod/game/lib.php on line 1248', referer: https://MYMMOODLE.de/course/view.php?id=MYCOURSEID

This propably also has further consequences as the call to 'preg_replace('/.*type=/', '', $type->type);' thus is performed on the undefined property and '$type->name' wont be correctly set. I just noticed the error in my log files and have not looked into the effects this has.

I would assume the deletion of the line was by accident and the issue can be fixed by re introducing the line.