Plugin with hook has slow panel progressbar

maybe you are causing a loop yourself. fix it yourself.

your plugin is called nested because some other plugin with hook is calling $page->update() etc. they should fix it. but you can too.

a) just add a static lock to your plugin class.

b) or go all static with your plugin functions like revision plugin does.

Hello !

I’m in the same trap, I understand the idea of a lock, but I can’t manage to apply your fix to my case…

This is the code I try to make working without looping…

kirby()->hook('panel.page.update', function($page) {

    if(isset($page->content()->data['compagnie'])) {

        $compagnie = $page->compagnie()->lower()->toString();

        try {
            $page->update(array('compagnie' => $compagnie));
        } catch(Exception $e) {
            echo $e->getMessage();
        }

    }
});

And my attempt to convert it into an object with a lock was so dirty that I throw it…
In case its not too long for you to make an exemple of your fix with this code, you will make me reeeeeally happy !

@pierre: What I’m asking myself is why you need the hook at all for what you are doing there?

I would like to convert all tags to lowercase, to avoid duplicate tags. Is there an easier way ? I would rather to save them in lowercase than to convert them to lowercase in the filter.

Yes, there is a lower option to automatically convert tags to lowercase.

2 Likes

Mea culpa… Kirby is too well made for me