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?

2

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

  • Thanks for the clarification, perhaps this should be reported to the Joomla dev team. – thednp May 19 at 5:46
  • You're welcome. I've submited an issue on the Issue Tracker – Lodder May 19 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 May 20 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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