Author Topic: Category Cache Problem VM 3.0.8  (Read 13924 times)

micpic

  • Beginner
  • *
  • Posts: 2
  • A beginner
Category Cache Problem VM 3.0.8
« on: April 21, 2015, 09:48:58 am »
Hello,

we are new in VM and learn the last 14 days much of the functionality. But now we have a major Problem
for us.

If we generate a new category over the Administrator Backend we see the category in the Joomla VM BAckend
but it is dont visible in the frontend for any times.
We disable all of joomla abd Template cache and disable the cache in the VM category modul too.
After five minutes we can see our Category changes in the frontend

We work with the "GAVICK shop an Buy" VM Template

We check this Issue in the Joomla Beeze Templates too wit the same result. And yes we look into the forum and find many entrys for caching problems with VM, but never fix it
or we dont find it.

We are very glad you can see us a way to fix this problem.

System: Joomla 3.4.1
VM: 3.8.0
PHP: 5.4.29

Best Regards
Michael

 

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9648
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Category Cache Problem VM 3.0.8
« Reply #1 on: April 21, 2015, 10:10:23 am »
It isn't a problem as such - it is the way it works

caching of the cats gives a huge speed improvement to a client browsing

if you want to clear the cache after a cat change simply go -> Joomla admin->system->clear cache
you will see the vm cats cache - com_virtuemart_cats - delete
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

micpic

  • Beginner
  • *
  • Posts: 2
  • A beginner
Re: Category Cache Problem VM 3.0.8
« Reply #2 on: April 21, 2015, 10:31:25 am »
Oh no,

iam so sorry. we disabled all of cache functions into to system and this is the reason that we ar dont take a look into the system cache.

OK now we see VM is writing into the system cache anytime.

Many thanks for your fast help.

Michel

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4329
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Category Cache Problem VM 3.0.8
« Reply #3 on: April 21, 2015, 10:42:26 am »
it would be so simple to clear the know cache in the model when recording a category :
Code: [Select]
$conf = JFactory::getConfig();
$options = array(
'defaultgroup' => 'com_virtuemart_cats',
'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache');

$cache = JCache::getInstance('callback', $options);
$cache->clean();
// mod product
$options['defaultgroup'] = 'mod_virtuemart_product';
$cache = JCache::getInstance('callback', $options);
$cache->clean();
// mod category
$options['defaultgroup'] = 'mod_virtuemart_category';
$cache = JCache::getInstance('callback', $options);
$cache->clean();
But this must be approved by the main developer.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10040
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Category Cache Problem VM 3.0.8
« Reply #4 on: April 21, 2015, 11:05:42 am »
Patrick, you are really .... unbelievable.
Please stop the permanent accusations and bitching. It is really genioius to go in our config model and copy line 458-472. Constructive would be to provide a patch adding exactly the missing line to the category model. If you would be willing to help and not just show how great you are and how dumb we are, you would get the fact that the cache is cleaned at 4 different places in the config model. So the question is not how todo that, the question is why it does not work for them as expected.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10040
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Category Cache Problem VM 3.0.8
« Reply #5 on: April 21, 2015, 11:23:17 am »
And yes we look into the forum and find many entrys for caching problems with VM, but never fix it

That does not mean it is not fixed. Yesterday I tried to find any post with "cant store product" which happened due an update to j3.4.1. It is fixed. There are more than 20 threads about it. 95% of them were created AFTER the fix was already released! So it is very likely the same here. There are none known problems with caching left.


VM: 3.8.0
vm3.0.8 please :-)
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4329
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Category Cache Problem VM 3.0.8
« Reply #6 on: April 21, 2015, 11:28:14 am »
First, i never said you are dumb,
second this is a proposal, not a final patch.

And i tried this, but the problem in Joomla is that when the cache is not active, my patch does not work, but this solve the problem for mod_category and mod_product(for alias).
In all case the current problem is Joomla cache system not virtuemart.
I don't understand. You don't want to find a solution ?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4329
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Category Cache Problem VM 3.0.8
« Reply #7 on: April 21, 2015, 12:02:27 pm »
This is a real working solution :
JOOMLAROTH/administrator/components/com_virtuemart/models/category.php
in public function store(&$data) { insert
Code: [Select]
$conf = JFactory::getConfig();

$options = array(
'defaultgroup' => '',
'storage' => $conf->get('cache_handler', ''),
'caching' => true,
'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')
);
$cache = JCache::getInstance('', $options);
$cache->clean('com_virtuemart_cats');
$cache->clean('mod_virtuemart_product');
$cache->clean('mod_virtuemart_category');

this work when joomla cache is active or not. tested in Joomla 3.4

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10040
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Category Cache Problem VM 3.0.8
« Reply #8 on: April 21, 2015, 12:55:12 pm »
Looks good Patrick. I have to dig through it again, but
Code: [Select]
$conf = JFactory::getConfig();

$options = array(
'defaultgroup' => '',
'storage' => $conf->get('cache_handler', ''),
'caching' => true,
'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')
);
$cache = JCache::getInstance('', $options);
is an idea. I must also first check if it is j3 problem only.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4329
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Category Cache Problem VM 3.0.8
« Reply #9 on: April 21, 2015, 13:11:25 pm »
I checked in com_cache model to find how joomla dev have do this.
In Joomla 2.5, the code is same as in joomla 3.4, this mean the code is certainly safe.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4329
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Category Cache Problem VM 3.0.8
« Reply #10 on: April 21, 2015, 16:53:38 pm »
same code for config model clean cache

Code: [Select]
$conf = JFactory::getConfig();

$options = array(
'defaultgroup' => '',
'storage' => $conf->get('cache_handler', ''),
'caching' => true,
'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')
);
$cache = JCache::getInstance('', $options);
$cache->clean('com_virtuemart_cats');
$cache->clean('com_virtuemart_rss');
$cache->clean('com_virtuemart_cat_manus');
$cache->clean('convertECB');
$cache->clean('_virtuemart');
$cache->clean('com_plugins');
$cache->clean('_system');
$cache->clean('page');
$cache->clean('mod_virtuemart_product');
$cache->clean('mod_virtuemart_category');

But the config, is not so important.

for manufacturer model in public function store(&$data) {
Code: [Select]
$conf = JFactory::getConfig();

$options = array(
'defaultgroup' => '',
'storage' => $conf->get('cache_handler', ''),
'caching' => true,
'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')
);
$cache = JCache::getInstance('', $options);
$cache->clean('com_virtuemart_cat_manus');

franzpeter

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 467
    • 2in1-online | Software, Mac, PC, Netzwerk, Drucker, Pad, Display
  • VirtueMart Version: Virtuemart 3.2.6
Re: Category Cache Problem VM 3.0.8
« Reply #11 on: April 23, 2015, 11:46:52 am »
@Studio 42
I did try to implement your patch in case of categories. With J 2.5 it does not work. I receive error message. In case of J 3 it is completely ignored. So by default seems to be useless. Is it a solution for an non existing problem? I do not know what was wrong with the caching before. I can delete the cache via Joomla in J 2.5 and J 3.4.1. It is recreated if going to the FE. If  - in case of the category module - the caching is set to none in BE, there will be no cache. So I do not understand exactly that solution. There is no problem and you write something for a non existing problem.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4329
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Category Cache Problem VM 3.0.8
« Reply #12 on: April 23, 2015, 16:17:04 pm »
Hi,
Virtuemart always force the cache for the category aliases.

But the fix is when you save the category not after. But why you have to change the aliases after saving, because this have to be correct if you don't do any change in Back end.

I tested the patch, perhaps you have do a mistake on copy/paste ?

Greets,

Patrick

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10040
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Category Cache Problem VM 3.0.8
« Reply #13 on: April 26, 2015, 12:19:10 pm »
Works also not for me, Patrick
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4329
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Category Cache Problem VM 3.0.8
« Reply #14 on: April 26, 2015, 13:54:35 pm »
This is exactly what i have in file administrator\components\com_virtuemart\models\category.php in the store function :

Code: [Select]
    public function store(&$data) {

vRequest::vmCheckToken();

$table = $this->getTable('categories');

if ( !array_key_exists ('category_template' , $data ) ){
$data['category_template'] = $data['category_layout'] = $data['category_product_layout'] = 0 ;
}
if(VmConfig::get('categorytemplate') == $data['category_template'] ){
$data['category_template'] = 0;
}

if(VmConfig::get('categorylayout') == $data['category_layout']){
$data['category_layout'] = 0;
}

if(VmConfig::get('productlayout') == $data['category_product_layout']){
$data['category_product_layout'] = 0;
}

$table->bindChecknStore($data);

if(!empty($data['virtuemart_category_id'])){
$xdata['category_child_id'] = (int)$data['virtuemart_category_id'];
$xdata['category_parent_id'] = empty($data['category_parent_id'])? 0:(int)$data['category_parent_id'];
$xdata['ordering'] = empty($data['ordering'])? 0: (int)$data['ordering'];

    $table = $this->getTable('category_categories');

$table->bindChecknStore($xdata);

}

// Process the images
$mediaModel = VmModel::getModel('Media');
$file_id = $mediaModel->storeMedia($data,'category');

$conf = JFactory::getConfig();

$options = array(
'defaultgroup' => '',
'storage' => $conf->get('cache_handler', ''),
'caching' => true,
'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')
);
$cache = JCache::getInstance('', $options);
$cache->clean('com_virtuemart_cats');
$cache->clean('mod_virtuemart_product');
$cache->clean('mod_virtuemart_category');

return $data['virtuemart_category_id'] ;
}

When i disable the cache in Joomla, all this 3 folders com_virtuemart_cats, mod_virtuemart_product, mod_virtuemart_category are removed and if i enable the cache this work same.
Of course, at the moment you refresh a page in the front, the  com_virtuemart_cats folder are regenerate, because this cache is forced in virtuemart.
I don't try to solve the foced cache problem, but my problem was that on saving a category, this was not refreshed in the 3 core caches using categories.
P.S: this fix is running on my test server without any error in my error log seens 4 days now.