xwikisas / macro-pdfviewer

0 stars 4 forks source link

Differences between the document from the attachment picker and the document macro paremeter #24

Closed oanalavinia closed 3 years ago

oanalavinia commented 3 years ago

Steps to reproduce

  1. Create a page Sandbox.TestPage1 and upload a PDF file, for example document1.pdf
  2. Create another page, Sandbox.TestPage2
  3. On Sandbox.TestPage2 use the PDF viewer macro and select the Sandbox.TestPage1@document1.pdf

Expected result The uploaded document1.pdf is displayed

Actual result An error appears, since the document is taken from the current document, instead of the document specified in the attachment picker pdfError

Even if the description of the macro parameters explain that the current document will be considered when there is no document added in the document macro parameter, I find it strange that this is needed since I am selecting a pdf along with it's parent from the drop down. From my point of view, the attachment picker should replace the need for the second macro parameter.

Note that this is the case only starting with XWiki version 11.5 #14 and on older versions there are no inconsistencies (since the attachment picker is not present)

Tested with XWiki version 12.10.4, Macro PDF Viewer version 2.2.1

oanalavinia commented 3 years ago

Starting with #14, the UI was changed and the file macro parameter will have a different signification depending on the XWiki version. If the url is not directly specified, the attachment reference can be taken either directly from the file macro parameter for XWiki versions starting with 11.5, since an attachment picker is used, or by using both the file and document parameters.

For being compatible with all types of PDF file definition, the following logic is applied, in this order:

  1. use the url if this is specified
  2. use the reference build by file+document parameters
    • if a document parameter is specified and the file name exists as attachment on it
    • if no document is specified, but the file name exists as attachment on the current document
  3. otherwise use the reference from the file parameter, selected inside the attachment picker (the document parameter is ignored)
oanalavinia commented 3 years ago

Reopening it since the proposed fix didn't covered some cases.