Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
18.4.8
-
None
-
Unknown
-
Description
Follow-up of XWIKI-22784, written with Claude AI
Steps to reproduce:
1. Create a terminal page Sandbox.P1 with an attachment image.png and this content:
[[image:Sandbox.P1@image.png]] [[Link>>doc:Sandbox.P1]]
2. Move it to Other.P1.WebHome with "Update links" enabled and "Create an automatic redirect" disabled. With the script service:
{{velocity}}
#set ($req = $services.refactoring.requestFactory.createRenameRequest($services.model.resolveDocument('Sandbox.P1'), $services.model.resolveDocument('Other.P1.WebHome')))
#set ($discard = $req.setInteractive(false))
#set ($discard = $req.setUpdateLinks(true))
#set ($discard = $req.setAutoRedirect(false))
#set ($job = $services.refactoring.rename($req))
#set ($discard = $job.join())
{{/velocity}}
Expected result:
[[image:Other.P1.WebHome@image.png]] [[Link>>doc:Other.P1.WebHome]]
Actual result:
[[image:Sandbox.P1@image.png]] [[Link>>doc:Other.P1.WebHome]]
The link is updated but the image is not, so it is broken. attach: references to the page's attachments go through the same check and are expected to behave the same (not tested). With "Create an automatic redirect" enabled, both are updated.
Analysis:
ResourceReferenceRenamer#isAbsoluteReferenceToDocument treats a reference as absolute when its resolution against the old document equals its resolution without a base:
linkReference.equals(this.entityReferenceResolver.resolve(resourceReference, null))
Resolved against the old document, Sandbox.P1@image.png gives Sandbox.P1: the reference equals the base, so AbstractResourceReferenceEntityReferenceResolver#resolveDocumentReference applies no fallback. Resolved without a base, the base is the current document, the reference differs from it, and since Sandbox.P1 no longer exists (no redirect was left), the resolver falls back to Sandbox.P1.WebHome. The two results differ, the reference is not seen as pointing to the moved page, and it is left unchanged.
Attachments
Issue Links
- is related to
-
XWIKI-22784 Links to a page itself are not updated when moving or renaming the page
-
- Closed
-