Fixed StorageSwitch doesn't export attachments correctly (removes html article) #525
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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) orfile-2
(html), those will be renamed tofile-x-1
on every switch and not recognised as special attachments anymore. This means the article suddenly is plain text with an attachment namedfile-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 longerfile-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:
Ticket::Article::Backend::MIMEBase::CheckAllStorageBackends
1 - 🐞 bug 🐞
Checklist