Skip to content

Conversation

@surli
Copy link
Member

@surli surli commented Feb 27, 2025

Jira URL

https://jira.xwiki.org/browse/XWIKI-22931

Changes

Description

  • Fix XWikiDocument#copyAttachment to actually perform a real clone including the copy of the content
  • Introduce a XWikiAttachment#cloneWithActualContent to clone and copy the content
  • Introduce a XWikiAttachmentContent#clone(boolean) that allows to decide to skip or not copying the content
  • Get rid of ownerDocument in XWikiAttachmentContent
  • Properly override new clone method in extended classes
  • Set the attachment document in XWikiDocument#setAttachment

Clarifications

Screenshots & Video

Executed Tests

mvn clean install -Pquality run on:

  • xwiki-platform-oldcore
  • xwiki-platform-store
  • xwiki-platform-legacy-oldcore

Tests ran for PageTemplatesIT

Manual test to create a page from Encyclopedia Template.

Note: CI run triggered in https://ci.xwiki.org/view/All/job/XWiki/job/xwiki-platform/job/XWIKI-22931/

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    • 17.10.x

@surli surli self-assigned this Mar 4, 2025
… a page from template

  * Fix XWikiDocument#copyAttachment to actually perform a real clone
    including the copy of the content
  * Introduce a XWikiAttachment#cloneWithActualContent to clone and copy
    the content
  * Introduce a XWikiAttachmentContent#clone(boolean) that allows to
    decide to skip or not copying the content

WIP: right now tests are passing but it shows a regression in logs when
running PageTemplatesIT, probably due to the ownerDocument of
XWikiAttachmnentContent in clone method
… a page from template

  * Get rid of ownerDocument in XWikiAttachmentContent
  * Properly override new clone method in extended classes
  * Set the attachment document in XWikiDocument#setAttachment

WIP: this still shows a regression in PageTemplatesIT with a stacktrace
about a missing attachment.
… a page from template

  * Small improvments but still having bad stack trace when trying to
    create page from template related to Solr
… a page from template

  * Properly load the file content before cloning it

WIP: there's still a problem with the template UC
@surli surli marked this pull request as ready for review December 31, 2025 15:02
@surli surli requested a review from tmortagne December 31, 2025 15:03
@tmortagne
Copy link
Member

The logic looks OK in general, but there are some pretty dangerous changes in there and I feel like they deserve better test coverage, it's so easy to break that kind of stuff...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants