MDL-34182: Add functions to warn of output in AJAX scripts

We need to be able to capture output when including contributed code as it
may add additional content which makes makes the json we output invalid.

We only warn of these errors if the site is in debugdeveloper, otherwise
we silently drop them.
MDL-34182 Repositories: Check for and warn on invalid output in the file picker
Merge branch 'MDL-34182-24' of git://github.com/andrewnicols/moodle into MOODLE_24_STABLE