Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Upgrading SilverStripe

Ask questions about upgrading SilverStripe to the latest version.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Issues With SilverStripe 3

Go to End

12 Posts   1947 Views


19 June 2012 at 7:16am (Last edited: 27 June 2012 6:58am), Community Member, 470 Posts

1. Fixed this issue. 2nd issue below still happens on some installs.

2. This issue just started with RC1. It never appeared when I was using beta versions of 3. I can't load any admin link with ajax. Throws an error and just hangs. I have to do a hard refresh for the page to load.

Screenshot of error message:



25 June 2012 at 6:27pm (Last edited: 25 June 2012 6:29pm), Community Member, 8 Posts

I was having the same symptoms as #2 with both RC1 and RC2 (though I never saw the error you posted). I narrowed it down to the fact that since the RC, CMS Ajax calls return JSON rather than plain HTML.

Something was causing "\r\n" to be output before the JSON code but after the Content-Length is already calculated, and this meant that the last two characters of the JSON output were truncated (the important "} ) meaning that the eval() fails and the .success callback was never executed.

Over around four hours I narrowed it down to coming from /cms/code/controllers/CMSMain.php, generatePageIconsCss() (of all places), in the $obj = singleton($class) line (around line 412). This loops through all the classes available, and through some trial and error I found that one of my classes in /mysite/code had a blank line before the opening <?php tag.

Note that this wasn't an issue in the beta -- it only showed up in RC -- so you may have one of these stray lines that you didn' t know about. I'd recommend using Firebug to check the result of the CMS's XHRs and see if there's a blank line before the JSON output.

Perhaps Core::singleton() (or one of the methods it uses to get the class) could be tweaked to make it a little more foolproof?


27 June 2012 at 6:57am Community Member, 470 Posts

I've figured out my first issue. It was code in a custom page class.

Is there a ticket open for the 2nd issue you found?

On a fresh install of rc2 I had no issues even with all my custom page types, but that's all I uploaded. No template stuff or any other files.

On my old install of rc2 I'm still getting the 2nd error with the admin pages not loading with ajax. None of my classes in mysite/code have an empty space before the opening php tag. I'll have to do some more narrowing down to see what is causing it.


27 June 2012 at 12:35pm Community Member, 8 Posts

I didn't submit a ticket for this one because it was actually an issue with out code (though in a perfect world Silverstripe would correct something like this).

Have you tried monitoring the CMS Ajax calls I'm Firebug? You could check the result in a parser like to make sure it is valid.


28 June 2012 at 6:52am Community Member, 470 Posts

I opened a ticket for it as I think it needs to be addressed.

If you want to add any comments in it, that would help. I'm a designer, not a developer so you'd be of more use.

I'm going to copy and paste your detailed response in there.

I use Chrome and used their XHR tab in the debugger and can't find much. I'll do more tonight and see.


28 June 2012 at 12:20pm (Last edited: 28 June 2012 12:20pm), Community Member, 8 Posts

Are you able to test this in Firefox? Then we can tell if our issues are similar, and then if so I can post on the ticket.

Firefox -> Firebug -> monitor the XHR request in there -> Copy/paste the result to -> Check validity of the code.

In my case the last few characters were being truncated, causing the JSON to be invalid.


28 June 2012 at 12:38pm Community Member, 470 Posts

Okay I checked in FireBug and right clicked, copy content as json and ran the script in the site you linked and got 1 error.

I have the output here to confirm I did this right as I'm not sure.


28 June 2012 at 1:05pm Community Member, 8 Posts

Pretty much -- I've attached my output so you can see what I mean.

In my case there was an extra line before {"Content", and the output ended with </div> when it should have been </div"} to be valid JSON.

In my attached picture you can see there is a JSON tab in the response -- this only shows up if the response is valid JSON. If you're having the issue I did then you'll only get Headers and Response tabs.

Hope that helps!

Attached Files
Go to Top