-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Links in the diagram content are not updated when the linked page is moved/renamed #110
Comments
First we need to detect when a page is renamed. For this we need to write an event listener. On XWiki 11.1RC1+ we can use the dedicated page rename events. On older versions we need to do some hacks. @lucaa might be able to help us with that. Note that if we want to use the dedicated rename events without increasing the minimum XWiki version we need to use reflection and do some hacks. Once we are notified when a page is renamed we need to determine which diagram pages have links to the renamed page. This can be done on each rename with a database query, or we could try to use the backlinks table, but for this we would need another event listener that updates the backlinks whenever a diagram is saved (by adding the links from the saved diagram). Once we know which diagrams have to be updated we need to modify their XML content. The best for this would be to use a stream-based XML parser / serializer because we don't need to load the entire diagram XML in memory, we just need to get to the XML element that holds the link and modify some attribute value. In any case, this processing should be done asynchronously. It shouldn't block the page rename. It's fine if the diagrams are updated "slowly" in a background thread. |
@mflorea Here is how @slauriere (and myself?) hacked this in the past https://github.com/xwiki-contrib/application-page-relations/blob/application-page-relations-2.4/application-page-relations-api/src/main/java/org/xwiki/contrib/pagerelations/internal/PageRelationsRenameEventListener.java#L69 (listening to create and then checking the context by the name or something). I think it was somewhat validated that it's the good way to know if the creation is part of a rename or a regular create. |
Thanks @lucaa , this is very helpful. |
…moved/renamed xwikisas#110 * the fix is implemented following xwikisas#110 (comment)
…moved/renamed xwikisas#110 * refactoring
…moved/renamed xwikisas#110 * refactoring
…moved/renamed xwikisas#110 * typo
#125) ... moved/renamed #110 * the fix is implemented following #110 (comment)
For diagrams created before the fix version, an additional save on each diagram page will be needed (to mark the page as a backlink) |
The links from the diagram content are not updated when the linked content is moved or renamed.
Steps to reproduce:
Results:
The links in the diagram are not updated.
The text was updated successfully, but these errors were encountered: