No Code Attached Yet J3 Issue
avatar n3t
n3t
30 May 2017

Steps to reproduce the issue

  • enable cache - progressive caching in Global configuration
  • Create new contact in com_contact, add an email, enable contact form
  • open JS console, to see errors
  • go to frontend, open the contact form
  • refresh the page for second time

Expected result

  • no JS error

Actual result

  • upon firs load, everything is OK
  • upon second load JS error appears
    keepalive.js…:1 Uncaught TypeError: Cannot read property 'uri' of undefined

System information (as much as possible)

  • Joomla Fresh installation 3.7.2
  • Protostar template

Additional comments

  • if you see the html, upon first call there is line
    <script type="application/json" class="joomla-script-options new">{"system.keepalive":{"interval":840000,"uri":"\/index.php\/en\/component\/ajax\/?format=json"},"joomla.jtext":{"JLIB_FORM_FIELD_INVALID":"Invalid field:&#160"}}</script>
  • upon second load is limited to
    <script type="application/json" class="joomla-script-options new">{"joomla.jtext":{"JLIB_FORM_FIELD_INVALID":"Invalid field:&#160"}}</script>
avatar n3t n3t - open - 30 May 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 30 May 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 31 May 2017
Category com_cache JavaScript
avatar Melvine9
Melvine9 - comment - 2 Jun 2017

Hello,

I have the same issue.
Make click right on the window and show source. This give me the same lines

<script type="application/json" class="joomla-script-options new">{"system.keepalive":{"interval":1740000,"uri":"\/index.php?option=com_ajax&amp;format=json"},"joomla.jtext":{"JLIB_FORM_FIELD_INVALID":"Champ invalide&#160;:&#160;"}}</script>

and cause some issue with dropeditor ( lines above)

php 7.1.5
Joomla 3.7.2
picture

Best Regards
Melvine

avatar franz-wohlkoenig franz-wohlkoenig - change - 2 Jun 2017
Status New Confirmed
avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Jun 2017

Issue confirmed:

  • Use latest joomla staging
  • Global config: System Cache = ON - Progressive caching
  • Go to frontend - not logged, view source, the keepalive code is there
  • Refresh page, view source, the keepalive json code is not there (there is no json at all)

Further info: seems JHtml::_('behavior.keepalive'); (that introduces that code) is not called in progressive cache mode (in no cache mode or conservative caching works).
In my case the keepalive was called by mod_login (the login box module)

A workaround is to disable progressive caching, but yes, confirmed the issue also.

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Jun 2017

Ok, so IMO there are two sides of this issue:

  1. The JHtml::_('behavior.keepalive'); inside the mod_login template file is not being processed when cache in conservative mode.
  2. The keepalive js should not give error and always fallback to a default value in case of no json system.keepalive config.

Proposed a PR to try to solve "2." #16452 - please test.

Reggarding "1." have no idea - maybe someone that understands better the cache system can help.

avatar Melvine9
Melvine9 - comment - 2 Jun 2017

Thank you very much, I will try

avatar franz-wohlkoenig franz-wohlkoenig - change - 3 Jun 2017
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2017-06-03 04:32:42
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - close - 3 Jun 2017
avatar joomla-cms-bot joomla-cms-bot - close - 3 Jun 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 3 Jun 2017

closed as having PR #16452


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16375.

avatar joomla-cms-bot
joomla-cms-bot - comment - 3 Jun 2017
avatar andrepereiradasilva
andrepereiradasilva - comment - 3 Jun 2017

@franz-wohlkoenig the PR does not solve one part of the issue. Imho Should remain open until someone looks at the progressive cache issue

avatar franz-wohlkoenig franz-wohlkoenig - change - 3 Jun 2017
Status Closed Discussion
Closed_Date 2017-06-03 04:32:42
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 3 Jun 2017
Status Discussion New
Closed_Date 0000-00-00 00:00:00
avatar joomla-cms-bot joomla-cms-bot - reopen - 3 Jun 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 3 Jun 2017
avatar joomla-cms-bot joomla-cms-bot - reopen - 3 Jun 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 3 Jun 2017

reopened


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16375.

avatar andrepereiradasilva
andrepereiradasilva - comment - 3 Jun 2017

@franz-wohlkoenig maybe the cache issue is the same thing as #11203 but not sure

avatar franz-wohlkoenig franz-wohlkoenig - change - 4 Jun 2017
Status New Discussion
avatar n3t
n3t - comment - 7 Jun 2017

Generelly, is keepalive neccessary in frontend? For example in login form? Or in Contact form. It could compromise security, as for example in contact it will keep user logged in even he leaves computer...


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16375.

avatar andrepereiradasilva
andrepereiradasilva - comment - 7 Jun 2017

Keepalive is used in forms because of the crsf token check. Anyway this issue as describe above is not a keepalive issue. is the progressive cache that makes this behaviour

avatar weeblr
weeblr - comment - 7 Jun 2017

Hi

#11203 does not appear to me as the same thing:

  1. The fix does not apply anyway, as it applied to controller and views, which are not used in modules
  2. #11203 happens with conservative caching, while this one is with progressive. Progressive being supposed to be more agressive caching, this kind of side effect might happen. Would be good to confirm whether the same happens with only conservative caching enabled or not.
  3. Agree that this should not cause a JS error, error should be caught and properly displayed
  4. Maybe caching for such modules should simply be disabled by users when progressive caching is enabled?
avatar andrepereiradasilva
andrepereiradasilva - comment - 7 Jun 2017
  1. The fix does not apply anyway, as it applied to controller and views, which are not used in modules

Ok, my misunderstanding

  1. #11203 happens with conservative caching, while this one is with progressive. Progressive being supposed to be more agressive caching, this kind of side effect might happen. Would be good to confirm whether the same happens with only conservative caching enabled or not.

Only progressive cache.

  1. Agree that this should not cause a JS error, error should be caught and properly displayed

A PR was done to solve the keepalive js issue (better fallback), but since core.js is not loaded it can cause other js issues in other similiar situations.

  1. Maybe caching for such modules should simply be disabled by users when progressive caching is enabled?

Not sure, this in principle would apply to all modules in such situations, right?
Doesn't seem the solution would be disabling cache in all modules that load a behaviour that loads core.js. There must be something that prevents core.js from being loaded in this scenario.

avatar weeblr
weeblr - comment - 7 Jun 2017

Hi

There must be something that prevents core.js from being loaded in this scenario.

Yes, it's caching. If the module is cached, then its PHP code is not executed, and thus any instruction such as loading js, css or any other type of action is not executed at all. Note that the same probably happen if the module is supposed to record something in the database for instance.

So basically such a module is not compatible with being cached, which is why it should be disabled IMHO.

Rgds

avatar andrepereiradasilva
andrepereiradasilva - comment - 7 Jun 2017

Yes, it's caching. If the module is cached, then its PHP code is not executed, and thus any instruction such as loading js, css or any other type of action is not executed at all. Note that the same probably happen if the module is supposed to record something in the database for instance.

I don't understand how this conservative and progressive cache works (never used it), but if php code is not executed, why is keepalive.js rendered?
See https://github.com/joomla/joomla-cms/blob/staging/modules/mod_login/tmpl/default.php#L14

avatar weeblr
weeblr - comment - 7 Jun 2017

Most likely because keepalive is rendered as part of the HTML of the module, inlined. And so it's cached with the rest of the content.

avatar andrepereiradasilva
andrepereiradasilva - comment - 7 Jun 2017

is behavior.keepalive that calls for core.js to be rendered (see https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/html/behavior.php#L709)

avatar weeblr
weeblr - comment - 7 Jun 2017

yes, exactly. Because the PHP part is not executed, the core.js is not linked. But the keepalive settings

<script type="application/json" class="joomla-script-options new">{"joomla.jtext":{"JLIB_FORM_FIELD_INVALID":"Invalid field:&#160"}}</script>

are simply output as part of the HTML and are cached.

avatar andrepereiradasilva
andrepereiradasilva - comment - 7 Jun 2017

doesn't that part is rendered in the same place as the js scripts, ie, in JDocument head render?
See https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/document/renderer/html/head.php#L236

avatar weeblr
weeblr - comment - 7 Jun 2017

Yes, so maybe it's called by something else (the page itself, another module). But the problem is the wrong configuration snippet?
You would need to be able to reproduce on a standard install, and then step through code to know...

avatar brianteeman brianteeman - labeled - 25 Mar 2018
avatar stutteringp0et
stutteringp0et - comment - 17 Apr 2018

I just ran into this, and it affects more than just keepalive. Any script option I set in a content plugin is also lost.

avatar stutteringp0et
stutteringp0et - comment - 17 Apr 2018

Any script declaration I set remains with caching enabled.

avatar jwaisner jwaisner - change - 13 Mar 2020
Status Discussion Confirmed
avatar brianteeman
brianteeman - comment - 23 Aug 2022

Thank you for raising this issue.

Joomla 3 is now in security only mode with no further bug fixes or new features.

As this issue doesn't relate to Joomla 4 it will now been closed.

If we are mistaken and this does apply to Joomla 4 please open a new issue (and reference this one if you wish) with updated details for testing in Joomla 4.
cc @zero-24

avatar zero-24 zero-24 - change - 23 Aug 2022
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2022-08-23 13:48:26
Closed_By zero-24
Labels Added: No Code Attached Yet
Removed: ?
avatar zero-24 zero-24 - close - 23 Aug 2022

Add a Comment

Login with GitHub to post a comment