?
avatar vagari
vagari
19 Jul 2016

Steps to reproduce the issue

  1. Install Joomla
  2. Create Contact in admin
  3. Add "Contact Us" page menu item, single contact, that references created contact
  4. Install betweenbrain/Custom-Contact-Form-Plugin - Amphenol Sensors branch (this is what's in production/tested)
  5. Turn on Conservative Caching
  6. Visit Contact Us page on front end

Expected result

Small Javascript file is included in the header. If that file is updated to point at the correct form fields (the version on GitHub has generic #country & #state IDs) it will populate the state drop down when either United States or Canada is selected int he country drop down.

Actual result

With Conservative Caching enabled the Javascript is loaded the first time the page is accessed and it disappears on subsequent visits. At least until the cache expires or is cleared, then it appears a single time again.

System information (as much as possible)

Linux
Database Version 5.5.50
PHP Version 5.6.23
Web Server Apache
WebServer to PHP Interface apache2handler
Joomla! Version Joomla! 3.6.0 Stable

Additional comments

Plugin worked correctly until 3.5 was installed.

The plugin can be found on GitHub. The Amphenol Sensors branch was written for me, developer hasn't worked with Joomla for a while so didn't know of a solution.

Currently I have Conservative Caching disabled. And we're using the Plugin - System - Page Cache based on a workaround discussed on Stack Overflow.

I've also tried some variations on when/how the Javascript file is included without success. Things like using JHTML::script instead of ->addScript. And other execution times besides onBeforeRender.

To rule out something else on the production site I sucessfully reproduced the issue on a clean install of Joomla 3.6.

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
3.00

avatar vagari vagari - open - 19 Jul 2016
avatar csthomas
csthomas - comment - 19 Jul 2016

Did you move:

$this->doc->addScript(JURI::base(true) . '/media/plg_customcontactform/js/form-actions.min.js');

to method onContentPrepareForm

avatar vagari
vagari - comment - 19 Jul 2016

Hi @csthomas, Are you asking if I attempted that? I did try that but it migrated the Javascript to the beginning of the "chain," before anything else, including jQuery, was loaded. Which fixed the cache issue, but broke the actual Javascript.

avatar csthomas
csthomas - comment - 19 Jul 2016

Yes, I updated my question.

Then add jquery before that line.

IMHO this is not joomla bug.
You should go to forum.joomla.org if you can not resolve it yourself.

If you use something that requires jquery then you have to load jquery before (ex. line before).
This will change "chain".

avatar vagari
vagari - comment - 20 Jul 2016

Fair enough. I understand the concept. Migrating the script to onContentPrepareForm from onBeforeRender and including the JHtml::_('jquery.framework') solves the caching issue. (Though it does still places the included file above a bunch of other JavaScript so it might not work for all situations). And it may not be a bug in the proper sense, but considering many plugins use onBeforeRender, (and I've seen it in tutorials) I'm still surprised at the outcome. Is there an actual reason (apparently undocumented) that caching does not work in this scenario.

TL:DR I'd still consider this a workaround as opposed to a fix at this juncture.

avatar vagari
vagari - comment - 20 Jul 2016

Oh, and to reiterate from my original post, the way the plugin was written functioned correctly before the release of Joomla 3.5.

avatar csthomas
csthomas - comment - 20 Jul 2016

Try something direct instead JHtml::_('jquery.framework')
$doc->addScript...

avatar vagari
vagari - comment - 20 Jul 2016

Are you saying, instead of referencing the jQuery framework via JHtml, use an explicit addScript to add jQuery?

avatar csthomas
csthomas - comment - 20 Jul 2016

yes, there may be bug with caching but I can not confirm now.

avatar brianteeman brianteeman - change - 20 Jul 2016
Category Cache
avatar brianteeman brianteeman - change - 21 Jul 2016
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 21 Jul 2016
The description was changed
avatar joomla-cms-bot joomla-cms-bot - edited - 21 Jul 2016
avatar franz-wohlkoenig franz-wohlkoenig - change - 6 Apr 2017
Status New Needs Review
avatar weeblr
weeblr - comment - 3 Jun 2017

Looking into this #jab17


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

avatar andrepereiradasilva
andrepereiradasilva - comment - 3 Jun 2017

further info that may be related: see also #16375 (comment) reggarding modules and conservative caching

avatar weeblr
weeblr - comment - 3 Jun 2017

Hi all,

This is happening because when Caching is set to "Conservative", the component output is fetched from the cache, meaning any code from view.html.php is not executed. This includes the:

JPluginHelper::importPlugin('content');

instructions. This plugin is a content plugin, and except on 1st page load, it's simply not loaded. Therefore it onBeforeRender handler is not registered and not executed.

I would think a content plugin should be allowed to insert js/css into the page head section and so content plugins should also be loaded when conservative caching is enabled. Not been able to pinpoint when this was changed around 3.5 release.

/cc @csthomas @mbabker @nibra


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

avatar mbabker
mbabker - comment - 3 Jun 2017

Maybe we have the app ensure content plugins are imported before onAfterDispatch is dispatched?

avatar weeblr
weeblr - comment - 3 Jun 2017

Actually it's enough to move the plugin loading to the content controller vs in each individual per view view.html.php, as it is today. I have confirmed that.


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

avatar nibra
nibra - comment - 6 Jun 2017

Added information to documentation, closing this issue.


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

avatar nibra nibra - change - 6 Jun 2017
The description was changed
Status Needs Review Closed
Closed_Date 0000-00-00 00:00:00 2017-06-06 18:58:59
Closed_By nibra
avatar joomla-cms-bot joomla-cms-bot - edited - 6 Jun 2017
avatar joomla-cms-bot joomla-cms-bot - change - 6 Jun 2017
The description was changed
Closed_By nibra joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 6 Jun 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 6 Jun 2017

Set to "closed" on behalf of @nibra by The JTracker Application at issues.joomla.org/joomla-cms/11203

avatar andrepereiradasilva
andrepereiradasilva - comment - 6 Jun 2017

@nibra so if i understand properly this one #16375 is the same issuie and can also be closed with the same motive?

avatar nibra
nibra - comment - 6 Jun 2017

Seems to be the same issue, yes.Although the PR for that other issue touches different apects.

Add a Comment

Login with GitHub to post a comment