VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: ServeTT on November 22, 2016, 07:30:26 AM

Title: [SOLVED] Bug with clear cat cache. Didn't clean com_virtuemart_cat_childs
Post by: ServeTT on November 22, 2016, 07:30:26 AM
Hello!
PHP 5.6
Installed Joomla 3.6.4 + virtuemart 3.0.18.4 Blue Corvus 9383. Nothing else.
Standart template without changes. All Joomla and VM settings are default after clean install.

Noticed a bug in administrator/components/com_virtuemart/models/category.php
Method clearCategoryRelatedCaches, line 651.
After creating new category, com_virtuemart_cat_childs didn't delete.
Chaged the code to

$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');
              $cache->clean('com_virtuemart_cat_childs');


Now everything works fine!)
My category.php is in attachment in zip archive.

Thanks to author - Studio 42 (https://forum.virtuemart.net/index.php?topic=129548.msg445864#msg445864)
Title: Re: Bug with clearCategoryRelatedCaches. Didn't clean com_virtuemart_cat_childs
Post by: Milbo on November 22, 2016, 09:10:32 AM
Any idea, why it does not work with $cache = JFactory::getCache(); ?
Title: Re: Bug with clearCategoryRelatedCaches. Didn't clean com_virtuemart_cat_childs
Post by: ServeTT on November 22, 2016, 09:50:04 AM
Quote from: Milbo on November 22, 2016, 09:10:32 AM
Any idea, why it does not work with $cache = JFactory::getCache(); ?
I don't know for sure, but maybe specify $storage in  JFactory::getCache(), because it is null by default.
I found this code on this forum and tried it and it worked)
Forgot to write about the author, sorry, fixed first post
Title: Re: Bug with clearCategoryRelatedCaches. Didn't clean com_virtuemart_cat_childs
Post by: Milbo on November 22, 2016, 14:04:29 PM
I think now it is the
'cachebase'      => $conf->get('cache_path', JPATH_SITE . '/cache')

because we are in the BE and want to delete a cache in the FE.
Title: Re: Bug with clearCategoryRelatedCaches. Didn't clean com_virtuemart_cat_childs
Post by: ServeTT on November 22, 2016, 14:24:26 PM
Quote from: Milbo on November 22, 2016, 14:04:29 PM
I think now it is the
'cachebase'      => $conf->get('cache_path', JPATH_SITE . '/cache')

because we are in the BE and want to delete a cache in the FE.

Will You release VM 3.0.18.5 with that fix??
Title: Re: Bug with clearCategoryRelatedCaches. Didn't clean com_virtuemart_cat_childs
Post by: Milbo on November 22, 2016, 14:48:37 PM
yes
Title: Re: Bug with clearCategoryRelatedCaches. Didn't clean com_virtuemart_cat_childs
Post by: ServeTT on November 22, 2016, 15:26:58 PM
Quote from: Milbo on November 22, 2016, 14:48:37 PM
yes
Ready to test on clean Joomla install, when You will release new version
Title: Re: Bug with clearCategoryRelatedCaches. Didn't clean com_virtuemart_cat_childs
Post by: Milbo on November 22, 2016, 21:39:05 PM
http://dev.virtuemart.net/attachments/download/1034/com_virtuemart.3.0.18.5_extract_first.zip
Title: Re: Bug with clearCategoryRelatedCaches. Didn't clean com_virtuemart_cat_childs
Post by: ServeTT on November 23, 2016, 07:33:00 AM
Quote from: Milbo on November 22, 2016, 21:39:05 PM
http://dev.virtuemart.net/attachments/download/1034/com_virtuemart.3.0.18.5_extract_first.zip
Now everything is OK, thanks!
Title: Re: [SOLVED] Bug with clear cat cache. Didn't clean com_virtuemart_cat_childs
Post by: Milbo on November 23, 2016, 08:17:02 AM
Nice that we got that sorted, finally. I think you took the code idea from Patrick, btw. I think the reason is a difference in joomla 2 and joomla3. When I check my j2.5, then there is a cache folder in the administrator folder, but no files (except the index.html). But in joomla 3 I see there files. So it seems that they fixed or added the feature of different cache folders per application (FE oder BE). And this lead to trouble, when we try to delete a cache of the FE, while in the BE. I wonder also if it makes sense to controll the options always, even when just use the cache.
Title: Re: [SOLVED] Bug with clear cat cache. Didn't clean com_virtuemart_cat_childs
Post by: ServeTT on November 23, 2016, 10:53:35 AM
Quote from: Milbo on November 23, 2016, 08:17:02 AM
Nice that we got that sorted, finally. I think you took the code idea from Patrick, btw. I think the reason is a difference in joomla 2 and joomla3. When I check my j2.5, then there is a cache folder in the administrator folder, but no files (except the index.html). But in joomla 3 I see there files. So it seems that they fixed or added the feature of different cache folders per application (FE oder BE). And this lead to trouble, when we try to delete a cache of the FE, while in the BE. I wonder also if it makes sense to controll the options always, even when just use the cache.
Yes, I wrote about it in my first post, at first forgot about it, then gave a link to his original post.
I have site on J2.5 and VM2 - and there is OK, in VM3 and J3 it is my first)