Error when I activate cache on a module that I created Topic is solved

For Joomla! 4.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Post Reply
thierry77515
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Sep 26, 2022 7:09 pm

Error when I activate cache on a module that I created

Post by thierry77515 » Mon Sep 26, 2022 8:32 pm

I , i'm starting to create a simple module (using a bootstrap carousel). It work if I don't activate cache , but when i activate cache the error is the following :
error - Uncaught Throwable of type Exception thrown with message "Serialization of 'Closure' is not allowed".
Stack trace: #0 [ROOT]/libraries/src/Cache/Controller/CallbackController.php(156): serialize(Array) #1
[ROOT]/libraries/src/Helper/ModuleHelper.php(588): Joomla\CMS\Cache\Controller\CallbackController->get(Array, Object(Joomla\Registry\Registry), '202cb962ac59075...', true, Array)
#2 [ROOT]/modules/mod_carousel_artincycle/mod_carousel_artincycle.php(26): Joomla\CMS\Helper\ModuleHelper::moduleCache(Object(stdClass), Object(Joomla\Registry\Registry), Object(stdClass))
#3 [ROOT]/libraries/src/Dispatcher/ModuleDispatcher.php(52):
In my module I chose a parent category and then it show all the child categories , with the image, in the carousel. it's simple.

I created a module (I used the module mod_articlse_categories) and here's the code of the main php file

tell me if you need code on the others files , I searched in the forum , I compare with the others modules n but i really don't see where is the error

Code: Select all

use Joomla\CMS\Helper\ModuleHelper;
$cacheid = md5($module->id);
$cacheparams               = new \stdClass();
$cacheparams->cachemode    = 'id';
$cacheparams->class        = 'Joomla\Module\CarouselMysite\Site\Helper\CarouselMysiteHelper';
$cacheparams->method       = 'getList';
$cacheparams->methodparams = $params;
$cacheparams->modeparams   = $cacheid;

[color=#FF0000]$list       = ModuleHelper::moduleCache($module, $params, $cacheparams);[/color]

$startLevel = $list ? reset($list)->getParent()->level : null;

require ModuleHelper::getLayoutPath('mod_carousel_mysite', $params->get('layout', 'default'));

It fail on the red line. Do you have an idea . What I have forgotten
Thanks for your help

Thierry
Last edited by toivo on Mon Sep 26, 2022 8:36 pm, edited 1 time in total.
Reason: mod note: moved from 4.x Extensions

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 13044
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Error when I activate cache on a module that I created

Post by sozzled » Tue Sep 27, 2022 4:07 am

You haven't forgotten anything. It's a known bug with J! 4.2.2; see viewtopic.php?f=808&t=996482&p=3671362#p3671362
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
Walking the talk: https://j4xdemo.enduring.com.au
:)

thierry77515
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Sep 26, 2022 7:09 pm

Re: Error when I activate cache on a module that I created

Post by thierry77515 » Tue Sep 27, 2022 12:21 pm

Thanks

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 13044
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Error when I activate cache on a module that I created

Post by sozzled » Tue Sep 27, 2022 9:54 pm

This is also a known bug with J! 4.2.3; it has nothing to do with the [iJoomla! 4.x Coding[/i] forum.

I asked the forum moderators to relocate this post but my request was denied.
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
Walking the talk: https://j4xdemo.enduring.com.au
:)


Post Reply

Return to “Joomla! 4.x Coding”