Hi,
we recently updated our EE install from 2.11.9 to 5.3.0 - server set up stayed the same using Nginx, PHP 5.6.40, MySQL, page charset is set to utf-8.
We’re now verifying the site after the update and we’re noticing that some pages show code fragments from the template in the html rendered in the browser on the front-end, for example: on some pages in our blog we can see text fragments like ‘set}’ appear in the page, which comes from the closing tag ‘</layout:set>’ in the template…
after some investigation we found that certain characters in the CMS content break the template on EE 5.3.0, hence why code fragments appear in the html, for example an elongated hyphen, aka em dash (—), causes this. Once we replace with a standard hyphen the error goes away.
Sine this is the same CMS content as was used on EE 2.11.9 with no issue and same server set up, I wonder what could cause this on 5.3.0 ?
Is there a specific server setting needed for EE 5.3.0 to render these characters correctly without breaking the template ?
Thanks !
update:
enabled PHP in template, output parsing
tried using native PHP escape functions (htmlspecialchars etc) as well as the EE built-in Text Formatter but page breaks with a PHP error if the CMS content contains simple double quotes…..
any help ?
this was a non-issue on EE 2.x with exact same content… very confused
Might be worth switching to PHP7 as that’s now the general minimum for EE5.
For the symptoms you mention I’ve only ever seen that with malformed EE template tags such as incorrect syntax or a wrong mix of ’ and “. Sometimes these are easy to spot but if you can’t it’s worth starting with a simple working template (+ optional layout template) then add bits in until it breaks, that can give you a clue where to find the rogue bit.
Hi Rob,
I’ll update to PHP 7 and report back if it solves the issue.
regarding incorrect syntax and/or wrong mix of ’ and “:
since it’s the exact same template and CMS entries as we were using on EE 2.x, that worked without issue, I cannot see how that would pop up now.
The culprit seems to be the {layout:set} tags, we have two of those in the template (was also used on EE 2.x), the leftover fragments are always from the {layout:set} code block, here’s one example:
{layout:set name="meta"} {exp:seo_lite entry_id="{entry_id}”} {/layout:set}
If I remove both {layout:set} code blocks from the template, everything works, but of course we need them…
I’ll report back after the update to PHP 7…
Thanks !
Yeh mixing ’ and ” was a long shot!
Couple of things to try:
{exp:seo_lite entry_id='{entry_id}'}
{layout:set name="meta"}Test meta value{/layout:set}
…does that output correctly?
Not sure if it’s your cut n paste but the seolite tag uses different apostrophies, the one after {entry_id} looks the wrong type. Try correcting that or use single apostrophes inside the seolite tag.
it was a copy/paste thing, the quotes are correct in the template
What happens if you just add the layout:set tag without the SEOlite tag inside it
without the SEOLite tag inside the layout:set tag, the meta var just outputs correctly (it doesn’t output meta tags, which is what SEOLite does, but it does get the assigned value and outputs it) - with SEOLite in it, the meta tags assigned by SEOLite are correct in the page source, but we have afore mentioned code leftover fragments…
okay, I’ll update to PHP 7 now and update here…
I’m thinking it could be something to do template parse order, at a guess SEOlite is processed after the layout variable, hence why it throws a wobbly. I use normal EE fields for meta data so haven’t come across this with SEOLite (I’ve never used it so don’t have the addon to test with).
Things to try:
parse='inward'
parameter (note use of single apostrophies){layout:set name="meta"}{exp:seo_lite entry_id='{entry_id}' parse='inward'}{/layout:set}
{layout="your/_layout" meta="{exp:seo_lite entry_id='{entry_id}'}"}
Then in your layout template just call {layout:meta}
wherever you want it.
Not sure if this will work, it’s not documented, try with and without the parse parameter:
{exp:seo_lite entry_id="{entry_id}" parse="inward"}
{layout:set name='meta'}{meta_description}{/layout:set}
{/exp:seo_lite}
I tried all three of your suggestions, no luck… also tried PHP 7 (7.0.33 | 7.1.33 | 7.2.26 | 7.3.13), all have same issues, see below
I figured out what causes the issues: it’s the PHP plugin method mbstring.func_overload, which I have set to a value of 6, as per the EE recommendation in the docs
this setting causes the template to break on EE 5.3.0 with PHP 5.6.40 or any PHP 7 version, if the CMS entry contains special characters
if I disable the mbstring.func_overload setting or set it to 0, the template does not break any longer and displays correctly on the front-end, but another nasty bug raises it’s head:
with mbstring disabled, in the EE 5.3.0 CP, if I go to any CMS entry that has special characters, and I simply click SAVE without editing anything - it is supposed to simply save the same CMS entry data that is already in the db - then EE 5.3.0 will wipe/delete the data in the CMS fields that contain special characters… (there is no PHP error or warning)
just to repeat: it will DELETE your data, without asking, confirming or warning.
I’ve confirmed this behavior on all four PHP 7 versions listed above if mbstring.func_overload is disabled…
So besides that last bug, could my issues (of the template breaking on EE 5.3.0) possibly be due to a server misconfiguration ?
I have PHP 7 configured with all required plugins as listed in the EE docs:
MySQL is configured with these params:
Do I need to add or change any of the configurations ?
Thanks !
I’m no programmer but yes it could be something server side.
Your MySQL config looks ok, perhaps check /system/user/config/config.php, in the database array you should have
'char_set' => 'utf8mb4',
'dbcollat' => 'utf8mb4_unicode_ci',
I’m out of ideas, for this, might be worth posting this to the Slack channel or Stack Exchange https://expressionengine.stackexchange.com/ where you’ll have some more expert eyes.
Rob,
thanks for all the help, I’ll post on stackexchange as well.
Re db params in config.php, this is what I currently have:
$config['database'] = array(
'expressionengine' =>
array(
'hostname' => 'ee_host',
'database' => 'ee_db',
'username' => 'ee_user',
'password' => 'ee_pw',
'dbprefix' => 'exp_',
),
);
just to clarify: do the params you mentioned go into the outer ‘database’ array or into the inner ‘expressionengine’ array ?
btw, the db engine used in this db is still MyISAM, since we came from EE 2.x… will convert the tables to InnoDB and see if this fixes things…
Thanks !
On a boilerplate install I have:
$config['database'] = array(
'expressionengine' => array(
'hostname' => 'localhost',
'database' => 'xxxxxx',
'username' => 'xxxxxx',
'password' => 'xxxxxx',
'dbprefix' => 'exp_',
'char_set' => 'utf8mb4',
'dbcollat' => 'utf8mb4_unicode_ci',
'port' => ''
),
);
I can’t reproduce with override 0 or 6. It has to be some sort of interaction going on- encodings not matching up or something.
We are removing the mbstring.func_overload recommendation as it’s deprecated.
Can you drop a note to support@expressionengine.com? If it’s possible for us to take a look, it would be helpful. I know I can’t hit it tomorrow, but hopefully Monday.
agreed, I’m assuming it’s a server misconfig or encoding problem… but on EE 2.11.9 we were using UTF-8 and same now on EE 5.3.0, server set up is the same…
I’m out of ideas… I’ve tried to escape the content with PHP methods such as htmlspecialchars, htmlentities, etc but it makes no difference…
😕
I’ll shoot an email to support@expressionengine.com
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.