2

From the documentation I use this part to store a large chunk of data

if (empty($families)) {
  $cache = Factory::getCache();
  $families = $cache->call( array( 'JFormFieldFamily', 'getFamilyList' ) );
} 

Working perfectly on my Joomla 3.9.6, however my extension in Joomla 4 throws this

Warning: call_user_func_array() expects parameter 1 to be a valid callback,
class 'Joomla\CMS\Cache\Cache' does not have a method 'call' in
site\libraries\src\Cache\CacheController.php on line 74

Looking into the documentation for Joomla\CMS\Cache\Cache

$families = $cache->call( array( 'JFormFieldFamily', 'getFamilyList' ) );

becomes

$families = $cache->get( array( 'JFormFieldFamily', 'getFamilyList' ) );

and works properly on Joomla 3.9/4.

Do I need to use $cache->store() method?

1 Answer 1

4

The call method has been marked as removed for Joomla 4.0, as it's simply a wrapper for get().

You don't need to manually store the cache as this is done within the get() method:

https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Cache/Controller/CallbackController.php#L139

3
  • Thanks for the clarification, perhaps this should be reported to the Joomla dev team.
    – thednp
    Commented May 19, 2019 at 5:46
  • You're welcome. I've submited an issue on the Issue Tracker
    – Lodder
    Commented May 19, 2019 at 9:10
  • 1
    @thednp Apparently @deprecated 4.0 means it will be removed in 4.0. Rather bad terminology in my opinion but oh well.
    – Lodder
    Commented May 20, 2019 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.