lsuits / lsu-block_quickmail

*Louisiana State University ITS no longer maintains this Project.* A Moodle block that provides selective, bulk emailing within courses
45 stars 68 forks source link

Block render error on 3.5 #250

Closed haietza closed 6 years ago

haietza commented 6 years ago

We backed up a course on Moodle 3.4 and restored it on 3.5, and when trying to render the block contents, we get the following error:

Did you remember to make the first column something unique in your call to get_records? Duplicate value 'roleselection' found in column 'name'. line 1254 of /lib/dml/mysqli_native_moodle_database.php: call to debugging() line 1400 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql() line 1351 of /lib/dml/moodle_database.php: call to moodle_database->get_records_select() line 1440 of /lib/dml/moodle_database.php: call to moodle_database->get_records() line 213 of /blocks/quickmail/lib.php: call to moodle_database->get_records_menu() line 64 of /blocks/quickmail/block_quickmail.php: call to quickmail::load_config() line 709 of /blocks/moodleblock.class.php: call to block_quickmail->get_content() line 230 of /blocks/moodleblock.class.php: call to block_list->formatted_contents() line 1211 of /lib/blocklib.php: call to block_base->get_content_for_output() line 1263 of /lib/blocklib.php: call to block_manager->create_block_contents() line 374 of /lib/blocklib.php: call to block_manager->ensure_content_created() line 3924 of /lib/outputrenderers.php: call to block_manager->region_has_content() line 41 of /theme/asu/layout/columns2.php: call to core_renderer->blocks() line 1273 of /lib/outputrenderers.php: call to include() line 1203 of /lib/outputrenderers.php: call to core_renderer->render_page_layout() line 244 of /course/view.php: call to core_renderer->header()

There are multiple entries for roleselection for a single coursesid in the mdl_block_quickmail_config table (name is not a unique column for the table).

We are running v 1.7.6 of block_quickmail. Please advise - thank you!

chadmazilly commented 6 years ago

I'll try duplicating the error myself and will get back to you on this, thanks!

chadmazilly commented 6 years ago

@haietza I think we have found the issue. To fix, try going to the Quickmail configuration page for that course and hit "save". This will consolidate those two rows into one (based on whatever roles you've selected before saving). I think what caused this was you restoring into a course that already had course Quickmail configuration records. Let me know!

haietza commented 6 years ago

@chadmazilly That fixed it! Thank you so much for the quick response and solution!

chadmazilly commented 6 years ago

Excellent! This does bring up an issue that I think could be improved. When you restored that course on top of existing data, Quickmail should have wiped any of that course config data. It does not do this currently, but apparently this does not happen this often. I'll make note of this and fix in the future.