Smarty cache issue

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
krodelabestiole
Forum Members
Forum Members
Posts: 12
Joined: Thu Feb 18, 2016 11:00 am

Smarty cache issue

Post by krodelabestiole »

hello

i've just updated from 1.11.4 to 2.1.2 (thru steps) and everything went fine.
except when i finally disconnected from the admin :
my front-office went all wiggly, like parts in some pages that come from other pages, wrong image sizes, wrong active page in the menu, broken html etc.
i reconnected to the admin panel and everything went fine again (it took some time to understand this though).

i've finally found the guilty party : smarty cache. but even when i delete every files from templates_c , every time i activate it my website becomes a mess again (slowly but surely, a bit more at each click - it's quite a piece of art).
- i guess smarty cache is deactivated as long as we are connected ?

i use some external modules : gallery, showtime, navigator and such.
everyone are faulty when it comes to smarty cache and run perfectly otherwise.
i run cmsms by a hosting service, infomaniak, running a lamp server
Apache 2.0
PHP 5.5.23
mysql 5.0.11

it's a production server so i won't break the website on purpose but i could setup the cms a second time on a subdirectory if it's really needed - though i doubt it would be of any help.
tell me if you need more info.

anyway i can use the website without smarty cache but i'm very curious about what could cause this bad behavior and i would like to optimise performances.

thank you

O0
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: Smarty cache issue

Post by paulbaker »

I don't know the answer to your issue but you are more likely to get helpful responses from the gurus ;) if you post your full system info, see my signature for how.
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
krodelabestiole
Forum Members
Forum Members
Posts: 12
Joined: Thu Feb 18, 2016 11:00 am

Re: Smarty cache issue

Post by krodelabestiole »

hi, thanks for the tip, i hadn't found this.

here it is :

Code: Select all

----------------------------------------------
Cms Version: 2.1.2
Installed Modules:
AdminSearch: 1.0
CMSContentManager: 1.1
CMSMailer: 6.2.14
Captcha: 0.5.2
DesignManager: 1.1.1
FileManager: 1.5.2
FormBuilder: 0.8.1.3
Gallery: 2.1
MicroTiny: 2.0.3
ModuleManager: 2.0.2
Navigator: 1.0.2
News: 2.50.4
Search: 1.50.2
Showtime: 3.4
ThemeManager: 1.1.8

Config Information:
php_memory_limit:
max_upload_size: 300000000
url_rewriting: mod_rewrite
page_extension: .html
query_var: page
auto_alias_content: true
locale:
set_names: true
timezone: Europe/Berlin
permissive_smarty: false

Php Information:
phpversion: 5.5.23
md5_function: On (True)
json_function: On (True)
gd_version: 2
tempnam_function: On (True)
magic_quotes_runtime: Off (False)
E_ALL: 32759
E_STRICT: 2048
E_DEPRECATED: 8192
test_file_timedifference: No time difference found
test_db_timedifference: No time difference found
create_dir_and_file: 1
memory_limit: 128M
max_execution_time: 30
register_globals: Off (False)
output_buffering: 20480
disable_functions: set_time_limit, passthru, exec, system, popen, shell_exec, proc_open
open_basedir: /home/www/86ad7b441e0fe2e42983a4d6e77e0f50:/tmp:/opt/php/lib/php
test_remote_url: Success
file_uploads: On (True)
post_max_size: 300M
upload_max_filesize: 300M
session_save_path: No check because open basedir active
session_use_cookies: On (True)
xml_function: On (True)
xmlreader_class: On (True)
check_ini_set: On (True)
curl: On

Performance Information:
allow_browser_cache: On (True)
browser_cache_expiry: 60
php_opcache: Off (False)
smarty_cache: Off (False)
smarty_compilecheck: Off (False)
smarty_cache_udt: Off (False)
auto_clear_cache_age: On (True)
Server Information:
Server Software: Apache
Server Api: apache2handler
Server Os: Linux 3.4.74-imu On x86_64
Server Db Type: MySQL (mysqli)
Server Db Version: 5.0.84
Server Db Grants: Could not find a suitable "GRANT ALL" permission, this does not necessarily lead to problems... But if you have problems installing/removing modules or adding and deleting items/pages this could be the cause!

Permission Information:
tmp: /home/www/86ad7b441e0fe2e42983a4d6e77e0f50/web/tmp (2777)
tmp_cache: /home/www/86ad7b441e0fe2e42983a4d6e77e0f50/web/tmp/cache (2777)
templates_c: /home/www/86ad7b441e0fe2e42983a4d6e77e0f50/web/tmp/templates_c (2777)
modules: /home/www/86ad7b441e0fe2e42983a4d6e77e0f50/web/modules (2777)
uploads: /home/www/86ad7b441e0fe2e42983a4d6e77e0f50/web/uploads (2777)
File Creation Mask (umask): /home/www/86ad7b441e0fe2e42983a4d6e77e0f50/web/tmp/cache (2777)
config_file: 0744
----------------------------------------------
krodelabestiole
Forum Members
Forum Members
Posts: 12
Joined: Thu Feb 18, 2016 11:00 am

Re: Smarty cache issue

Post by krodelabestiole »

i found something weird :
it seems in this table that smarty_compilecheck stays off even though Do a Compilation Check is selected yes in the smarty settings page (Settings - Global Settings -> Smarty Settings)

Code: Select all

smarty_cache: On (True)
smarty_compilecheck: Off (False)
smarty_cache_udt: On (True)
could someone please check that smarty_compilecheck should be on when this parameter is set ?
krodelabestiole
Forum Members
Forum Members
Posts: 12
Joined: Thu Feb 18, 2016 11:00 am

Re: Smarty cache issue

Post by krodelabestiole »

value for use_smartycompilecheck is also 1 in the database (cms_siteprefs table)
msaluste
New Member
New Member
Posts: 8
Joined: Sun Aug 14, 2011 8:17 am

Re: Smarty cache issue

Post by msaluste »

I am having a similar problem after upgrading from 1.12.1 to 2.1.2.

Enabling Smarty caching completely messes up content rendering on IE and Edge: page titles do not change (it caches the first title and displays it for every page I open next), everything stored with Smarty's capture command stays cached even when I add "nocache".

I also have second content block in my template and its content is never displayed on IE and Edge. Firefox seems to have no problems with Smarty caching.

Clearing browser and CMSMS cache (and F5 or Ctrl+F5 in IE/Edge) has no effect on rendering.

After disabling Smarty caching all browsers work fine, but pages load noticeably slower.

Here's my sysinfo:

Code: Select all

CMS Made Simple Install Information
CMSMS Version		2.1.2

Installed Modules
AceEditor2		1.05
AdminSearch		1.0
CGExtensions		1.51.1
CGSimpleSmarty		2.0.5
CMSContentManager		1.1
CMSMailer		6.2.14
DesignManager		1.1.1
FileManager		1.5.2
FormBuilder		0.8.1.3
MenuManager		1.50.2
MicroTiny		2.0.3
ModuleManager		2.0.2
Navigator		1.0.2
SiteMapMadeSimple		1.2.8
TinyMCE		3.1.2

CMS Made Simple Config Settings
php_memory_limit		 
max_upload_size		16000000
url_rewriting		mod_rewrite
page_extension		.html
query_var		page
auto_alias_content		true
locale		 
set_names		true
timezone		Europe/Tallinn
permissive_smarty		false
debug		false
root_path	/home/***	(0751)
uploads_path	/home/***/uploads	(0775)
image_uploads_path	/home/***/images	(0755)

Performance and Tuning Information (recommended settings, but not required)
Allow Browser to Cache Pages	On
Browser Cache Expiry Period (minutes)	960
PHP 5.5+ Opcode Cache	On
Enable Smarty Caching	Caution	Off	
Enabling smarty caching can have serious performance benefits for most websites.
Do a Compilation Check	Off
Cache UDT Calls	Caution	Off	
Caching user defined tags can have serious performance benefits. Use caution
Remove cache files that are older than the specified number of days	On

PHP Information
Current PHP Version (phpversion)	 5.6.18
md5 function (md5_function)	 On
JSON functions (json_function)	 On
GD version (gd_version)	 2
tempnam function (tempnam_function)	 On
Magic quotes in runtime (magic_quotes_runtime)	 Off
Is E_ALL enabled in error_reporting (E_ALL)	Caution	E_ALL is not enabled in error reporting, this could mean that you may not see important problems in your error log.
Is E_STRICT disabled in error_reporting (E_STRICT)	
Is E_DEPRECATED disabled in error_reporting (E_DEPRECATED)	
Testing for time difference in the file system (test_file_timedifference)	 No time difference found
Testing for time difference in the database (test_db_timedifference)	 No time difference found
Checking if the HTTPD process can create a file inside of a directory it created (create_dir_and_file)	 1
PHP Effective Memory Limit (memory_limit)	 128M
Maximum Execution Time (max_execution_time)	 60
PHP register_globals (register_globals)	 Off
PHP output_buffering (output_buffering)	 On
disable_functions in PHP (disable_functions)	Caution	 show_source, system, shell_exec, passthru, exec, phpinfo, popen, proc_open	 ?
PHP Open Basedir (open_basedir)	 
Test for remote URL (test_remote_url)	 Success	
fsockopen: Connection ok! Success 
fopen: Connection ok! Success
File uploads (file_uploads)	 On
Maximum Post Size (post_max_size)	 16M
Maximum Upload Size (upload_max_filesize)	 16M
Session Save Path (session_save_path)	 /tmp	(1777)
Sessions are allowed to use Cookies (session_use_cookies)	 On
Basic XML (expat) support (xml_function)	 On
Checking for the XMLReader class (xmlreader_class)	 On
Test ini_set (check_ini_set)	 On
Test for the curl library (curl)	 On
Test curl version (curlversion)	 version 7.38.0, minimum recommended version is 7.19.7

Server Information
Server Software (server_software)		apache
Server API (server_api)		cgi-fcgi
Server Operating System (server_os)		linux 2.6.32-042stab112.15 on x86_64
Server Database (server_db_type)		mysql (mysqli)
Server Database Version (server_db_version)	5.6.29
Check database access levels (server_db_grants)	found a "grant all" statement that appears to be suitable

Permission Information
tmp	/home/***/tmp	(0775)
tmp_cache	/home/***/tmp/cache	(0755)
templates_c	/home/***/tmp/templates_c	(0755)
modules	/home/***/modules	(0755)
uploads	/home/***/uploads	(0775)
File Creation Mask (umask)	/home/***/tmp/cache	(0755)
config_file	0444
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Smarty cache issue

Post by calguy1000 »

Smarty caching results in HTML being cached to the disk, rather than merely a 'compiled' smarty template. That said, smarty caching is a complex issue... particularly after smarty variable scopes were introduced, and in relation to custom display of output.

i.e: It's potentially very difficult to do caching of HTML if there is logic in the template.

If there are browser issues with the resulting HTML when using smarty caching... then it is almost certainly (IMHO) an issue that must be resolved in the template.

Unfortunately, nobody has posted their templates for us to be able to take a cursory look and potentially spot any issues.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
krodelabestiole
Forum Members
Forum Members
Posts: 12
Joined: Thu Feb 18, 2016 11:00 am

Re: Smarty cache issue

Post by krodelabestiole »

Code: Select all

smarty_cache: On (True)
smarty_compilecheck: Off (False)
smarty_cache_udt: On (True)
sorry im asking again, but is it normal that smarty_compilecheck appears off in the system info when Do a Compilation Check is selected yes in the smarty settings page (Settings - Global Settings -> Smarty Settings) - and use_smartycompilecheck is also set to 1 in the database (cms_siteprefs table) ?

here is for the main template i use (zionarrow strongly modified) :

Code: Select all

{process_pagedata}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<__html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{sitename} - {title}</title>
{metadata}
{cms_stylesheet}
</head>
</__body>
<div id="wrapper">
	<div id="header">
		<div id="logo">
			<img src="gorellaume.png" width="300" height="101" />
			<a href="index.php><img src="/images/galleryLogo_sm.png" width="396" height="83" /></a>
			{*<h1>{sitename}</h1>*}
		</div>
		{*<div id="search">
			{search}
		</div>*}
	</div>
	<!-- end #header -->
	{*<div id="menu">
		{menu template="zionnarrows_minimal_menu" number_of_levels="1"}
	</div>*}
	<!-- end #menu -->
	<div id="page">
	<div id="page-bgtop">
	<div id="page-bgbtm">
		<div id="content">
			<div class="post">
				<h2 class="title">{title}</h2>
				<div class="entry">
			    	{*<p class="meta">{print} | {edit}</p>*}
                    {content}
				</div>
			</div>
		</div>
		<!-- end #content -->
		<div id="sidebar">
			<ul>
				<li>
					<h2>Menu</h2>
					{Navigator collapse="1"}
				</li>
			</ul>
		</div>
		<!-- end #sidebar -->
	</div>
	</div>
	</div>
	<!-- end #page -->
</div>
	<div id="footer">
		<p>All images copyrighted. © Gorellaume {$smarty.now|date_format:"%Y"}</p>
	</div>
	<!-- end #footer -->
{literal}
<!-- Piwik -->
<__script__ type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://www.crachecode.net/piwik/" : "http://www.crachecode.net/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</__script><__script__ type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 8);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</__script><noscript><p><img src="http://www.crachecode.net/piwik/piwik.php?idsite=8" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->
{/literal}
<__body>
</__html>
this is for the menu template (i can't remember if i had modified it or not) :

Code: Select all

{strip}

{$main_id = ' id=\'footer-menu\''}
{function do_footer_class}
    {if count($classes) > 0} class='{implode(' ',$classes)}'{/if}
{/function}

{function name='Simplex_footer_menu' depth='1'}
    <ul{$main_id}{if isset($ul_class) && $ul_class != ''} class="{$ul_class}"{/if}>
        {$main_id = ''}
        {$ul_class = ''}
        {foreach $data as $node}
            {* setup classes for the anchor and list item *}
            {$list_class = []}
            {$href_class = []}
    
            {if $node->current || $node->parent}
                {* this is the current page *}
                {$list_class[] = 'current'}
                {$href_class[] = 'current'}
            {/if}
    
            {if $node->children_exist}
                {$list_class[] = 'parent'}
            {/if}
    
            {* build the menu item node *}
            {if $node->type == 'sectionheader'}
                {$list_class[] = 'sectionheader'}
                <li{do_footer_class classes=$list_class}><span>{$node->menutext}</span>
                {if isset($node->children)}
                    {Simplex_footer_menu data=$node->children depth=$depth+1}
                {/if}
                </li>
            {else if $node->type == 'separator'}
                {$list_class[] = 'separator'}
                <li{do_footer_class classes=$list_class}'><hr class='separator'/></li>
            {else}
                {* regular item *}
                <li{do_footer_class classes=$list_class}>
                    <a{do_footer_class classes=$href_class} href='{$node->url}'{if $node->target != ''} target='{$node->target}'{/if}>{$node->menutext}</a>
                    {if isset($node->children)}
                        {Simplex_footer_menu data=$node->children depth=$depth+1}
                    {/if}
                </li>
            {/if}
        {/foreach}
    </ul>
{/function}

{if isset($nodes)}
    {Simplex_footer_menu data=$nodes depth='0' ul_class='cf'}
{/if}

{/strip}
and for gallery template (fancybox modified)

Code: Select all

<div class="gallery">
{*if !empty($gallerytitle)}<h3>{$gallerytitle}</h3>{/if*}
{if !empty($gallerycomment)}<div class="gallerycomment">{$gallerycomment}</div>{/if}
{*<p>{$imagecount}</p>
<div class="pagenavigation">
{if $pages > 1}
<div class="prevpage">{$prevpage}</div>
<div class="nextpage">{$nextpage}</div>
{/if}
{if !$hideparentlink && !empty($parentlink)}<div class="parentlink">{$parentlink}</div>{/if}
{if $pages > 1}<div class="pagelinks">{$pagelinks}</div>{/if}
</div>*}

{foreach from=$images item=image}
	<div class="img">
	{if $image->isdir}
		<a href="{$image->file}" title="{$image->titlename}"><img src="{$image->thumb|escape:'url'|replace:'%2F':'/'}" alt="{$image->titlename}" /></a><br />
		{$image->titlename}
	{else}
   <a class="group" href="{$image->file|escape:'url'|replace:'%2F':'/'}" title="{$image->titlename}" rel="gallery-{$galleryid}"><img src="{$image->thumb|escape:'url'|replace:'%2F':'/'}" alt="{$image->titlename}" /></a>
	{/if}
	</div>
{/foreach}
</div>
krodelabestiole
Forum Members
Forum Members
Posts: 12
Joined: Thu Feb 18, 2016 11:00 am

Re: Smarty cache issue

Post by krodelabestiole »

i just want to mention the fact that the forum add underscores and randomness in my code

there is no
<__body>
</__html>
and no closing </__body> at the beginning...
if i try to edit i've got the clean thing though
not that practical to share code...

i would like to upload the template as an external file but i have this message instead :
The upload was rejected because the uploaded file was identified as a possible attack vector.

how do you usually work here to share some code ?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Smarty cache issue

Post by calguy1000 »

yeah I see the issue with the title tag and other smarty plugins (including the stylesheet tag... though I don't think that would effect browser behavior).

It will take some time to play with this and investigate..

In the mean time I suggest you disable smarty caching.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
krodelabestiole
Forum Members
Forum Members
Posts: 12
Joined: Thu Feb 18, 2016 11:00 am

Re: Smarty cache issue

Post by krodelabestiole »

ok thanks

that's 3 bugs then

1 - broken smarty cache. sounds pretty critical to me.
2 - smarty_compilecheck alway appears off in the system info (minor bug).
3 - impossible to share html code on the forum - which is the only place i found to report bugs :-\
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1922
Joined: Mon Jan 29, 2007 4:47 pm

Re: Smarty cache issue

Post by Jo Morg »

krodelabestiole wrote: that's 3 bugs then

1 - broken smarty cache. sounds pretty critical to me.
2 - smarty_compilecheck alway appears off in the system info (minor bug).
3 - impossible to share html code on the forum - which is the only place i found to report bugs :-\
Well, that's none yet:
  1. We'll have to investigate that and assess if it is a bug or not. If reproducible then we'll fix it;
  2. Same as point 1;
  3. How is it impossible? if you search around you'll see other people doing so without issues - the underscores are added on purpose to avoid the defacing of the forum pages on badly formed posts containing html tags. The code is still readable and there is no randomness about it that I can see. In any case, bugs can, and should, be reported on the Forge, so the Forum is not the only (not even the best) place to report bugs;
That doesn't mean that you can't start by opening a topic here if you need to confirm if the issues you are experiencing are really a bug or not.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
krodelabestiole
Forum Members
Forum Members
Posts: 12
Joined: Thu Feb 18, 2016 11:00 am

Re: Smarty cache issue

Post by krodelabestiole »

Jo Morg wrote:The code is still readable and there is no randomness about it that I can see.
what i would called randomness is just the fact that the body tag is closing before it's opening then. which is not that big deal but i guess it might get things a bit tricky when you're looking for html errors, or when you just want to copy paste. i guess there are cleaner way to get the code not to be interpreted, but it's ok if it suits you.
Post Reply

Return to “CMSMS Core”