oliviervalentin / moodle-mod_stickynotes

Sticky Notes is a Moodle activity for creating an interactive post-it wall. Students can create, move and vote for notes, under supervision of teacher which can define colors, lock fucntionnalities...
Other
4 stars 6 forks source link

Undefined variable $data referenced when locking #31

Closed djarran closed 6 months ago

djarran commented 6 months ago

When locking, the following error is received:

 Warning: Trying to access array offset on value of type null in /var/www/site/mod/rstickynotes/note.php on line 101

This is due to a type cast to an object of the $data variable which was not yet previously initialised:

 /**
  * Updates locks parameters.
  * @param object $data  Datas from the form
  * @return post The id of the activity.
  */
  function update_lock($instance, $lock, $lockvalue) {
    global $DB;
    $data = (object)$data;
    $data->id = $instance;
    $data->$lock = $lockvalue;

    $res = $DB->update_record('stickynotes', $data);

    return true;
  }
oliviervalentin commented 6 months ago

Dear Djarran, ok fixed. $data should be declared as a new StdClass. I'll soon fix it. Best regards, Olivier