-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Refactor moveFileFromTmp to not use a static method call #27581
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
Refactor moveFileFromTmp to not use a static method call #27581
Conversation
Hi @dmanners. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dmanners. Thanks a lot for your collaboration. Please, check my comments below regarding some minor adjustments.
Thanks @rogyar I have made the changes required. I could consider also removing all usages of the old static method as this is used in multiple locations. Though I was thinking about doing this step first then doing the replacments later on. |
Hi, @dmanners. Thank you for the adjustments. If you take a look at the failing static tests, you will see that the If you have some time, I would suggest some refactoring of the Please, let me know if you need any help with that. Thank you! |
Hi @rogyar honestly I cannot see the right place for improvement here without simply removing the logger that is only used for one exception but not the other exception. If you had any ideas that would be greatly appreciated. |
Hi @dmanners. We could create a separate class like |
c81b343
to
4072bc8
Compare
app/code/Magento/Catalog/etc/di.xml
Outdated
@@ -216,7 +216,7 @@ | |||
<argument name="instanceName" xsi:type="string">Magento\Catalog\Model\System\Config\Source\Inputtype</argument> | |||
</arguments> | |||
</virtualType> | |||
<virtualType name="Magento\Catalog\CategoryImageUpload" type="Magento\Catalog\Model\ImageUploader"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could only find this one usage of the virtual type though I thought there would be more.
/** @var $uploader \Magento\MediaStorage\Model\File\Uploader */ | ||
$this->imageUploader = $this->objectManager->create( | ||
\Magento\Catalog\Model\ImageUploader::class, | ||
$this->configProvider = $this->objectManager->create( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too sure if this is the desired way to do this or if I can inject the virtual type from the di?
* | ||
* @return string[] | ||
*/ | ||
public function getAllowedExtensions() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 2.4 a breaking change? Am I allowed to remove these? I could not see any usaged in place for them apart from in the class.
Hi @rogyar since we have now added in all the actual classes that this is dependant on we are getting the following:
What I could suggest is to extract the usage of the store manager and the building of the media url into a ImageUploadURLBuilder class. Though that will only fix this mess warning if I can then remove the storemanager from the constructor. Is that ok with the current release setup or would that break too much compatibility issues? |
Hi @dmanners. That's one of the trickiest things in the legacy code refactoring. You try to add some minor adjustment but then you realize that you need to rebuild a huge part of the logic. I believe you know how it works :) I feel really sorry that you had to spend so much time on that but I don't think that we need to spend more tilting at windmills. Let's do the following. I would ask you to revert the last iteration of refactoring and get back to the place where we had 10 constructor arguments. We will try to convince the gatekeepers that it's the case when we should bypass the test. Once again, sorry for your time. I wish I could predict such cases and sometimes I can but the legacy code is still stronger than me :( |
Hi @rogyar sorry for the slow update. I actually had some changes that I had not pushed before your original message on reverting some commits. Could you please take a look over the current code and let me know which stuff I would need to put back :D |
Hi @dmanners. As far as I see, we need all commits prior to b2e726f57326d0dc6e7a5418996b16e9db8fabc7 (including this one). Thank you |
…n preperation for refactoring
…same name are in the directory
@magento run all tests |
Hi @engcom-Charlie @engcom-Delta. I'm not sure what is the reason, but I don't see the particular failing Static/Unit tests in the system. Only a pack of skipped tests. |
@magento run all tests |
Hi, @sidolov can you please help to understand why the unit tests and static tests are falling? In the report, there are no errors. |
|
@magento run all tests |
@magento run all tests |
Hi @rogyar, thank you for the review. |
✔️ QA passed |
Note: Automation tests are passed |
Hi @dmanners, thank you for your contribution! |
Description (*)
Currently the class
\Magento\Catalog\Model\ImageUploader
has a static call toUploader::getNewFileName
In this PR I plan to:
getNewFileName
,\Magento\Catalog\Model\ImageUploader
class to use this new class,Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
I am not too sure on the naming of the new class but would be happy to update it if needed.
I am also not sure about if I need an optional injection of my new class to the
ImageUploader
class.Contribution checklist (*)
Resolved issues: