by Chris Megahan.
Line 66 is getting the course from the database. And error on that line seems to indicate that the course doesn't exist. Perhaps these links to files were copy pasted from a course which no longer exists? I can't imagine why this would be sporadic though. Have you had any other database issues?
https://github.com/moodle/moodle/blob/MOODLE_25_STABLE/file.php#L66