Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-368: Added image path normalization before storing it into the DB #3102

Merged
merged 9 commits into from
Jun 10, 2021

Conversation

mateuszbieniek
Copy link
Contributor

@mateuszbieniek mateuszbieniek commented May 12, 2021

Question Answer
JIRA issue IBX-368
Bug yes
Target version 7.5+
BC breaks no
Tests pass yes
Doc needed yes

When Flysystem stores the image, the path is normalized and (for example) unprintable utf8 characters are dropped. The same transformation is not applied to the path stored in the ezimagefile table, which leads to 404 errors.

As the issue did not occur in legacy, an image path normalization command has to be implemented for migrating projects.

TODO:

  • Implement feature / fix a bug.
  • Fix new code according to Coding Standards ($ composer fix-cs).
  • Implement an image path normalization command for projects migrating from legacy.
  • Ask for Code Review.

Copy link
Member

@glye glye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice & compact. I'm only wondering if this is the right place for a binding to Flysystem, given that other handlers can be used? Other handlers might have other normalising rules, even stricter than Flysystem, so this might not be correct/enough.

Second, might we need this for non-image files too?

@mateuszbieniek
Copy link
Contributor Author

Very nice & compact. I'm only wondering if this is the right place for a binding to Flysystem, given that other handlers can be used? Other handlers might have other normalising rules, even stricter than Flysystem, so this might not be correct/enough.

Second, might we need this for non-image files too?

  1. I don't think we are expecting multiple "handlers" for a single field type - any idea for the other placement?
  2. Binary files are somewhat not affected.

@glye
Copy link
Member

glye commented May 12, 2021

I didn't mean multiple, just that Flysystem is documented as "default", implying it can be replaced by something else, so seems odd to have Flysystem code in the generic ImageStorage class.

Where else? Not sure, but I imagine the flysystem binarydatahandler could do it, and afterwards ImageStorage::storeFieldData could check with the returned binaryfile object if the filename is still the same as it was in the create struct. If not, update the $targetPath used further on in storeFieldData.

Or we could ask the ioservice up front if it wants to modify the name, and the ioservice asks the configured handler, which returns the corrected name, which we then use in the create struct. A bigger code change, but isn't it how we usually roll with regards to separation of concerns?

Anyway, if Andrew is happy, I'm happy :)

@adamwojs adamwojs changed the title [IBX-368] Added image path normalization before storing it into the DB IBX-368: Added image path normalization before storing it into the DB May 13, 2021
@mateuszbieniek
Copy link
Contributor Author

I didn't mean multiple, just that Flysystem is documented as "default", implying it can be replaced by something else, so seems odd to have Flysystem code in the generic ImageStorage class.

Where else? Not sure, but I imagine the flysystem binarydatahandler could do it, and afterwards ImageStorage::storeFieldData could check with the returned binaryfile object if the filename is still the same as it was in the create struct. If not, update the $targetPath used further on in storeFieldData.

Or we could ask the ioservice up front if it wants to modify the name, and the ioservice asks the configured handler, which returns the corrected name, which we then use in the create struct. A bigger code change, but isn't it how we usually roll with regards to separation of concerns?

Anyway, if Andrew is happy, I'm happy :)

Oh, I understand now - I'll give it a second look. Thanks @glye .

@juskora juskora added the Doc needed The changes require some documentation label May 13, 2021
Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ezsystems/documentation-team proofread the messages to users please (pointed out below)

@mateuszbieniek
Copy link
Contributor Author

pinging for a second round of review:
@alongosz @adamwojs @glye

Copy link
Member

@glye glye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, some questions aside.

Copy link

@tomaszszopinski tomaszszopinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA approved on eZPlatform-ee 2.5 & 2.5.20 with patch & diff.

@adamwojs adamwojs merged commit a327702 into ezsystems:7.5 Jun 10, 2021
@adamwojs
Copy link
Member

Could you please merge up changed @mateuszbieniek?

@mateuszbieniek
Copy link
Contributor Author

Merge up PR: ezsystems/ezplatform-kernel#197

@mateuszbieniek mateuszbieniek deleted the IBX-368_fix branch June 11, 2021 12:00
@DominikaK DominikaK removed the Doc needed The changes require some documentation label Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

9 participants