brendanheywood / moodle-local_cleanurls

Lets drag Moodle's url structure into this century...
36 stars 24 forks source link

Problem with course format "single activity" #118

Open Flottertotte opened 6 years ago

Flottertotte commented 6 years ago

Thank you for the great plugin!

I run into a small problem: I have a course with single activity course format. If I use a direct link to this activity (such as: /mod/activityxy/view.php?id=123), the activity gets displayed and the url cleaned (eg.: /course/i+am+clean/). So that works fine.

But when I now hit the reload button in my browser (or use a link to the cleaned url directly), an error message appears:

Multiple records found, only one record expected. More information about this error

Debug info: Debug info: SELECT id,module FROM {course_modules} WHERE course = ? [array ( 0 => '71',)] Error code: multiplerecordsfound Stack trace:

line 1568 of /lib/dml/moodle_database.php: dml_multiple_records_exception thrown
line 1530 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
line 1509 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
line 70 of /local/cleanurls/classes/local/courseformat/singleactivity.php: call to moodle_database->get_record()
line 70 of /local/cleanurls/classes/local/uncleaner/uncleaner.php: call to local_cleanurls\local\courseformat\singleactivity->get_unclean_url()
line 50 of /local/cleanurls/classes/local/uncleaner/uncleaner.php: call to local_cleanurls\local\uncleaner\uncleaner::perform_uncleaning()
line 43 of /local/cleanurls/router.php: call to local_cleanurls\local\uncleaner\uncleaner::unclean()

I use moodle 3.3

Any help is very welcomed.

Flotter

Flottertotte commented 6 years ago

Hello, a quick update on above issue. It seems the root cause it not the single activity, but the activity which we added (facetoface module). Any hint very welcome! Flotter

brendanheywood commented 6 years ago

Hmm, that looks like a bug in this plugin that would apply to any activity in a singleactivty format. You can probably semi dodgy work-around the issue by just adding a "limit 1" around here

https://github.com/brendanheywood/moodle-local_cleanurls/blob/master/classes/local/courseformat/singleactivity.php#L70

But we'd have to dig in deeper to find out why that course has more than one activity despite being a 'singleactivity'. That might be normal, eg a hidden forum or something so we just have to deal with it gracefully. Are you in a position to sponsor improvements?