modxcms / revolution

MODX Revolution - Content Management Framework
https://modx.com/
GNU General Public License v2.0
1.36k stars 528 forks source link

Clearing cache link doesn't work properly in 2.6.0 #13681

Closed Waivor closed 6 years ago

Waivor commented 6 years ago

After updating Modx to version 2.6.0 the "clear cache" menu button doesn't work anymore. Having a closer look at the html code, the browser shows me this:

<a onclick="{literal} MODx.clearCache(); return false;{/literal} ">

Comparing this line of code with the one that is generated in the Modx version 2.5.X I guess it shoud look like this:

<a onclick="MODx.clearCache(); return false;">

jonleverrier commented 6 years ago

@Waivor How would you define "doesn't work anymore"?

I can't replicate this issue on my installation of 2.6.0.

labr1005 commented 6 years ago

I can't replicate it either.

But maybe it's related to this commit: https://github.com/modxcms/revolution/commit/5529f5eb02af2e7d8240cf1c14e9c394df4fc7a2

Waivor commented 6 years ago

@jonleverrier "doesn't work anymore" means that clicking on it doesn't start the procedure of clearing the cache. Clicking on it doesn't have any effect.

jonleverrier commented 6 years ago

@Waivor Have you tried clearing your browser cache since upgrading? Are there any console errors in your browser? Can you replicate the issue?

Bruno17 commented 6 years ago

Seems related: https://forums.modx.com/thread/103122/upgrade-form-2-5-8-to-2-6-0-manager-menu

Bruno17 commented 6 years ago

could there be situations, where this part doesn't run thrue Smarty? @Mark-H

Jako commented 6 years ago

If I remember right, this happened once in my dev installation, when the core package was not build right before the installation. @Waivor Do you use a git-installation?

Waivor commented 6 years ago

@Jako I downloaded the traditional installation package (v. 2.6.0) from modx.com, uploaded everything by using FileZilla etc. ... quite ordinary.

Jako commented 6 years ago

Sorry, then it was a different cause/result. I had to comment out {eval var=$navb} in that installation temporary, because the manager did not load anymore. Sadly I don't know the reason anymore.

Maybe a lexicon issue, a wrong encoded/decoded unicode char or some invalid settings in the manager menu.

mrhaw commented 6 years ago

How big of a jump in upgrade did you do? Maybe if you upgrade version by version it would fix this. Just a thought... https://docs.modx.com/extras/revo/upgrademodx

Also did you try a fresh install on the same server?

Waivor commented 6 years ago

@mrhaw I upgraded from Modx 2.5.8 to 2.6.0, so there wasn't a big update jump. So far, I have not done a new installation on my server. It is noticeable that the same error occurs whenever I update an existing system (2.5.8) to 2.6.0.

muzzwood commented 6 years ago

I'm getting pretty much the same thing when trying to flush permissions. Clearing cache works fine though. Upgraded from 2.5.7 - 2.6.0 My browser gets an empty response with the error: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data

Bruno17 commented 6 years ago

@digitalpenguin sounds to me, yours is a different issue and I think, you should open a new issue for yours.

muzzwood commented 6 years ago

Right, will do!

sottwell commented 6 years ago

Getting a lot of these Smarty tags not being processed in my localhost upgraded installation, quite a few menu items don't work, such as Preview Site and Clear Cache and more.

sottwell commented 6 years ago

Which is odd, since all of my Cloud installations are upgraded and seem fine. Maybe because localhost was an upgrade of a pre-release 2.6?

Jako commented 6 years ago

If you could track this down, you could help a lot @sottwell

sottwell commented 6 years ago

Installed 2.5.8 on localhost, it upgraded with no problem.

Bruno17 commented 6 years ago

@Waivor could you tell about your environment?

Jako commented 6 years ago

@sottwell Could you look in the HTML code of your backend and locate where the first {literal} occurs after <li id="modx-manager-search-icon">. Especially the entry before that {literal} could help to identify the issue.

sottwell commented 6 years ago

I'm sorry, I just dumped everything to start fresh with an updated version of MAMP. However, in all cases, the {literal} tags were exactly as described in the forum post here https://forums.modx.com/thread/103122/upgrade-form-2-5-8-to-2-6-0-manager-menu#dis-post-555045 All menu items that were simple links were fine, it was only the Javascript-activated actions that had the problem.

Waivor commented 6 years ago

@Bruno17 MySQL 5.6.19 (both systems), PHP 7.71 Stable and PHP 5.56 Stable (2nd system), both were upgraded (2.5.8 to 2.6.0) with the same results. @sottwell link in the last post describes all the problems I have found so far.

Plugins: Collections 3.6.0 pl ContentBlocks 1.7.1 pl Migx 2.11.0 pl pdoTools 2.10.2 pl pThumb 2.3.3 pl Archivist 1.2.4 pl Quip 2.3.3 pl SimpleSearch 1.9.2 pl

Jako commented 6 years ago

@Waivor could you post a dump of the modx_menus table here? Maybe the issue is visible in there.

labr1005 commented 6 years ago

Hopefully a stupid question: You did run setup after upgrading and did not only upload/merge the files, right?

sottwell commented 6 years ago

Yes

labr1005 commented 6 years ago

Because without running setup I can reproduce this. But it's something different then.

sottwell commented 6 years ago

I strongly suspect something in the nature of caching somewhere. ExtJS can get really difficult if it gets fed old files.

Waivor commented 6 years ago

@Jako Do you mean this one?

<ul class="modx-subnav">
<li id="users">
<a href="?a=security/user">Users<span class="description">Manage Users and their Permissions</span>
</a>
</li>
<li id="refresh_site">
<a onclick="{literal} MODx.clearCache(); return false;{/literal} ">Clear Cache<span class="description">Delete Cache files in all Contexts</span>
</a>
<ul class="modx-subsubnav">
<li id="refreshuris">
<a onclick="{literal} MODx.refreshURIs(); return false;{/literal} ">Refresh URIs<span class="description">Regenerate system Resource URIs.</span>
</a>
</li>
</ul>
</li>
<li id="remove_locks">
<a onclick="{literal} MODx.removeLocks();return false;{/literal} ">Remove Locks<span class="description">Remove all locks on Manager pages</span>
</a>
</li>
<li id="flush_access">
<a onclick="{literal} MODx.msg.confirm({
    title: _('flush_access')
    ,text: _('flush_access_confirm')
    ,url: MODx.config.connector_url
    ,params: {
        action: 'security/access/flush'
    }
    ,listeners: {
        'success': {fn:function() { location.href = './'; },scope:this}
    }
});{/literal} ">Flush Your Permissions<span class="description">Reload this session’s Permissions</span>
</a>
</li>
<li id="flush_sessions">
<a onclick="{literal} MODx.msg.confirm({
    title: _('flush_sessions')
    ,text: _('flush_sessions_confirm')
    ,url: MODx.config.connector_url
    ,params: {
        action: 'security/flush'
    }
    ,listeners: {
        'success': {fn:function() { location.href = './'; },scope:this}
    }
});{/literal} ">Logout All Users<span class="description">Immediately destroy all sessions</span>
</a>
</li>
<li id="reports">
<a>Reports<span class="description">Admin reports for your MODX install</span>
</a>
<ul class="modx-subsubnav">
<li id="site_schedule">
<a href="?a=resource/site_schedule">Site Schedule<span class="description">View Resources with upcoming publish or unpublish dates.</span>
</a>
</li>
<li id="view_logging">
<a href="?a=system/logs">Manager Actions<span class="description">View the recent manager activity.</span>
</a>
</li>
<li id="eventlog_viewer">
<a href="?a=system/event">Error Log<span class="description">View the MODX error.log.</span>
</a>
</li>
<li id="view_sysinfo">
<a href="?a=system/info">System Info<span class="description">View server information, such as phpinfo, database info, and more.</span>
</a>
</li>
</ul>
sottwell commented 6 years ago

@Waivor I think he meant the modx_menus table in the database. A couple of the relevant lines in the database dump from a properly-working site:

('refresh_site', 'manage', '', 'refresh_site_desc', '', 1, '', 'MODx.clearCache(); return false;', 'empty_cache', 'core'),

('remove_locks', 'manage', '', 'remove_locks_desc', '', 2, '', 'MODx.removeLocks();return false;', 'remove_locks', 'core'),
Jako commented 6 years ago

@Waivor The generated html code above looks right. But the {literal} smarty tags are not removed by Smarty for some reason. Does manager/templates/default/header.tpl contains the {eval var=$navb} tag according to https://github.com/modxcms/revolution/commit/5529f5eb02af2e7d8240cf1c14e9c394df4fc7a2

Waivor commented 6 years ago

@sottwell I see, no problem:

('site','topnav','','','','0','','','menu_site','core')
('new_resource','site','resource/create','new_resource_desc','','0','','','new_document','core')
('preview','site','','preview_desc','','4','','MODx.preview();returnfalse;','','core')
('import_site','site','system/import/html','import_site_desc','','5','','','import_static','core')
('import_resources','site','system/import','import_resources_desc','','6','','','import_static','core')
('resource_groups','site','security/resourcegroup','resource_groups_desc','','7','','','access_permissions','core')
('content_types','site','system/contenttype','content_types_desc','','8','','','content_types','core')
('media','topnav','','media_desc','','1','','','file_manager','core')
('file_browser','media','media/browser','file_browser_desc','','0','','','file_manager','core')
('sources','media','source','sources_desc','','1','','','sources','core')
('components','topnav','','','','2','','','components','core')
('installer','components','workspaces','installer_desc','','0','','','packages','core')
('manage','topnav','','','','3','','','menu_tools','core')
('users','manage','security/user','user_management_desc','','0','','','view_user','core')
('refresh_site','manage','','refresh_site_desc','','1','','MODx.clearCache();returnfalse;','empty_cache','core')
('refreshuris','refresh_site','','refreshuris_desc','','0','','MODx.refreshURIs();returnfalse;','empty_cache','core')
('remove_locks','manage','','remove_locks_desc','','2','','MODx.removeLocks();returnfalse;','remove_locks','core')
('flush_access','manage','','flush_access_desc','','3','','MODx.msg.confirm({title:_('flush_access'),text:_('flush_access_confirm'),url:MODx.config.connector_url,params:{action:'security/access/flush'},listeners:{'success':{fn:function(){location.href='./';},scope:this}}});','access_permissions','core')('flush_sessions','manage','','flush_sessions_desc','','4','','MODx.msg.confirm({title:_('flush_sessions'),text:_('flush_sessions_confirm'),url:MODx.config.connector_url,params:{action:'security/flush'},listeners:{'success':{fn:function(){location.href='./';},scope:this}}});','flush_sessions','core')
('reports','manage','','reports_desc','','5','','','menu_reports','core')
('site_schedule','reports','resource/site_schedule','site_schedule_desc','','0','','','view_document','core')
('view_logging','reports','system/logs','view_logging_desc','','1','','','logs','core')
('eventlog_viewer','reports','system/event','eventlog_viewer_desc','','2','','','view_eventlog','core')
('view_sysinfo','reports','system/info','view_sysinfo_desc','','3','','','view_sysinfo','core')
('usernav','','','usernav_desc','','0','','','','core')('user','usernav','','','&lt;spanid=&quot;user-avatar&quot;&gt;{$userImage}&lt;/span&gt;&lt;spanid=&quot;user-username&quot;&gt;{$username}&lt;/span&gt;','5','','','menu_user','core')
('profile','user','security/profile','profile_desc','','0','','','change_profile','core')
('messages','user','security/message','messages_desc','','1','','','messages','core')
('logout','user','security/logout','logout_desc','','2','','MODx.logout();returnfalse;','logout','core')
('admin','usernav','','','&lt;iclass=&quot;icon-geariconicon-large&quot;&gt;&lt;/i&gt;','6','','','settings','core')
('system_settings','admin','system/settings','system_settings_desc','','0','','','settings','core')
('bespoke_manager','admin','security/forms','bespoke_manager_desc','','1','','','customize_forms','core')('dashboards','admin','system/dashboards','dashboards_desc','','2','','','dashboards','core')
('contexts','admin','context','contexts_desc','','3','','','view_context','core')
('edit_menu','admin','system/action','edit_menu_desc','','4','','','actions','core')
('acls','admin','security/permission','acls_desc','','5','','','access_permissions','core')
('propertysets','admin','element/propertyset','propertysets_desc','','6','','','property_sets','core')
('lexicon_management','admin','workspaces/lexicon','lexicon_management_desc','','7','','','lexicons','core')('namespaces','admin','workspaces/namespace','namespaces_desc','','8','','','namespaces','core')('about','usernav','help','','&lt;iclass=&quot;icon-question-circleiconicon-large&quot;&gt;&lt;/i&gt;','7','','','help','core')
('contentblocks.menu','components','1','contentblocks.menu_desc','','0','','','administrator','core')
('migx','components','index','MigxKonfigurator','','0','&amp;configs=packagemanager||migxconfigs||setup','','','migx')('formit','components','3','formit.menu_desc','images/icons/plugin.gif','0','','','packages','core')('quip','components','4','quip_desc','images/icons/plugin.gif','4','','','','core')
('collections.menu.collection_templates','components','5','collections.menu.collection_templates_desc','','0','','','packages','core')

@Jako line 73 to line 78 in /templates/default/header.tpl

...
</a>
</li>
{/if}
{eval var=$navb}
</ul>
 {if $_search}
...
Waivor commented 6 years ago

Note: I solved the problem by deleting the whole system on the server and reuploading and installing modx 2.6.0 (traditional) (uploading the database, installing snippets etc.).

OptimusCrime commented 6 years ago

Just to be sure, you are certain that you did upload (and overwrite the existing files) and ran the installer for an upgrade?

sottwell commented 6 years ago

When it happened to my localhost installation, I had used UpgradeMODX.

OptimusCrime commented 6 years ago

@sottwell I am not familiar with that extra. What does that do that solved the problem? And what did you to first?

sottwell commented 6 years ago

It downloads the requested release, extracts it and moves the files into the appropriate location, then redirects you to the Setup page.

sottwell commented 6 years ago

I had downloaded the .zip of the 2.6 from github, built it and installed. Then when the release came out, I installed UpgradeMODX and ran it (it's a Dashboard widget) and everything seemed fine, until checked the main menu.

sottwell commented 6 years ago

Later, I installed 2.5.-whatever, checked it to make sure it was good, then again installed UpgradeMODX and repeated the upgrade. This time, everything was fine.

OptimusCrime commented 6 years ago

We have a website that has this problem. I can see all the {literal} tags in the source. Can someone confirm that this in fact works on a fresh 2.6.0 site? This problem only occur with an upgrade? I heard reports from the office that the problem happened when they tried to upgrade from 2.5.7, but 2.5.8 was fine.

Bruno17 commented 6 years ago

I don't have seen this issue. Neither at new installations nor at upgraded. I'm also upgrading with Bobs UgradeMODX. But I didn't try it on a local installation. Could it be something with smarty - cache?

Jako commented 6 years ago

I suppose it is/was a caching issue and some files in core/cache/mgr/smarty are not removed during the update to 2.6.0. The following steps have to happen to reproduce the issue:

The menu content is cached in another place, but that cache can't cause the {literal} issue.

And I don't think that a smarty issue could cause this. In my tests I have tried to create some parsing issues in header.tpl, but then the whole manager breaks with an error 500.

As far as I know, the only smarty cache is in the core/cache/mgr/smarty folder. So the update process should clear this folder and warn the user, if there is something left there.

OptimusCrime commented 6 years ago

I tried to manually clear the core/cache/mgr/smarty directory, and the problem is still there. I can also confirm that the menus are cached in core/cache/menu, but without the {literal} tags, so this should not be the cause of the problem.

EDIT: Could it be that eval is turned off?

Jako commented 6 years ago

It can't be disabled, at least there is no statement in the docs for disabling it: https://www.smarty.net/docsv2/en/language.function.eval.tpl

@OptimusCrime: Could you look what's in navb after this line: https://github.com/modxcms/revolution/blob/5529f5eb02af2e7d8240cf1c14e9c394df4fc7a2/manager/controllers/default/header.php#L74 with die($this->modx->smarty->getTemplateVars('navb'));

OptimusCrime commented 6 years ago

I did a var_dump. Complete output below:

string(5479) "<li id="limenu-site" class="top">
<a href="javascript:;">Content</a>
<ul class="modx-subnav">
<li id="new_resource">
<a href="?a=resource/create">New Resource<span class="description">Create a Resource — usually a web page</span>
</a>
</li><li id="preview">
<a onclick="{literal} MODx.preview(); return false;{/literal} ">Preview Site<span class="description">View your website in a new window</span>
</a>
</li><li id="import_site">
<a href="?a=system/import/html">Import HTML<span class="description">Import HTML files to Resources</span>
</a>
</li><li id="import_resources">
<a href="?a=system/import">Import Static Resources<span class="description">Import any Content Type based on file extension to Static Resources</span>
</a>
</li><li id="resource_groups">
<a href="?a=security/resourcegroup">Resource Groups<span class="description">Assign Resources to Groups</span>
</a>
</li><li id="content_types">
<a href="?a=system/contenttype">Content Types<span class="description">Add content types for resources, such as .html, .js, etc.</span>
</a>
</li></ul>
</li>
<li id="limenu-media" class="top">
<a href="javascript:;">Media</a>
<ul class="modx-subnav">
<li id="file_browser">
<a href="?a=media/browser">Media Browser<span class="description">View, upload and manage media</span>
</a>
</li><li id="sources">
<a href="?a=source">Media Sources<span class="description">Media sources for use of media from remote services or servers</span>
</a>
</li></ul>
</li>
<li id="limenu-components" class="top">
<a href="javascript:;">Extras</a>
<ul class="modx-subnav">
<li id="installer">
<a href="?a=workspaces">Installer<span class="description">Manage Add-ons and Distributions</span>
</a>
</li><li id="cmpgenerator">
<a href="?a=3">CMP Generator<span class="description">Generate CMP code</span>
</a>
</li><li id="collections.menu.collection_templates">
<a href="?a=1">Collection views<span class="description">Define views for collection's children grid.</span>
</a>
</li></ul>
</li>
<li id="limenu-manage" class="top">
<a href="javascript:;">Manage</a>
<ul class="modx-subnav">
<li id="users">
<a href="?a=security/user">Users<span class="description">Manage Users and their Permissions</span>
</a>
</li><li id="refresh_site">
<a onclick="{literal} MODx.clearCache(); return false;{/literal} ">Clear Cache<span class="description">Delete Cache files in all Contexts</span>
</a>
<ul class="modx-subsubnav">
<li id="refreshuris">
<a onclick="{literal} MODx.refreshURIs(); return false;{/literal} ">Refresh URIs<span class="description">Regenerate system Resource URIs.</span>
</a>
</li></ul>
</li><li id="remove_locks">
<a onclick="{literal} MODx.removeLocks();return false;{/literal} ">Remove Locks<span class="description">Remove all locks on Manager pages</span>
</a>
</li><li id="flush_access">
<a onclick="{literal} MODx.msg.confirm({
    title: _('flush_access')
    ,text: _('flush_access_confirm')
    ,url: MODx.config.connector_url
    ,params: {
        action: 'security/access/flush'
    }
    ,listeners: {
        'success': {fn:function() { location.href = './'; },scope:this}
    }
});{/literal} ">Flush Your Permissions<span class="description">Reload this session’s Permissions</span>
</a>
</li><li id="flush_sessions">
<a onclick="{literal} MODx.msg.confirm({
    title: _('flush_sessions')
    ,text: _('flush_sessions_confirm')
    ,url: MODx.config.connector_url
    ,params: {
        action: 'security/flush'
    }
    ,listeners: {
        'success': {fn:function() { location.href = './'; },scope:this}
    }
});{/literal} ">Logout All Users<span class="description">Immediately destroy all sessions</span>
</a>
</li><li id="reports">
<a>Reports<span class="description">Admin reports for your MODX install</span>
</a>
<ul class="modx-subsubnav">
<li id="site_schedule">
<a href="?a=resource/site_schedule">Site Schedule<span class="description">View Resources with upcoming publish or unpublish dates.</span>
</a>
</li><li id="view_logging">
<a href="?a=system/logs">Manager Actions<span class="description">View the recent manager activity.</span>
</a>
</li><li id="eventlog_viewer">
<a href="?a=system/event">Error Log<span class="description">View the MODX error.log.</span>
</a>
</li><li id="view_sysinfo">
<a href="?a=system/info">System Info<span class="description">View server information, such as phpinfo, database info, and more.</span>
</a>
</li></ul>
</li></ul>
</li>
<li id="limenu-DevTools" class="top">
<a href="javascript:;">DevTools</a>
<ul class="modx-subnav">
<li id="DB Search">
<a href="?a=home&namespace=dev">DB Search<span class="description">Search resources, templates, chunks and snippets with reguar expressions.</span>
</a>
</li><li id="MODX Error Log">
<a href="?a=system/event">MODX Error Log<span class="description">Track PHP bugs registered by MODX</span>
</a>
</li><li id="xbug.xbug">
<a href="?a=2" onclick="{literal} return false;{/literal} ">xBug<span class="description">xBug Query and Page Profiler Tools.</span>
</a>
<ul class="modx-subsubnav">
<li id="xbug.xbug_query">
<a href="?a=2">xBug Query Debugger.<span class="description">xBug xPDOCriteria Debugging Utility.</span>
</a>
</li><li id="xbug.profiler">
<a href="?a=2&action=profiler">Profiler<span class="description">Analyze parser and sql events during page load</span>
</a>
</li></ul>
</li><li id="Notes">
<a href="?a=notes&namespace=dev">Notes<span class="description">Keep track of your notes when under development.</span>
</a>
</li></ul>
</li>
"
Jako commented 6 years ago

Looks ok, but why it is not evaled with {eval var=$navb} here?

https://github.com/modxcms/revolution/blob/a6dabd869fd426d21ae022caa651554650b6fe74/core/model/modx/modmanagercontroller.class.php#L477

Jako commented 6 years ago

Could you look if the fetched header.tpl (it could be cached somewhere) contain that eval tag?

Jako commented 6 years ago

Is it possible, that it is not cached in core/cache/mgr/smarty but elsewhere (i.e. in a database or the memory)?

Jako commented 6 years ago

@OptimusCrime Did you get further on this? I can't reproduce those issues here, but since you have one installation showing that issue, you could help a lot debugging it.

OptimusCrime commented 6 years ago

Sorry! The header.tpl file contains the eval tag. I looked at modSmarty, and it looks like the cache files that related to Smarty are all placed in the directory you specified above. We do not use in memory caching.

Jako commented 6 years ago

Could you remote debug that beast and look whether fetchTemplate is getting the right template + data? There must be some reason why that {eval var=$navb} does not strip the {literal} tags.