1

We just migrated a moodle site and for the most part everything is working well except the admin link site administration. Once it is clicked, it will go on spinning for 3 minutes until it timeouts with a 500 error and an error message Unexpected token < in JSON at position 0. Here is the console output:

moodle/lib/ajax/getsiteadminbranch.php 500 (Internal Server Error)

I disabled JS to get debug turned on but wasn't able to replicate the bug until I logged out and logged back in (JS turned on).

Replicating the steps above, I got a more verbose console log

Chrome JS console with verbose moodle js notifications

It seems to get hung up on

moodle-block_navigation: Loading navigation branch via AJAX: siteadministration

Here is the stack trace:

SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse >()
at Object.Y.namespace.parse (https://foo-bar.io/moodle/theme/yui_combo.php?rollup/3.13.0/yui-moodlesimple.js:37340:18)
at BRANCH.ajaxProcessResponse (https://foo-bar.io/moodle/theme/yui_combo.php?m/1477092989/block_navigation/navigation/navigation-debug.js:653:33)
at Y.Subscriber._notify (https://foo-bar.io/moodle/theme/yui_combo.php?rollup/3.13.0/yui-moodlesimple.js:26572:35)
at Y.Subscriber.notify (https://foo-bar.io/moodle/theme/yui_combo.php?rollup/3.13.0/yui-moodlesimple.js:26601:24)
at Y.CustomEvent._notify (https://foo-bar.io/moodle/theme/yui_combo.php?rollup/3.13.0/yui-moodlesimple.js:26264:17)
at Y.CustomEvent._procSubs (https://foo-bar.io/moodle/theme/yui_combo.php?rollup/3.13.0/yui-moodlesimple.js:26390:36)
at Y.CustomEvent.fireSimple (https://foo-bar.io/moodle/theme/yui_combo.php?rollup/3.13.0/yui-moodlesimple.js:26357:18)
at Y.CustomEvent._fire (https://foo-bar.io/moodle/theme/yui_combo.php?rollup/3.13.0/yui-moodlesimple.js:26339:29)
at IO.fire (https://foo-bar.io/moodle/theme/yui_combo.php?rollup/3.13.0/yui-moodlesimple.js:27492:22)

The code worked on the old environment but obviously I am still missing something in the new one. Any assistance would be appreciated.

8
  • Just a guess, but your web site is returning HTML. Perhaps an error message wrapped in HTML. In future, you might want to actually copy and paste the error message - not an image of it. Images of text have little value. Commented Nov 3, 2016 at 3:34
  • Your error message most likely means that a Javascript function is unable to parse the response of the AJAX call to moodle/lib/ajax/getsiteadminbranch.php because that script has failed. Commented Nov 3, 2016 at 7:40
  • To see the real error you will probably have to consult your server error log. That may be /var/log/httpd/error.log but will depend on what web server (eg Apache) and operating system you are running. Commented Nov 3, 2016 at 7:42
  • You should try the following and paste the response here: 1. Turn debugging on (if not done already). 2. Monitor this network request. 3. Check the response sent for this ajax request. That might give you more details on what actually happened on Moodle's end when that request for being made. If you can;t figure out what is wrong then you can post the response here. Commented Nov 6, 2016 at 1:22
  • @SandeepGill how do you monitor the network response?
    – powpow12
    Commented Jan 25, 2017 at 12:48

1 Answer 1

0

I`ve solved the issue by uncommenting in my php.ini: always_populate_raw_post_data = -1

Source: http://php.net/always-populate-raw-post-data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.