silly me. i used a template with blueprint having an autoid field. thats why update is called on create.
so now i have the following issue using autoid. autoid registers a panel.page.create hook. on create it will call $page->update() to write the autoid. so far so good.
but i also have a custom hook listening to panel.page.update. so this one gets triggered causing the slow progressbar. a basic hook like this works fine.
kirby()->hook('panel.page.create', function($page) { file_put_contents(kirby()->roots()->index().'/testcreate.log', 'hello'); });
but once i use my plugin in fails. in all other cases it works just when create is causing an update.
kirby()->hook('panel.page.create', function($page) use ($plugin) { $plugin->log($page, 'panel.page.create'); });
so my guess is that my plugin fails to process the update because its still processing the create. a nested call of the same plugin. any ideas how to fix this?
i check revisions from @jenstornell again. he uses only static functions and no issue in combination with autoid. good job.
but i refuse the idea to make my plugin static since its not causing the loop. autoid form @helllicht is causing it. so i can create an github issue there (which would require them to go static) or i find a workaround myself.
any ideas how to track if my class is called nested?
haha. it always helps writing to the forum. explaining a problem is half way of solving it.
i just added a static ‘lock’ to my own class blocking the main function to be called nested.
private static $lock;
public function main() {
if(MyClass::$lock) return;
MyClass::$lock = true;
try {
// do work
} catch(Exception $ex) {
// maybe echo ex
}
finally {
MyClass::$lock = false;
}
}