Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback for keepalive js #16452

Merged
merged 7 commits into from Jun 13, 2017
Merged

Fallback for keepalive js #16452

merged 7 commits into from Jun 13, 2017

Conversation

andrepereiradasilva
Copy link
Contributor

@andrepereiradasilva andrepereiradasilva commented Jun 2, 2017

Pull Request for Issue #16375 (only keepalive fallback part).

Summary of Changes

The keepalive js fallback is not working correctly when there is no system.keepalive json. This PR intends to add better fallback for those wild scenarios.

Testing Instructions

Pre-requisites:

  • Use latest joomla staging with a login module in the frontend (so keepalive is called)
  • In global config set joomla session to 1 minute (for faster test) and System Cache to "ON - Progressive caching"

Reproducing the issue:

  • Clear joomla cache
  • Go to frontend - not logged, reload the page two times (Ctrl+F5)
  • Confirm there is a js error in the Chrome Debug Console "Console" tab (F12)

Test if proposed keepalive fallback works:

  • Apply patch Fix initial call of Joomla.loadOptions() #16488 (if not merged) and them this patch
  • Repeat steps in "Reproducing the issue", but now confirm there is no js error in the Chrome Debug Console "Console" tab (F12)
  • Wait one minute and also confirm keepalive in called correctly in Chrome Debug Console "Network" tab

Expected result

Keepalive should always work even if there is no system.keepalive json.

Actual result

Keepalive does not work in this scenario because of a js error.

Documentation Changes Required

@dgt41 @Fedik can you also check this one and confirm there is no problem in adding the joomla install uri paths trough script options in behavior.core, ie, all the pages that use the core bahaviour (this would also be used in #15529).

@Fedik
Copy link
Member

Fedik commented Jun 3, 2017

@andrepereiradasilva I did not tested, but looks good to me

keepaliveInterval = keepaliveOptions && keepaliveOptions.interval ? keepaliveOptions.interval : 45 * 1000;

// Fallback in case no keepalive uri was found.
if (keepaliveUri === '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check only for empty string, for check all "false" cases use if (!keepaliveUri)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but i want to strict check for empty string :) see above

keepaliveUri      = keepaliveOptions && keepaliveOptions.uri ? keepaliveOptions.uri.replace(/&/g, '&') : '',

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay 😉

@dgrammatiko
Copy link
Contributor

@Fedik can you also update the spinning logo to move this code instead of the data-attr (#15529)?

@@ -88,6 +88,10 @@ public static function core()
}

JHtml::_('script', 'system/core.js', array('version' => 'auto', 'relative' => true));

// Add core paths so javascript can have the root path.
JFactory::getDocument()->addScriptOptions('system.paths', array('root' => JUri::root(true), 'base', JUri::base(true)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to 'base' => JUri::base(true)?

@Quy
Copy link
Contributor

Quy commented Jun 3, 2017

After PR, I still get a js error:

Uncaught TypeError: Cannot read property 'system.keepalive' of null
    at Object.e.getOptions (core.js?449d852…:1)
    at HTMLDocument.<anonymous> (keepalive.js?449d852…:1)

@Fedik
Copy link
Member

Fedik commented Jun 3, 2017

@andrepereiradasilva I guess there still bug with Joomla.loadOptions

there

if (!Joomla.optionsStorage) {
  Joomla.optionsStorage = options;
}

need to be:

if (!Joomla.optionsStorage) {
  Joomla.optionsStorage = options || {};
}

Can you add it here or I do new PR?

@dgt41 I thought that is your PR 😉
we can update, after this one will be merged

@Fedik
Copy link
Member

Fedik commented Jun 3, 2017

another strange thing,
with this patch, if cache is enabled, the core.js loaded but there no any <script type="application/json" class="joomla-script-options"> in the head.
maybe it somehow related to JCache::set(get)Workarounds ?

upd. debug off, and only on "Progressive caching"

@andrepereiradasilva
Copy link
Contributor Author

andrepereiradasilva commented Jun 3, 2017

@Fedik

Can you add it here or I do new PR?

please do a PR i prefer you do that Joomla.optionsStorage part - i will test it so it can be RTC and merged fast (hope @dgt41 tests it too 😄 )
this one stays in standby until your is merged

another strange thing,
with this patch, if cache is enabled, the core.js loaded but there no any <script type="application/json" class="joomla-script-options"> in the head.
maybe it somehow related to JCache::set(get)Workarounds ?

that is the first problem of the issue that originated this PR see #16375 (comment)
But that's another issue not related to js.

@Fedik
Copy link
Member

Fedik commented Jun 3, 2017

@andrepereiradasilva there is pull #16488 😉
which should fix:

Uncaught TypeError: Cannot read property 'system.keepalive' of null
    at Object.e.getOptions (core.js?449d852…:1)
    at HTMLDocument.<anonymous> (keepalive.js?449d852…:1)

Current pull should work after #16488

@andrepereiradasilva
Copy link
Contributor Author

yeah this work after #16488 applied

@Quy
Copy link
Contributor

Quy commented Jun 3, 2017

I am still getting the js error after both PRs are applied in the frontend.

Uncaught TypeError: Cannot read property 'system.keepalive' of null
    at Object.Joomla.getOptions (core.js?cf50a49…:1)
    at HTMLDocument.<anonymous> (keepalive.js?cf50a49…:1)

@andrepereiradasilva
Copy link
Contributor Author

andrepereiradasilva commented Jun 3, 2017

@Quy did you refresh the js cache?

UPDATE: Forget it i'm seing it also

@andrepereiradasilva
Copy link
Contributor Author

@Quy : @Fedik solved the issue in the other PR, should be fine now

@Quy
Copy link
Contributor

Quy commented Jun 3, 2017

I have tested this item ✅ successfully on 80d499b


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

@Fedik
Copy link
Member

Fedik commented Jun 3, 2017

I have tested this item ✅ successfully on 80d499b

works as described, with #16488


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

@ghost
Copy link

ghost commented Jun 3, 2017

RTC after two successful tests.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jun 3, 2017
@rdeutz rdeutz merged commit 9c36589 into joomla:staging Jun 13, 2017
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jun 13, 2017
@rdeutz rdeutz added this to the Joomla 3.7.3 milestone Jun 13, 2017
@andrepereiradasilva andrepereiradasilva deleted the patch-20 branch June 13, 2017 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants