Author Topic: [SOLVED] Pagination problem with cache (Virtuemart 2.0.8 - 2.0.14)  (Read 4194 times)

usovdm

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 16
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

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 16
Re: Pagination problem with cache (Virtuemart 2.0.8 - 2.0.14)
« Reply #1 on: November 29, 2012, 10:05:33 am »
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:

Code: [Select]
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9997
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Pagination problem with cache (Virtuemart 2.0.8 - 2.0.14)
« Reply #2 on: November 29, 2012, 13:39:31 pm »
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
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

zstep

  • Beginner
  • *
  • Posts: 1
Re: [SOLVED] Pagination problem with cache (Virtuemart 2.0.8 - 2.0.14)
« Reply #3 on: October 28, 2013, 23:58:20 pm »
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

  • Beginner
  • *
  • Posts: 25
Re: [SOLVED] Pagination problem with cache (Virtuemart 2.0.8 - 2.0.14)
« Reply #4 on: November 03, 2013, 08:06:04 am »
My problem is same ...

VM 2.0.24 with jotcache


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