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

After submitting form_note, $col is not set in note.php #32

Closed djarran closed 6 months ago

djarran commented 6 months ago

After creating a note for a given column and submitting the form, the following error is shown:

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

This is the code on line 101 in note.php:

// Define the page title for creating form.
$settitle = get_column_title($col);
$pagetitle = (get_string('createnote_title', 'stickynotes')).'"'.$settitle['title'].'"';

...

function get_column_title($col) {
    global $DB;
    $record = $DB->get_record('stickynotes_column', array('id' => $col));
    if (!$record) {
        return;
    } else {
        $column['title'] = $record->title;
    }
    return $column;
}

After submitting the form, the $col parameter is empty as it is not passed to the form definition. Consequently, the get_column_title returns a null value, and is attempted to be accessed still.

oliviervalentin commented 6 months ago

Dear Djarran, ok fixed. For this case, I will put a test to check if variable is defined. If yes, that means form is shown. If not, it means form has been posted. I will soon push a new version for the plugin. Thank you once again for reporting all theses bugs ! :) Olivier