znuny / Znuny

Znuny/Znuny LTS is a fork of the ((OTRS)) Community Edition, one of the most flexible web-based ticketing systems used for Customer Service, Help Desk, IT Service Management.
https://www.znuny.org
GNU General Public License v3.0
333 stars 82 forks source link

Fixed StorageSwitch doesn't export attachments correctly (removes html article) #525

Open tipue-dev opened 6 months ago

tipue-dev commented 6 months ago

Proposed change

Problem: Using Admin::Article::StorageSwitch when Ticket::Article::Backend::MIMEBase::CheckAllStorageBackends is active changes all html articles to plaintext.

When switching between the backends FS and DB (Admin::Article::StorageSwitch), the code looks up, if a file with the same name exists already (because of some Unicode situation described here). To check this, the code gets all attachments of the article from the target backend.

The problem is, that the function used to list all attachments can look up the files in the other backend if the config Ticket::Article::Backend::MIMEBase::CheckAllStorageBackends is active. In that case, when no attachment has been written to the new backend yet, the file list of the old backend is returned instead. That means the first attachment, is wrongly assumed to already exists and gets renamed with a suffixing -1.

Since the first attachment is always file-1 (plain text) or file-2 (html), those will be renamed to file-x-1 on every switch and not recognised as special attachments anymore. This means the article suddenly is plain text with an attachment named file-x-1 added in the TicketZoom. Every switch adds more -1 at the end, that means if someone tries to fix this by switching between the backends, the filename becomes longer file-2-1-1-1-1-1.

The parameter needed to fix this already exists for different cases an can be used here too.

To reproduce the behaviour:

  1. activate Ticket::Article::Backend::MIMEBase::CheckAllStorageBackends
  2. export tickets to a new backend using Admin::Article::StorageSwitch
  3. open the TicketZoom

1 - 🐞 bug 🐞

Checklist

rkaldung commented 1 week ago

@tipue-dev I can't reproduce this with version Znuny LTS 6.5.9. Any ideas or is it just magically working again?

tipue-dev commented 1 week ago

@rkaldung i just tested it again in a fresh installation of 6.5.9.

The missing change of the ArticleStorage to FS might have been the problem in reproducing it.

https://github.com/znuny/Znuny/assets/80031303/88731a25-e64b-415c-9c7e-69bb4c842f51