michitux / dokuwiki-plugin-move

Move and rename pages and namespaces whilst maintaining the links
http://www.dokuwiki.org/plugin:move
GNU General Public License v2.0
40 stars 20 forks source link

Help with move plugin changes #233

Open glensc opened 1 year ago

glensc commented 1 year ago

I'm maintaining a notification plugin:

how to handle page moves more efficiently? as currently each page move sends two events:

image

The plugin is listening to COMMON_WIKIPAGE_SAVE event:

$controller->register_hook('COMMON_WIKIPAGE_SAVE', 'AFTER', $this, 'handleSave');
glensc commented 1 year ago

maybe somehow DOKUWIKI_DONE event could help:

like collect the events to an array, and when DOKUWIKI_DONE is invoked empty that array in memory.

but from my testing, DOKUWIKI_DONE and COMMON_WIKIPAGE_SAVE are fired in different processes, so memory caching will not work. would need to store to filesystem.

michitux commented 1 year ago

One idea could be to use an event that has the before handler called before the move happens and the after handler after the move completed. Your event handler could then ignore or summarize the events (I mean the deletion of the old and creation of the new page) that happen in between the before and after event handler. I'm not sure if such an event already exists, but if not, it could be added.

glensc commented 1 year ago

this is dump of events fired during rename of one page

michitux commented 1 year ago

Are you sure that's from the move plugin and you aren't using another plugin for renaming the page? I'm asking because the move plugin fires an event before and after the move (which you could also use to combine the events as I wrote before): https://github.com/michitux/dokuwiki-plugin-move/blob/master/helper/op.php#L158 - and I cannot see that event in the log.

glensc commented 1 year ago

I renamed via simple rename:

glensc commented 1 year ago

The native page notification suffers the same problem, sends out two emails:

glensc commented 1 year ago

🚧 Never link to branches, share a permalink 🚧

NOTE: edit your post and fix it with a permalink!

glensc commented 1 year ago

Found that PLUGIN_MOVE_PAGE_RENAME::BEFORE is called, but if an error occurs, there's no knowledge of that to the event listener. so could lose messages.

EDIT: irrelevant: no move actually happens on error.

for I'm running on arm64 with rosetta2 so the indexes is super slow, and rename page gets index locked errors: "Error while updating the search index locked"

glensc commented 1 year ago

Have look:

what you think?