The Joomla! Forum ™



Forum rules


Please use the official Bug Tracker to report a bug: http://joomlacode.org/gf/project/joomla ... er_id=8103



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Dec 15, 2011 10:29 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Oct 30, 2008 7:27 pm
Posts: 149
Description:

If you cache modules then the cache of those modules will include all custom head elements (ie, elements added via addCustomTag()), even if they aren't associated with that module. This will then cause those custom head elements to be added to other pages inappropriately.

Here is what let me to this:

After clearing my site's cache and loading an article, then a second article, that second article has some of the head elements that belonged to the first article (when viewing the source). If I visit a third article then that article will have some of the head elements from both the first and the second article.

Turning off cache makes the issue go away. This happens from both Conservative caching and Progressive caching.

When I looked through the files in my /cache/ folder I discovered the extra head elements that were being added were all part of module cache files (files in "/cache/mod_custom/" for example). Turning off caching for all modules (via the modules' Advanced Options parameters) also makes the issue go away.

I then researched why modules were storing head elements that had nothing to do with that module (eg, a mod_custom module's cache was storing addCustomTag() elements from a content plug-in). I found in:

/libraries/joomla/application/module/helper.php -> moduleCache() :

line 420:
Code:
      $wrkaroundoptions = array (
         'nopathway'    => 1,
         'nohead'       => 0,
         'nomodules'    => 1,
         'modulemode'    => 1,
         'mergehead'    => 1
      );


The 'nohead'=>0 and 'modulemode' => 1 option causes Joomla to cache the custom head elements with every module cache (nohead=0 would cause it to cache all head elements but modulemode=1 unsets stuff like the title, description, links, etc). You can see where this happens here:

/libraries/joomla/cache/cache.php -> setWorkarounds()

line 529:
Code:
      if ($loptions['nohead'] != 1) {
         $cached['head'] = $document->getHeadData();

         if ($loptions['modulemode'] == 1) {
               unset($cached['head']['title']);
               unset($cached['head']['description']);
               unset($cached['head']['link']);
               unset($cached['head']['links']);
               unset($cached['head']['metaTags']);
         }
      }


Notice that $cached['head']['style'], $cached['head']['scripts'], $cached['head']['custom'] and a few others are not unset for modules. If it's not unset, it gets added to the module's cache file.

When that module's cache is read (when another page is loaded) the 'mergehead'=>1 causes the cached custom head elements from the module to be added to the page's head (de-dupping any identical elements). Therefore, changing 'nohead'=>0 to 'nohead'=>1 causes this issue to go away. This is isn't a solution though, because this would cause fatal issues for any module that's use custom head elements (I didn't test this statement it though).

Am I right in seeing this as a bug or am I missing something? For now I have turned off cache for all modules.


Reported on:
Joomla! 1.7.3 Stable [ Ember ] 14-Nov-2011 14:00 GMT
Platform 11.2.0 Stable+Modified [ Omar ] 27-Jul-2011 00:00 GMT

Affected functions:
Module Caching

Related files:
/libraries/joomla/application/module/helper.php
/libraries/joomla/cache/cache.php
/libraries/joomla/document/html/html.php


Top
 Profile  
 
PostPosted: Sun Dec 25, 2011 6:52 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Fri Aug 12, 2005 3:47 pm
Posts: 16630
Location: **Translation Matters**
Please post your findings here:
http://joomlacode.org/gf/project/joomla ... m_id=27503

_________________
Jean-Marie Simonet / infograf · http://www.info-graf.fr
Multilanguage in 2.5: http://help.joomla.org/files/EN-GB_multilang_tutorial.pdf
---------------------------------
Joomla Translation Coordination Team • Joomla! Production Working Group


Top
 Profile  
 
PostPosted: Tue Dec 27, 2011 7:30 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Oct 30, 2008 7:27 pm
Posts: 149
infograf768 wrote:


Done.

It was suggested that this was ultimately a Joomla Platform issue and should be brought up on that tracker system. The ticket can be found here: https://github.com/joomla/joomla-platform/issues/675


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 



Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group