2.7, customscripts, /course/view.php causes stack errors

2.7, customscripts, /course/view.php causes stack errors

by tim st.clair -
Number of replies: 2
Picture of Plugin developers

I have version 2.7.7+ (Build: 20150313)

I have my config set to use customscripts, which I've homed in /local/customscripts/

I have enabled extra developer debugging and am showing it to the page.

If I copy  /course/view.php into /local/customscripts/course/view.php then reload the course page , a large stack trace (http://pastebin.com/JKPxut3j) is output at the bottom. At first I thought this was my theme or blocks with actual unclosed tags (it's not), but then discovered that if I remove /local/customscripts/course/view.php (so it falls back on the default location), no stack trace is displayed.

Why is the behaviour inside customscripts different for the same file?

Average of ratings: -
In reply to tim st.clair

Re: 2.7, customscripts, /course/view.php causes stack errors

by Darko Miletić -

Behavior is different because Moodle hq designed it that way. For any custom script you have to:

Remove require for config.php

End the page execution with die


In reply to Darko Miletić

Re: 2.7, customscripts, /course/view.php causes stack errors

by tim st.clair -
Picture of Plugin developers
aha, oh yes. Die() to prevent execution of the rest of setup.php - including the page it is in fact over-riding. Good spot! Fixed. (config.php is require_once in most moodle files, so there's no need to explicitly remove it other than for the tiniest of performance notches).