Missing dashboard css and the perils of smart quotes

This is the tale of a mystery and intrigue about the disappearance of the css from a blogs dashboard and how we hunted it down and fetched it back.

Thord Daniel Hedengren, one of the writers for Blog Herald, put out a plea for help on twitter and was pointed in my direction.

He was faced with a WordPress dashboard which looked like this and wasn’t much use:

WordPress 2.8.4 dashboard without all the styling

WordPress 2.8.4 dashboard without all the styling

This evening I hooked up with Thord and with the help of his server administrator we tracked down the issue and thought it a good idea to spread the message to help any one else out there who has a similar issue in the future.

I started off by looking at the headers returned by the php file which concatenates all the CSS files together and noticed something strange:

HTTP/1.1 200 OK
Server: nginx/0.7.62
Date: Tue, 29 Sep 2009 19:34:47 GMT
Content-Type: text/css;charset=“utf-8″
Connection: keep-alive
X-Powered-By: PHP/5.3.0
Expires: Wed, 29 Sep 2010 19:34:47 GMT
Cache-Control: public, max-age=31536000
Vary: Accept-Encoding

As you can see here the Content-Type header looks a little strange, it has a charset specified but the value being returned is not a valid charset and it looks like this is probably why Firefox is refusing to apply this css file to the page.

This was starting to look like a server configuration issue so we got in contact with the server admin and we tracked down the errant configuration to the php.ini file.

Within the php.ini file you can set a default charset to be used if one has not already been specified for the request this had erroneously been set in the file with some smart quotes rather than normal quotes and so php was outputting the smart quotes as well as the charset name into the HTTP header.

Now the headers look like this and Firefox is happy to display a fully styled WordPress dashboard:


HTTP/1.1 200 OK
Server: nginx/0.7.62
Date: Tue, 29 Sep 2009 19:39:17 GMT
Content-Type: text/css;charset=utf-8
Connection: keep-alive
X-Powered-By: PHP/5.3.0
Expires: Wed, 29 Sep 2010 19:39:17 GMT
Cache-Control: public, max-age=31536000
Vary: Accept-Encoding

In short, check the configuration you use for default_charset in your php.ini file and don’t use any quotes unless you need to the following works fine in my testing:


default_charset = utf-8

7 Responses to “Missing dashboard css and the perils of smart quotes”

  1. […] it works, courtesy of Peter “Westi” Westwood and Jonathan Sulo. Westi details the issue in a blog post, you should check that out if you ever encountered this […]

  2. westi says:

    Note if your seeing this at the moment it could also be a hint towards a hack on your site / server which has added content to the end of every php file.

    This will cause the admin css which is loaded via a php script to be invalid and some browsers will then ignore it.

    If so this link may help you tidy up – http://www.wpsecuritylock.com/cechriecom-com-script-wordpress-hacked-on-godaddy-case-study/

  3. brandon Sean says:

    Hi westi first of all congrats on finding a solution to this problem.

    I’ve been cracking my head finding a solution to this problem, each time my dashboard breaks i would have to reupload my WP includes as suggested in the forum..

    I have a self hosted wp blog on Hostgator but i have no clue how PHP works,

    I would certainly appreciate it if you can just tell me what I have to do? in a little more detail

    I just edit the php.ini file?

    ALso any idea whats causing this? apparently all my blogs are affected. I want to completely get rid of this issue once and for all, im afraid I

    I cant offer you money like the guy who gave you that $100 but i can blog about your service :)

    Thanks in advance Westi

    hope to hear from you soon

  4. brandon Sean says:

    Update- I just read the comment you posted above about the Godaddy recent attck
    my domain is from Godaddy but hosting is at Hostgator Cpanel.

    Do you think im affected?

    I personally think it has nothing to do, though I am not too sure

    • westi says:

      If all your sites are affected its well worth looking for the signature of the hack before looking at php.ini yes

  5. Sterling C says:

    I was having this exact same problem on all of my WP dashboards i had installed on my server…

    Here is how i fixed it for myself: (using Firefox):

    Open dashboard

    Click on Upgrade

    Scroll all the way down to bottom

    Click on Upgrade automatically (Even tho it says you have latest ver.)

    Let it upgrade (scroll down again to bottom to confirm)

    Go to website

    Go back to dashboard and Shift Refresh to reload dashboard

    Worked for me…

  6. Ilya says:

    If you don’t want to change your default_charset value globally or if you don’t have access to your php.ini file, you can set the value in the WordPress .htaccess file “php_value default_charset utf-8″



d
go to dashboard
l
go to login
h
show/hide help
e
edit post/page
r
comment on post/page
m
go to moderate comments
esc
cancel
%d bloggers like this: