?
avatar bertmert
bertmert
26 Jul 2016

inconsitent use of cache paths

It's possible to set a custom cache path in configuration.php
public $cache_path = '/absolute/path/to/custom/cache2345';

On the other hand includes/defines.php and administrator/includes/defines.php are defining a constant

  • JPATH_CACHE in frontend: /path/to/joomla/cache/
  • JPATH_CACHE in backend: /path/to/joomla/administrator/cache/

=> Use $cache_path for FE and also BE if defined. If not uses JPATH_CACHE (depends on BE or FE).


=> Use $cache_path if defined only for FE. Otherwise /path/to/joomla/cache/.
=> Use always /path/to/joomla/administrator/cache/ for BE.


=> Uses JPATH_CACHE. Ignores $cache_path completely. (Seems to be a bug. I will provide a PR.).


This all may lead to unwanted and/or confusing results if you use Cache Handler File which is the mostly used one.

I wanted to correct cache directories output of tab Folder Permissions
administrator/index.php?option=com_admin&view=sysinfo
because if you define $cache_path in configuration.php it only shows 1 path instead of 2 paths (1 for BE, 1 for FE which is definitely(?) correct meanwhile.)

Because I would like to do a code review concerning cache paths I have this question now:

  • Should BE cache always be /JoomlaROOT/administrator/cache/ ? And never $cache_path ? (I would prefer this.)

and

  • Should FE cache always be $cache_path or if $cache_path is not defined in /JoomlaROOT/cache/ ? and
  • Shouldn't we set JPATH_CACHE as deprecated because it's defined too early when we don't have access to configuration datas and therefore $cache_path?
  • Or ... ?
avatar bertmert bertmert - open - 26 Jul 2016
avatar bertmert bertmert - change - 26 Jul 2016
The description was changed
avatar bertmert bertmert - edited - 26 Jul 2016
avatar bertmert bertmert - change - 26 Jul 2016
The description was changed
avatar bertmert bertmert - edited - 26 Jul 2016
avatar bertmert bertmert - change - 26 Jul 2016
The description was changed
avatar bertmert bertmert - edited - 26 Jul 2016
avatar mbabker
mbabker - comment - 26 Jul 2016

IMO JPATH_CACHE should ALWAYS equate to JPATH_ADMINISTRATOR . '/cache', I personally don't see the need for separate filesystem cache per application especially since some of the stuff caching data is shared between applications, and I'd say the less top level directories Joomla requires in the web root the better.

And IMO any place looking for a filesystem cache path should be doing JFactory::getConfig()->get('cache_path', JPATH_CACHE); as that allows a custom cache path to be defined (outside the web root if you're insistent on that) while still uses a reasonable default. So the config var shouldn't be deprecated.

Unless you've screwed up your application bootstrap (thinking custom CLI or web apps now, not the default CMS app classes or index.php front controllers), you'll always have the JPATH_* constants and JFactory::getConfig() working to get these values, not to mention you can inject custom values calling the factory methods directly instead of going through JFactory or using the public APIs to change some values. So I don't think there's any action needed regarding changing how these values are used.

avatar bertmert bertmert - change - 26 Jul 2016
The description was changed
avatar bertmert bertmert - edited - 26 Jul 2016
avatar andrepereiradasilva
andrepereiradasilva - comment - 27 Jul 2016

I can see the use case for a custom cache path. Putting cache files in a ramdisk or something like that.

avatar brianteeman brianteeman - change - 27 Jul 2016
Category Cache
avatar mbabker mbabker - change - 27 Jul 2016
Labels Added: ?
Removed: ?
avatar bertmert bertmert - change - 12 Aug 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-08-12 19:25:14
Closed_By bertmert
avatar bertmert bertmert - close - 12 Aug 2016

Add a Comment

Login with GitHub to post a comment