Glich when admin session times out

Glich when admin session times out

by k l -
Number of replies: 12

First off, very nice theme, thank you!

When I'm logged in as admin and my session times out I get this error when I click on the admin link:

JSON.parse: unexpected character at line 1 column 1 of the JSON data

This happens consistently, I'll start checking other links after the timeout to see if it's only admin links or all links. I'll post what I find out here.

KYLE

(Edited by Gareth J Barnard - original submission Saturday, 6 December 2014, 2:57 AM) - Split from: https://moodle.org/mod/forum/discuss.php?d=276307 as totally different topic.

Average of ratings: -
In reply to k l

It's just the one link

by k l -

I dropped my session timeout to 5 minutes and did some testing, this only seems to happen with the Site administration link and only when it hasn't been expanded before the session times out. I thought I should check Shoehorn while I was at it and it appears to have the same issue.

This is in a fresh install of the latest moodle, almost everything is still set to the defaults, I was just starting to add themes when I noticed this.

In reply to k l

Re: It's just the one link

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi Kyle,


Ok.  This has nothing to do with Shoelace or Shoehorn or indeed Essential or even every single theme ever conceived for Moodle.

When you click on the admin link it sends an AJAX request to the server to retrieve the contents of the menu to be rendered.  The reply is sent in JSON format.  However, when the session times out an error message is returned in plain text.  This causes the client side JSON parser to fall over because it does not understand it.  The message only appears to admins and is silently handled for all other users (I think).  Ages ago I had the same issue with the set user preference code for Collapsed Topics and chatted to Tim Hunt about it and came to the conclusion at the time that nothing can be done.

So in effect there is an ongoing core issue that has not been resolved.  I don't know if there is one - you would need to look.  Ok, as we all improve over time, I now believe there should be a solution after having used '$post' in jQuery (http://api.jquery.com/jquery.post/) on another project.  What should happen is the session time out error functionality at the server needs to set the 'error' properties required to cause the client side 'error' function to operate and display a suitable error message.

Gareth

In reply to Gareth J Barnard

Re: It's just the one link

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Does that mean you are going to attempt to fix that core JSON error?

Yeah! Get git bashing...

In reply to Gareth J Barnard

I see...

by k l -

I have noticed that moodle falls on it's face a lot where error messages are concerned, so, no big surprise there.

I used jquery post to fix a problem with event handlers on a project I was working on this summer. You can check if the error is json formatted with something like:

$( document ).ajaxError(function() {
try{
   jQuery.parseJSON( error msg )
//this is valid JSON pass it on
}
catch(e){
//not JSON create the JSON error msg here   
 }
});
That's off the top of my head but you get the point...

I've been coding in one language or another for about 30 years, I suppose I should look into the dev situation here.

In reply to k l

So much for that...

by k l -

Seems you have to provide them with a history of tracker updates on another project before they'll even start to talk to you about coding, I have too many hoops to jump through already for paying customers, I'll stick to fixing my own copy.


Thanks again for the themes, they are quite nice smile

In reply to k l

Re: So much for that...

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Kyle,

You could contact HQ and ask for access using the quality of the fix as evidence.

Gareth

In reply to Gareth J Barnard

Re: So much for that...

by k l -

Well, to make a short story long, I have a friend in charge of online education at a 90 school for profit education group, teaching college/grad students. They had a custom solution being developed for them that would roll out in mid Jan. The corp the developers were part of got taken over by outsiders who shut down their IT/DEV group last month. Now he's only got the moodle install they were using for a small group of courses, no moodle staff, and no budget for moodle staff until 3rd quarter of next year because they spent 7 figures on development over the last year. So I am doing this on my own time and dime to help him out while he gets it up to speed to handle the entire online course load. And I still need to do work on my own client's projects if I want to eat and live indoors.

Sooo, I've got no time for being part of the full time dev cycle here, or creating/finding/joining/managing the "appropriate" git project to post code, request reviews, etc., and I won't have the luxury of waiting for code changes to be approved and fully tested by moodle and then slowly bubble up through consecutive releases. If I have to fix something in the core, or anywhere really, I'll code it, test on the server, and if it seems sound, I'll implement it and just keep to myself ;)

That way I can fix useless error messages like this one that has popped up 3 times in the last 2 days while clicking around here, without waiting on the dev bureaucracy or posting to and managing git repositories.

"Coding error detected, it must be fixed by a programmer: No further information available for this branch"

That's an error that should go straight to a log with some useful data attached, not shown to an end user with no way of acting on it or reporting it. The pages it came up on didn't even have a contact link. They need to review the ui standards and error handling for this project in a big, big way, and I certainly don't have time to lobby for that either.

After spending 2 full weeks reading everything I can about moodle and it's use, I've come to the conclusion that's it become so large and overly dogmatic and controlling over recent years, it's stifling it's own growth, creativity and usefulness. Like wanting people to read and comprehend a 10 page long statement of "Moodle's social constructionist pedagogy" before learning how to contribute, so they can stay in keeping with it. Really? I'm a programmer, not a philosopher or sociology professor. The fact that one even exists says something, let alone that they're pointing programmers to it as a guideline. Enough of my whining though, thanks for the themes and input, I really do appreciate you taking the time, I wish you the best of luck smile

Average of ratings: Useful (4)
In reply to k l

Re: Glich when admin session times out

by Sam Villamizar -

Kyle,

I have encountered the same glitch when trying to restore large courses (>400MB) into Moodle.  We are currently using Moodle 2.6 on a PostgreSQL database.

I believe the issue is happening due to some setting that the PostgreSQL database does not recognize or like; if I  restore the same backup file in a Moodle 2.6 install with a MySQL database it restores perfectly without any issues.

So far I have not found a solution to the issue, I will post if I do.

Have a blessed afternoon.

Sam Villamizar

In reply to Sam Villamizar

Re: Glich when admin session times out

by Dominik Wujastyk -
I'm getting this "JSON.parse: unexpected character at line 1 column 1 of the JSON data" message when trying to move a course from one moodle installation to another, using "backup" and "restore."  Dateline January 2016.  Really? 

Moodle version 3.0.1 (build 20151221 [$version =2015111601.00])
In reply to Dominik Wujastyk

Re: Glich when admin session times out

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

This is not a theme issue. Please can you post with appropriate details in the General Help forum.

I would move the post, but I don't think it gives sufficient detail to stand on its own in the relevant forum.