Skip to content

Manager compression causes Webkit-based browser to bail #8168

@CyntaxDotDev

Description

@CyntaxDotDev

ReSpawN created Redmine issue ID 8168

When using a webkit based browser like Chrome or Safari (latest versions) and in combination with UNCOMPESSED javascript, it caused the following error:

malformed formal parameter (in Firefox)
Unexpected Syntax: Unexpected Token [ (Chrome and Safari)

Both occurred on line 16 or 17 in line utilities.js

Ext.namespace('MODx.util.Progress');
/**
 * A JSON Reader specific to MODExt
 *
 * @class MODx.util.JSONReader
 * @extends Ext.util.JSONReader
 * @param {Object} config An object of configuration properties
 * @xtype modx-json-reader
 */
MODx.util.JSONReader = function(config) {
    config = config || {};
    Ext.applyIf(config,{
        successProperty:'success'
        ,totalProperty: 'total'
        ,root: 'data'
    });
    MODx.util.JSONReader.superclass.constructor.call(this,config,['id','msg']);
};
Ext.extend(MODx.util.JSONReader,Ext.data.JsonReader);
Ext.reg('modx-json-reader',MODx.util.JSONReader);

Thus this line

    MODx.util.JSONReader.superclass.constructor.call(this,config,['id','msg']);

We eventually traced it back to an error in the header.tpl of the manager. When you're using uncompressed javascript, the Smarty if statement wouldn't catch all that it needed to, thus including compressed CoreJS1 through 3, in addition to the uncompressed core JS files.

Attached is the correct header.tpl that will fix these errors. For the record, the reason why we had uncompressed javascript, was for internal developent.

We replaced the following block of code with that underneath it.

{if $_config.compress_js
<script src="{$_config.manager_url}assets/ext3/adapter/ext/ext-base-debug.js" type="text/javascript"></script>
<script src="{$_config.manager_url}assets/ext3/ext-all-debug.js" type="text/javascript"></script>
<script src="{$_config.manager_url}assets/modext/core/modx.js" type="text/javascript"></script>
<script src="{$_config.connectors_url}lang.js.php?ctx=mgr&topic=topmenu,file,resource,{$_lang_topics}&action={$smarty.get.a|strip_tags}" type="text/javascript"></script>
<script src="{$_config.connectors_url}layout/modx.config.js.php?action={$smarty.get.a|strip_tags}{if $_ctx}&wctx={$_ctx}{/if}" type="text/javascript"></script>

{if $_config.compress_js && $_config.compress_js_groups}

<script src="{$_config.manager_url}min/index.php?g=coreJs1" type="text/javascript"></script> <script src="{$_config.manager_url}min/index.php?g=coreJs2" type="text/javascript"></script> <script src="{$_config.manager_url}min/index.php?g=coreJs3" type="text/javascript"></script>

{/if}

{if !$_config.compress_js}
    <script src="{$_config.manager_url}assets/ext3/adapter/ext/ext-base-debug.js" type="text/javascript"></script>
<script src="{$_config.manager_url}assets/ext3/ext-all-debug.js" type="text/javascript"></script>

{else}
<script src="{$_config.manager_url}assets/ext3/adapter/ext/ext-base.js" type="text/javascript"></script>
<script src="{$_config.manager_url}assets/ext3/ext-all.js" type="text/javascript"></script>
{/if}

<script src="{$_config.manager_url}assets/modext/core/modx.js" type="text/javascript"></script> <script src="{$_config.connectors_url}lang.js.php?ctx=mgr&topic=topmenu,file,resource,{$_lang_topics}&action={$smarty.get.a|strip_tags}" type="text/javascript"></script> <script src="{$_config.connectors_url}layout/modx.config.js.php?action={$smarty.get.a|strip_tags}{if $_ctx}&wctx={$_ctx}{/if}" type="text/javascript"></script>

{if $_config.compress_js && $_config.compress_js_groups}

<script src="{$_config.manager_url}min/index.php?g=coreJs1" type="text/javascript"></script> <script src="{$_config.manager_url}min/index.php?g=coreJs2" type="text/javascript"></script> <script src="{$_config.manager_url}min/index.php?g=coreJs3" type="text/javascript"></script>

{/if}

Strangly I never encountered this before, but the bug is gone and all works fine again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThe issue in the code or project, which should be addressed.type-frontendIssues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions