Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table not found when using 'USING' (courses/delete_dangling_course_contexts) #97

Open
Kevin-Hipwell opened this issue Jan 16, 2020 · 1 comment
Labels

Comments

@Kevin-Hipwell
Copy link

I have tested this plugin in Moodle3.8
There seems to be an issue in the Courses/delete_dangling_course_contexts function.

ERROR

Default exception handler: Error writing to database Debug: Unknown table 'mdl_context' in MULTI DELETE
DELETE FROM mdl_context USING mdl_course
WHERE contextlevel = 50
AND mdl_context.instanceid = mdl_course.id
AND mdl_course.id IS NULL

The Error is produced with the execution of the following statement

$DB->execute("DELETE FROM {context} USING {course}
WHERE contextlevel = 50
AND {context}.instanceid = {course}.id
AND {course}.id IS NULL");

This is the correcting statement I used to successfully remove the dangling course context.

$DB->execute("DELETE {context} FROM {context} 
LEFT JOIN {course} 
ON {context}.instanceid = {course}.id 
WHERE {course}.id IS NULL 
AND {context}.contextlevel = 50");
@brendanheywood
Copy link
Contributor

thanks @Kevin-Hipwell can you please submit a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants