[SOLVED] Pagination problem with cache (Virtuemart 2.0.8 - 2.0.14)

Started by usovdm, November 29, 2012, 09:59:09 AM

Previous topic - Next topic

usovdm

Virtuemart 2.0.14.
How test a problem:
0. include standard caching
1. clear a cache
2. come on the 1st page of category 1
3. come on the 1st page of category 2
4. come on the 2nd page of categories 2
5. come on the 1st page of category 1
6. try to come on the 2nd page of category 1, but see on the 1st

usovdm

VirtueMartControllerCategory - /components/com_virtuemart/contoller/category.php
VirtuemartViewCategory - /components/com_virtuemart/views/category/view.html.php

1. clear a cache
2. come on the 1st page of category 1 (id = 1)
   input: LastVisitedCategoryId input = 0
   page isn't in a cache, therefore VirtueMartControllerCategory::display -> VirtuemartViewCategory::display. Result of execution of VirtuemartViewCategory::display save into a cache.
   in VirtuemartViewCategory::display is followed specifying LastVisitedCategoryId function.
   output: LastVisitedCategoryId output = 1

3. come on the 1st page of category 2 (id = 2)
   input: LastVisitedCategoryId input = 1
   page isn't in a cache, therefore VirtueMartControllerCategory::display -> VirtuemartViewCategory::display. Result of execution of VirtuemartViewCategory::display save into a cache.
   output: LastVisitedCategoryId output = 2

4. come on the 2nd page of categories 2
   input: LastVisitedCategoryId input = 2
   page isn't in a cache, therefore VirtueMartControllerCategory::display -> VirtuemartViewCategory::display. Result of execution of VirtuemartViewCategory::display save into a cache.
   output: LastVisitedCategoryId output = 2

5. come on the 1st page of category 1
   input: LastVisitedCategoryId input = 2
   page is IN a cache, therefore VirtueMartControllerCategory::display -> take from a cache result of VirtuemartViewCategory::display (doesn't execute it). Doesn't changes of LastVisitedCategoryId.
   output: LastVisitedCategoryId output = 2

6. try to come on the 2nd page of category 1, but get on the 1st
   input: LastVisitedCategoryId input = 2
   page isn't in a cache, therefore VirtueMartControllerCategory::display -> VirtuemartViewCategory::display. Since LastVisitedCategoryId doesn't correspond to really open category, throws on the 1st page and result of execution with the wrong navigation of VirtuemartViewCategory::display save into a cache.
   output: LastVisitedCategoryId output = 1 (if the page wasn't cached, on an output have the correct LastVisitedCategoryId therefore for example the 3rd page already fulfills correctly (not for long))

Candidate solution:
Since the controler isn't cached, in / components/com_virtuemart/contoller/category.php at the end of "function display" to add setLastVisitedCategoryId:

public function display($cachable = false, $urlparams = false)  {
if (JRequest::getvar('search')) {
$view = $this->getView('category', 'html');
$view->display();
} else {
// Display it all
$safeurlparams = array('virtuemart_category_id'=>'INT','virtuemart_manufacturer_id'=>'INT','virtuemart_currency_id'=>'INT','return'=>'BASE64','lang'=>'CMD','orderby'=>'CMD','limitstart'=>'CMD','order'=>'CMD','limit'=>'CMD');
parent::display(true, $safeurlparams);
}
if($categoryId = JRequest::getInt('virtuemart_category_id',0)){
shopFunctionsF::setLastVisitedCategoryId($categoryId);
}
}

Milbo

Thank you very much Usov,

clear explanation and correctly researched. The answer looks very useful, so I add this to vm2.0 and vm2.1
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

zstep

I'm using VM 2.0.24 with Joomla 2.5.9 but still have the same problem as mentioned here when a page cache is enabled.
I have to use JotCache with disabled category view caching now.
Does Virtuemart support whole page caching or not? Is someone experiencing the same problem?

szbstvn

My problem is same ...

VM 2.0.24 with jotcache


Küldve az én iPad-ről Tapatalk HD használatával