Internal Server Error only on Admin Side

Hey, I tried searching through the sea of error messages on here, but nothing quite fits my particular issue.
After adding some javascript (a SurveyMonkey widget) through the UI on the website settings tab in one of the text boxes I can no longer access anything admin based - I just get a blank page and a server 500 error. I don’t have a backup of the database before this was added so I can’t do a restore.

Here’s the URL:

Any help would be greatly appreciated.


Check your server’s error log for the exact details of the 500 error:

Do you remember (or can you otherwise identify) exactly where you entered the javascript code?

I’m getting this:
[Tue May 23 14:55:29.914819 2017] [:error] [pid 3678] [client] PHP Fatal error: Smarty error: [in core:common/headerHead.tpl line 20]: syntax error: unrecognized tag: h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments) (Smarty_Compiler.class.php, line 446) in /var/www/html/lib/pkp/lib/vendor/smarty/smarty/libs/Smarty.class.php on line 1094, referer:

Can’t see where there’s a syntax error though.

I can’t remember which field exactly, it may have been one of the “about” ones. The javascript worked fine when it was added to any of the static pages though.

There are multiple headHead.tpl files - found the right one with the error in it - job done!

Thanks for your help!

As distributed, the headerHead template doesn’t contain 20 lines, so I’m going to assume this is the referring to the cached version of the file.

I suspect this was in one of the cache/t_compile/*headerHead.tpl files?

Now that you have access again, can you describe more about what you tried so that we can ensure this doesn’t trip up others?

It was here: lib/pkp/templates/common/headerHead.tpl - I was looking at the version in my theme.

Odd though, as the code I removed had been there for a while and the site worked fine - that code was for analytics via HotJar - it never worked on the website, but it didn’t break the site either. I must have forgotten to remove it. The site stopped working however when I added javascript in one of the fields in the “information” tab under website settings via the UI. That code was nowhere to be found when I went back in after getting everything working again though.

Hi @mickbale,

Something probably triggered a recompile of your templates that surfaced a syntax error in the modified template file. The most likely cause of this is inclusion of e.g. Javascript code in a Smarty template without escaping – Smarty uses { and } characters for its own syntax, and since Javascript also often uses these, it’s common to have to escape them e.g. using Smarty’s {literal} tag before they’ll work.

Alec Smecher
Public Knowledge Project Team

Oh right, I didn’t know that, I haven’t used Smarty before - thanks for your help!