-
Notifications
You must be signed in to change notification settings - Fork 29
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-3334: Skipped migrating binary file or its metadata when using the same handler #322
Conversation
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 don't follow, how does this solve the issue? Why are you duplicating the code that differs only by 2 lines? Why are there no tests covering the issue?
CS is failing here.
It solves the issue by not migrating files or metadata to the exact same handler which is prone to errors (like writing the same file to the exact same location), besides, what's the point besides lowering the performance of the command?
Where exactly is this duplication?
It's not related. It's failing for some time already for CS in 8.0 in some packages. You can see that this is completely unrelated when you go to the |
It seems that both methods accept different types of objects for $metadataCreateStruct->mtime = $binaryFile->mtime;
$metadataCreateStruct->mimeType = $this->fromMetadataHandler->getMimeType($binaryFile->id); I don't get why we use the same struct for both and why remaining same struct parameters are filled in the only one case. That said, this could do maybe, given those seem to be different operations with the same naming, but... how does it work that
Ah true, I'll look into this. In that case it should be resolved separately. I encourage being pro-active in the future :) |
Because this is what is required respectively by
Handlers are being set in the
Sure, I completely agree, that's a great idea, however, I feel like this shouldn't be the scope of this PR as all the commands require such treatment. |
eZ/Bundle/EzPublishIOBundle/Migration/FileMigrator/FileMigrator.php
Outdated
Show resolved
Hide resolved
eZ/Bundle/EzPublishIOBundle/Migration/FileMigrator/FileMigrator.php
Outdated
Show resolved
Hide resolved
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.
@barw4 you can rebase the changes for CI not to fail
After deeper investigation I see that we have a flaw in the whole design of this command, which contradicts DDD approach with Services. A service should never allow to change its state during execution. If there's some dependency that needs to be set, it should be set within the scope of the method call. Alternatively a command should utilize some form of Factory to build an instance used only for a single runtime.
Given the flaw pre-existed, I can agree that refactoring of this architecture might require more work than we currently have a capacity to do, especially taking into the account BC on SPI.
Do you think that if something wasn't done before, we shouldn't improve?
Sure, I completely agree, that's a great idea, however, I feel like this shouldn't be the scope of this PR as all the commands require such treatment.
This argument never worked neither with me nor the other Maintainers of kernel & core package. It's not about catching up with technical debt of all the commands. It's about covering with unit test a use case that proved as a pain point for a Customer so we avoid further regressions (it's a part of a bug fix).
Moreover I didn't ask for coverage for the commands. I asked for the coverage of current behavior of FileMigrator
. Forget about the Command. Have a test that instantiates FileMigrator
with proper mocks which reflects the use case of the same and different from->to handlers. It's not a very complicated task. With that covered we can move on.
656a94a
to
e152fdf
Compare
@alongosz |
Please retry analysis of this Pull-Request directly on SonarCloud. |
Review ping @adamwojs |
The second proposed solution is 100% valid here and it should be pretty easy to introduce. My recommendation would be directly inject I agree that this could be improved in separate PR. |
Could you please merge up changes @barw4 ? |
v3.3
As stated in the title, seems like a logical thing to do as that leaves less space for errors.
Checklist:
$ composer fix-cs
).@ezsystems/engineering-team
).