You get an error when saving changes in plugins

358 views
Skip to first unread message

Finn Poulsen

unread,
Oct 14, 2022, 7:16:04 PM10/14/22
to Joomla! General Development
you get the following error message: "call_user_func_array(): Argument #1 ($callback) must be a valid callback, class Joomla\CMS\Cache\Cache does not have a method "cleanCache""

Occurs in joomla 4.2.3

Darren Forster

unread,
Oct 15, 2022, 1:38:01 AM10/15/22
to joomla-de...@googlegroups.com
It seems that according to the error somewhere there is a variable called $callback and the string 'cleanCache' however the class JCache doesn't have a function called 'cleanCache' however looking at the JCache documentation there is a function called clean which is possibly the function you are trying to run. 

You have three possible solutions... 

1 - find out why the word 'Cache' is being added to the $callback variable and remove it so it just receives 'clean'. (Best option) 

2 - create your own class that extends JCache and add a function called cleanCache to it e.g.

class myCache () extends Cache
{
   public function cleanCache ( $group = null, $mode = 'group') 
{
 $this->clean ( $group, $mode) ;

and then wherever you create the cache variable use $cache = new myCache () ; rather than $cache = new Cache () ;

This isn't ideal as if you are getting the Cache class from another Joomla function then you might not be able to tell it to use the myCache class rather than the Cache class. 

3.  Whilst it is a kind of solution this third option should not be done at all - find the definition of JCache class (libraries/joomla/cache/cache.php) and add the cleanCache function above to the JCache class. 

This third solution would certainly fix the problem and you wouldn't need to find where Cache was being added to the callback parameter or create your own class - however you would be editing a Joomla core file - which you should never do - the reason you should never edit a Joomla core file is because if the site updates Joomla at any point there is a risk that the core file could be replaced with a new file - thus removing the fix and breaking the site! 

On Sat, 15 Oct 2022, 00:16 Finn Poulsen, <fsp.p...@gmail.com> wrote:
you get the following error message: "call_user_func_array(): Argument #1 ($callback) must be a valid callback, class Joomla\CMS\Cache\Cache does not have a method "cleanCache""

Occurs in joomla 4.2.3

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/joomla-dev-general/e45f1280-af00-4882-9c57-9f1808b1d1c7n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages