User tests: Successful: Unsuccessful:
In methods in JCache
where we're already checking if caching is enabled and the check isn't deeply integrated into other logic in the method, move the check to the beginning of the method and early return if we aren't caching (this prevents the need to instantiate a storage adapter and lessens the occurrence of that "Cache Storage not supported" message). Also use the get method to make this check for better readability and needing to change less references if the options reference ever changed.
If caching is disabled, calls that result in JCache::get()
, JCache::getAll()
, orJCache::store()
being triggered should not result in a call to JCache::_getStorage()
or JCacheStorage::getInstance()
. Note this isn't a foolproof test, i.e. if something initializes cache locking first that will trigger a call to get a storage adapter.
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Category | ⇒ | Cache |
I want to ask why not add/replace only:
if (!$this->cache->getCaching())
{
if (!is_array($args))
{
$referenceArgs = !empty($args) ? array(&$args) : array();
}
else
{
$referenceArgs = &$args;
}
return call_user_func_array($callback, $referenceArgs);
}
$data = $this->cache->get($id);
at https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/cache/controller/callback.php#L89
Updated:
I think that cache methods should be use only if is enabled or as little as possible.
Because it's not only the callback cache controller that needs to be dealt with. And all the controllers ultimately call into the JCache
methods.
The entirety of JCache
needs a good review, beyond the one I gave it a few months back. As well as everything making use of it. There's a lot of Joomla code not optimized for the current code structure or even the PHP 5.3 minimum (hell without #10795 the callback controller doesn't support Closures!).
But you can add my code to your as a shortcut.
This not break your code, its only return callback result early.
I'd rather do it piece by piece before this becomes a large and
unmanageable PR.
On Thursday, July 14, 2016, Tomasz Narloch notifications@github.com wrote:
But you can add my code to your as a shortcut.
This not break your code, its only return callback result early.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#11121 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWfoXuQ3-TgThWcl-DpSEwYcxyaYa54ks5qVruegaJpZM4JMc5a
.
OK, first test and merge this PR, then may be time for other ideas.
I have tested this item
Tested like this (I don't know if this is sufficient for a successful test but solves issue #11150):
public $caching = '0';
public $cache_handler = 'file';
The file Cache Storage is not supported on this platform.
Go to backend and you'll see an error message.
Go to frontend and you'll see an error message.
Open configuration.php and set
public $cache_handler = '';
Now you can login into backend and apply this patch with Joomla! Patch Tester component.
Open configuration.php and set
public $cache_handler = 'file';
Instead of an error message all fine because caching is not enabled.
Further tests (mess around with other settings)
Set
public $caching = '1';
public $cache_handler = 'file';
=> Again error.
Bring back folder administrator/cache
Backend OK.
Frontend => error.
Go to Global configuration
Save => Warning "The cache folder is not writable: /cache" and caching is disabled automatically while saving.
Bring back folder cache
Backend OK.
Frontend OK.
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
Labels |
Added:
?
|
Category | Cache | ⇒ | Libraries Cache |
I have tested this
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-08-13 18:23:09 |
Closed_By | ⇒ | wilsonge |
Labels |
Removed:
?
|
I added early return against the lock/unlock methods too. So hopefully this coupled with #10815 will both cause the storage adapters to be instantiated less often and more of the error cases absorbed until more of the application can be cleaned up to better error trap.