? ? Success

User tests: Successful: Unsuccessful:

avatar andrepereiradasilva
andrepereiradasilva
26 Nov 2015

Description

This PR moves inline keepalive js script to a external keepalive.js file.
Also now uses JRoute to remove the redirect from com_ajax URI call when using sef.

How to test

  1. Use Joomla 3.7.x branch
  2. Install patch #11289 and then this patch.
  3. See if from time to time (defined session in global config - put 1 for faster) the keepalive URI is called in frontend and in the backend.

B/C

None that i know of.

43a7ffd 26 Nov 2015 avatar cs
avatar andrepereiradasilva andrepereiradasilva - open - 26 Nov 2015
avatar andrepereiradasilva andrepereiradasilva - change - 26 Nov 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Nov 2015
Labels Added: ?
f49719c 26 Nov 2015 avatar cs
avatar andrepereiradasilva andrepereiradasilva - change - 27 Nov 2015
The description was changed
avatar dgt41 dgt41 - test_item - 27 Nov 2015 - Tested successfully
avatar dgt41
dgt41 - comment - 27 Nov 2015

I have tested this item :white_check_mark: successfully on 5199006


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

avatar dgt41
dgt41 - comment - 27 Nov 2015

Works great!
Thanks @andrepereiradasilva for doing this!
screen shot 2015-11-27 at 15 05 46


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

avatar joomla-cms-bot
joomla-cms-bot - comment - 27 Nov 2015

This PR has received new commits.

CC: @dgt41


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

avatar andrepereiradasilva
andrepereiradasilva - comment - 27 Nov 2015

I detected a problem with the double entities in '&' in admin keepalive.
GET /administrator/index.php?option=com_ajax&format=json 404

Solved

@dgt41 Can you retest when you have time?

avatar Fedik
Fedik - comment - 28 Nov 2015
  • this PR introduce jQuery dependency (while it can work fine without jQuery) , so now Joomla need to load 4 files instead of one line of the inline code ... btw, framework dependancy was removed in #3376, so it some kind of regression to me
  • I do not see any profit from forcing JSON as data- value, for just 2 variable ... it can work fine with data-interval data-url (or around), and it more "readable" in output, that means more easy to debug
avatar dgt41
dgt41 - comment - 28 Nov 2015

@Fedik @andrepereiradasilva for the onload event we could use something like:

document.attachEvent("onreadystatechange", function(){
  if (document.readyState === "complete"){
    document.detachEvent( "onreadystatechange", arguments.callee );
    // code ...
  }
});

which is plain js, so no jQuery dependency

avatar Fedik
Fedik - comment - 28 Nov 2015

attachEvent is IE :smile:

(function(w){
  'use strict';
  var modern = !!w.addEventListener,
        event = modern ? 'load', 'onload';
   w[modern ? 'addEventListener' : 'attachEvent'](event, function(){
     // your code here
   })
})(window);
avatar andrepereiradasilva
andrepereiradasilva - comment - 28 Nov 2015

@Fedik @dgt41

this PR introduce jQuery dependency (while it can work fine without jQuery) , so now Joomla need to load 4 files instead of one line of the inline code ... btw, framework dependancy was removed in #3376, so it some kind of regression to me

Ok, so in your view the js in core should be vanilla js?
Or at least, when possible, reduce the dependencie from js frameworks?
I can identify with that.
I'm asking that because if you look at behavior.php you will see a lot of jQuery usage.

I do not see any profit from forcing JSON as data- value, for just 2 variable ... it can work fine with data-interval data-url (or around), and it more "readable" in output, that means more easy to debug

Yes it's more readable, i didn't like either the html entities in the HTML code.
So should we always use data-* attributes without json in core js, except when there is a lot o variables?

I will introduce the changes needed when i have time.

avatar Fedik
Fedik - comment - 28 Nov 2015

Use of jQuery is fine, but if the code already independent form the framework, then beter keep it in this way, when it is possible. I think.
Example core.js independent from any framework now.

I'm asking that because if you look at behavior.php you will see a lot of jQuery usage.

Mainly it depend from people who wrote that scripts :wink:

So should we always use data-* attributes without json in core js, except when there is a lot o variables?

Personally, I would do like this, yes.

avatar joomla-cms-bot
joomla-cms-bot - comment - 28 Nov 2015

This PR has received new commits.

CC: @dgt41


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

avatar andrepereiradasilva
andrepereiradasilva - comment - 28 Nov 2015

@dgt41 @Fedik
Check now:

  • Uses vanilla js (no js framework dependency)
  • Cross-browser compatible
  • Works even if onload event is already fired when script is loaded (this way the js file can be loaded on render, asyncronous or defered to after the onload event).
avatar Fedik
Fedik - comment - 28 Nov 2015

Looks good, thanks!
One more request:
Now all variables in the global scope, can you please wrap it into anonymous function, and use strict mode:

!(function(window){
  'use strict';

   // your code here
})(window);
avatar joomla-cms-bot
joomla-cms-bot - comment - 28 Nov 2015

This PR has received new commits.

CC: @dgt41


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

avatar andrepereiradasilva
andrepereiradasilva - comment - 28 Nov 2015

@Fedik ok now i think it's done.
Also improved keepalive behaviour.php code to be more readable and work with other session handlers (memcache, redis, etc).

a056ee7 28 Nov 2015 avatar cs
avatar joomla-cms-bot
joomla-cms-bot - comment - 28 Nov 2015

This PR has received new commits.

CC: @dgt41


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

avatar Fedik
Fedik - comment - 28 Nov 2015

... and work with other session handlers (memcache, redis, etc)

Please do not change this, it breaks thing that was fixed in #7363, and return issue #6730 back to life

Something for concern.
I think this Pull request bring potential backward compatibility problem (and just a problem) for extensions which merge the scripts, for optimization. As they ignore any custom attribute, the current keepalive code will be broken after merging keepalive.js with other JavaScript files to a single file.
This also means that all scripts that will use costume attributes by #8540 could be broken in this case :speak_no_evil:
hmm...

avatar andrepereiradasilva
andrepereiradasilva - comment - 28 Nov 2015

Please do not change this, it breaks thing that was fixed in #7363, and return issue #6730 back to life

I'm sorry but you are saying that if we use session handler 'none' Joomla will use the PHP.ini session value without changing the session time to the defined in the global config?
I think is not the way it works. I think Joomla uses ini_set to change the php session timeout value when set to handler is set to 'None'.
But i did the test and i didn't confirm your issue. I did this:

  • Set the session time to 1 minute in php ini session.gc_maxlifetime = 60
  • restart php
  • Set the session time to 2 minutes in global config and 'None' as handler ('None' should really be called 'Default PHP Handler' or something like that)
  • Go to an article edit in administrator and wait 3 minutes.
  • Refresh page, you'll see you are still logged.

Something for concern.
I think this Pull request bring potential backward compatibility problem (and just a problem) for extensions which merge the scripts, for optimization. As they ignore any custom attribute, the current keepalive code will be broken after merging keepalive.js with other JavaScript files to a single file.
This also means that all scripts that will use costume attributes by #8540 could be broken in this case :speak_no_evil:
hmm...

True, but it's not a Joomla B/C problem, those extension can be improved to check the script tag has other attributes and use it. But we also could use a default value in the js in the case no attribute is found in the script tag (e.g. 1 minute interval, and index.php as URI) to reduce potencial problems.
We can also run tests with some of those extensions.

avatar dgt41
dgt41 - comment - 28 Nov 2015

@andrepereiradasilva I think you should rename/move the scripts to media/jui/js/keepalive.js (uncompressed) and media/jui/js/keepalive.min.js (compressed). The -uncompressed option comes from the dark ages of mootools, modern scripts follow the other paradigm. Also since the script will be introduced first time is better to store it to jui folder...

avatar joomla-cms-bot
joomla-cms-bot - comment - 28 Nov 2015

This PR has received new commits.

CC: @dgt41


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

avatar mbabker
mbabker - comment - 28 Nov 2015

"jui" mostly has stuff related to Bootstrap and that effort, "system" at
one point was mostly Joomla's core JavaScript API. Probably best to clean
that all up at one point, but the system folder was fine.

On Saturday, November 28, 2015, Dimitri Grammatikogianni <
notifications@github.com> wrote:

@andrepereiradasilva https://github.com/andrepereiradasilva I think you
should rename/move the scripts to media/jui/js/keepalive.js (uncompressed)
and media/jui/js/keepalive.min.js (compressed). The -uncompressed option
comes from the dark ages of mootools, modern scripts follow the other
paradigm. Also since the script will be introduced first time is better to
store it to jui folder...

—
Reply to this email directly or view it on GitHub
#8545 (comment).

avatar dgt41
dgt41 - comment - 28 Nov 2015

@mbabker jui refers to ui/ux staff and I think this fits better there, anyhow I agree that these two folders need some cleanup...

avatar Fedik
Fedik - comment - 28 Nov 2015

But i did the test and i didn't confirm your issue.

ok, maybe it has been fixed in Session for Joomla 3.5

avatar anibalsanchez anibalsanchez - test_item - 2 Dec 2015 - Tested successfully
avatar anibalsanchez
anibalsanchez - comment - 2 Dec 2015

I have tested this item :white_check_mark: successfully on 290c439

Test OK


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

avatar brianteeman brianteeman - change - 12 Dec 2015
Category JavaScript
avatar Ruchiranga Ruchiranga - test_item - 3 Jul 2016 - Tested successfully
avatar Ruchiranga
Ruchiranga - comment - 3 Jul 2016

I have tested this item ✅ successfully on 290c439

HTML code
HTML

The external js file
JS

Tweaked the code to trigger calling URI every 10 seconds and it works.
Call


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

avatar joomla-cms-bot joomla-cms-bot - change - 28 Jul 2016
Category JavaScript Libraries
avatar andrepereiradasilva andrepereiradasilva - change - 28 Jul 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 28 Jul 2016
avatar andrepereiradasilva
andrepereiradasilva - comment - 28 Jul 2016

add to make a small change in JHtml script call since the PR that adds script attibutes in now other (#11289).

just this changed 235afcd

avatar wmchris wmchris - test_item - 1 Aug 2016 - Tested successfully
avatar wmchris
wmchris - comment - 1 Aug 2016

I have tested this item ✅ successfully on 235afcd

Works like a charm @icampus


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

avatar schmidtpaddy schmidtpaddy - test_item - 1 Aug 2016 - Tested successfully
avatar schmidtpaddy
schmidtpaddy - comment - 1 Aug 2016

I have tested this item ✅ successfully on 235afcd

it works @icampus


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

avatar roland-d roland-d - change - 2 Aug 2016
Status Pending Ready to Commit
avatar roland-d
roland-d - comment - 2 Aug 2016

RTC as we have 2 successful tests


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

avatar joomla-cms-bot joomla-cms-bot - change - 2 Aug 2016
Labels Added: ?
avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Aug 2016

mantainers, just a remainder: this CANNOT be merged without #11289 being merged.

avatar roland-d
roland-d - comment - 2 Aug 2016

@andrepereiradasilva How come a PR from last year is depending on a PR from 9 days ago?

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Aug 2016

"it's a kind of magic" ?

kidding aside, i replaced my old PR for that one recently (you can see that if you read the comments there)

avatar roland-d
roland-d - comment - 2 Aug 2016

@andrepereiradasilva A magician too...is there anything you can't do :)

I see now, thanks for the explanation.

avatar joomla-cms-bot joomla-cms-bot - change - 21 Aug 2016
Category Libraries Libraries JavaScript
avatar andrepereiradasilva andrepereiradasilva - change - 21 Aug 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 21 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - edited - 21 Aug 2016
avatar andrepereiradasilva andrepereiradasilva - change - 21 Aug 2016
The description was changed
avatar rdeutz
rdeutz - comment - 1 Oct 2016

@could you have a look at the conflicts/problems and resolve them, thanks!

avatar andrepereiradasilva andrepereiradasilva - change - 2 Oct 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 2 Oct 2016
avatar joomla-cms-bot joomla-cms-bot - change - 2 Oct 2016
Labels Added: ? ?
avatar joomla-cms-bot joomla-cms-bot - change - 2 Oct 2016
Category Libraries JavaScript Libraries JavaScript Unit Tests
avatar andrepereiradasilva andrepereiradasilva - change - 2 Oct 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - change - 2 Oct 2016
The description was changed
avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Oct 2016

fixed conflicts and reviweed code to use the new 3.7.x methods (JDocument::addScriptOptions and js Joomla.request)

avatar zero-24 zero-24 - close - 2 Oct 2016
avatar zero-24 zero-24 - close - 2 Oct 2016
avatar rdeutz rdeutz - change - 2 Oct 2016
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-10-02 16:52:15
Closed_By rdeutz
avatar rdeutz rdeutz - close - 2 Oct 2016
avatar rdeutz rdeutz - merge - 2 Oct 2016
avatar zero-24 zero-24 - change - 2 Oct 2016
Labels Removed: ? ?
avatar zero-24
zero-24 - comment - 3 Oct 2016

@andrepereiradasilva can this work without #11289 ?

avatar andrepereiradasilva
andrepereiradasilva - comment - 3 Oct 2016

well ... yes and no. it works, except in IE8 since the JHtmlBehaviour polyfill needs #11289

avatar Fedik
Fedik - comment - 3 Oct 2016

hm, but why we need polyfill here? ?

it can work very well without document.addEventListener('DOMContentLoaded', function() {}) after you have changed code to use Joomla.getOptions('system.keepalive') ?

avatar andrepereiradasilva
andrepereiradasilva - comment - 3 Oct 2016

this code already uses Joomla.getOptions('system.keepalive')

I prefer to have sure that the content is already loaded so we can defer js processing to after dom ready.

but if you can do it without polyfill, please make a PR to change that ? .

Add a Comment

Login with GitHub to post a comment