xwikisas / application-diagram

Create various types of diagrams using draw.io
GNU Lesser General Public License v2.1
0 stars 8 forks source link

Store SVG as attachment migration is not working if the free aplication was previoustly installed #226

Closed oanalavinia closed 2 years ago

oanalavinia commented 2 years ago

Starting with version 1.11, the diagram svg is not anymore stored inside a page object, but as an attachment, see https://github.com/xwikisas/application-diagram/issues/84#issuecomment-555078670 When upgrading from a version that used the old storage, a migration should be triggered to move the svg to the attachments.

Steps to reproduce the issue:

  1. Have Diagram Application (free version) installed
  2. Create a diagram Diagram1 and add some content
  3. On a different page, let's say MyTest, add a diagram macro that displays Diagram1 with the cached option checked (it will use the diagram svg when displaying)
  4. Install Diagram Application (Pro), using a version >= 1.11 (let's say 1.12)
  5. (optional) Uninstall Diagram Application (free version)
  6. Go to MyTest and observe the diagram included using the diagram macro

Expected result: The diagram it is displayed.

Actual result: The diagram it's not displayed anymore while the cached option checked.

Note: This behavior is caused by the fact that the applied migration only listens to the upgrade event (see https://github.com/xwikisas/application-diagram/blob/master/application-diagram-api/src/main/java/com/xwiki/diagram/internal/DiagramApplicationListener.java#L68), while above an install event was actually fired (the free and the paid version are 2 separate application). So I continued with:

  1. Upgrade Diagram Application (Pro) to 1.13
  2. Go to MyTest and observe the diagram included using the diagram macro

At this point the problem continues to reproduce, meaning that the migration is not applied. The migration is working well if the paid application was installed from the start

Workarounds:

  1. Use the diagram macro without the cached option checked
  2. Resave Diagram1 (since this will generate the needed attachments)

Note that this will impact the XWiki PDF export export as well (or any other feature that relies on the diagram svg)