-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cloning feature with fallback for 1.10.x #7409
base: 1.10.x
Are you sure you want to change the base?
Cloning feature with fallback for 1.10.x #7409
Conversation
You should squash all the changes since master in order to remove all these useless commits and comments. |
@sebastienros please, help me squash that mess I pushed |
Checkout your branch.
This will move the |
…at is in 1.10.x: - Implemented fallback logic in the driver coordinators - Reverted change on the signature of the Clone method in src/Orchard.Web/Core/Contents/Controllers/AdminController.cs - Reverted changes to src/Orchard.Web/Modules/Orchard.Localization/Controllers/AdminController.cs - Restored src/Orchard.Web/Modules/Orchard.Localization/Views/Admin/Translate.cshtml - Reverted changes to src/Orchard.Web/Modules/Orchard.Localization/Views/EditorTemplates/Parts/Localization.ContentTranslations.Edit.cshtml - Reverted src\Orchard.Web\Modules\Orchard.Localization\Drivers\LocalizationPartDriver.cs
2501db0
to
85c4ae0
Compare
I think I did it! |
And now that it's clean, we can see the breaking changes ... IContentFieldDriver and IContentPartDriver new methods. |
I see...
@sebastienros, @MatteoPiovanelli-Laser can we talk about a strategy tomorrow during or before triage? |
I will join 15 minutes the meeting if you want. Ping me if I forget. |
@MatteoPiovanelli-Laser creating a derived interface like
And then to implement it where necessary, can solve or |
I'd say IContentFieldCloningDriver ,same for parts, inheriting from IContentFieldDriver. |
@sebastienros @HermesSbicego-Laser The same does not hold, however, for Does that sound right? |
…loningDriver and IContentPartCloningDriver interfaces. Changed ContentPartDriver and ContentFieldDriver so they inherit from the new interfaces. Changed ContentFieldDriverCoordinator and ContentPartDriverCoordinator so that the drivers are injected using the new interface.
I pushed the change with those two new interfaces. I haven't yet checked that all the modules in the repo implement the new methods as needed. The ones in this PR are those that had them implemented in dev, but we should do a check on all modules and features just in case, especially in light of the fact that, because of the fallback, if we need a specific part/field to never be cloned, we should implement an empty @sebastienros chat with you today 1145am PST? |
…er and IContentFieldDriver. The Cloning and Cloned logic now verify that the each driver implements the cloning interface
@sebastienros I made the change we discussed in the driver coordinators. It still works on my machine. |
@sebastienros
Why did I implement this in the coordinator like that? Here's something I realized after implementing this: I will be back in a few hours to read any comment, and I will try to implement any alternative you propose before you log back in on Wednesday morning (your morning, my evening). Cheers, |
@sebastienros I may have found a way to remove the reflection. I will push it on a separate branch later today. Please, let me know if you have a few minutes to discuss it when you log in. EDIT:
I will explain the reasoning for parts, but it's the same for fields: I tried this a bit, and it seems to give the same results I got with the version of the coordinators that used reflection. Issues may arise if peple start doing their own |
The simplest way to remove reflection is just to check if the instance of the driver |
But doing that check and casting does not take care of a situation where the driver is an implementation of |
Unless we say that
And then every where we want a driver to have a "real" cloning behaviour, separate from export/import, we implement However, that looks kind of kludgy to me. |
What about this: If someone wants to implement custom cloning, they implement From the coordinator (the service that calls the drivers) in the Clone methods, cast each driver to |
Also, if we did as per my last comment, we would run into trouble when we implement cloning+translations. Say we want the export/import to run when cloning, but we want to do something special when translating, as could easily be the case for e.g. ContentPickerField. If we did things like I described above, we would have to make sure and implement something giving the same end result as export/import in the cloning:
|
In your example you could have Cloned/Cloning in the base class, and you can just call |
Try to have the default behavior in the base classes (field and driver). If someone implemented IContentPartDriver directly (without the abstract class) then you can detect it from the coordinator and also call the fallback behavior. So the fallback code is in both the abstract drivers and the coordinator. |
Does that mean the abstract class should not be implementing
But the problem with implementing the export/import fallback down in the |
@sebastienros Current state of 1.10.x:
In the coordinator, when the Cloning is called, I check all the drivers for a part: if none implements Sorry if I misunderstood yesterday. I will code this now and get it pushed on a branch in our repo, so that you can give it a look. Matteo |
in the same branch I linked yesterady (https://github.com/LaserSrl/Orchard/tree/CloningFeatureWithFallbackNoReflection) I implemented what I explained in my previous comment. If I try to start a PR it says it can be merged into 1.10.x, but I didnt make a PR yet: if you think that approach is fine, I might overwrite it on the branch from this PR here. It works on my machine. Wouldn't this approach for the fallback be incompatible with what is happening in dev? cc @HermesSbicego-Laser because I'm on vacation starting tomorrow and the whole next week. |
@sebastienros any update on this? |
@sebastienros @HermesSbicego-Laser I am back from vacation and ready to go ahead with the discussion on this |
@MatteoPiovanelli-Laser it's a bit unfortunate, but due to the amount of time passed, do you think this should still be taken care of for 1.10.4? Localization changed a lot on 1.10.x/dev (mostly thanks to you guys) and 1.11 will soon™ be released. |
We should check whether dev has the fallback. Without it, it would be too much of a breaking change, I think. |
You mean an automated copying of infoset properties in a similar fashion as ExportInfoset and ImportInfoset? Btw we're currently reviewing/testing your other PR on cloning (#7592). |
the fallback I have does Export/Import using the existing functionality if no Cloning implementation is found. |
@MatteoPiovanelli-Laser is this PR still interesting for you? If so, we can discuss details and I can review, but please merge from 1.10.x and/or allow edits by maintainers if it's OK for you that I'd push changes. |
@MatteoPiovanelli-Laser ? Should we work on this PR or just #7592? |
Since we discussed cloning in the context of localization in #7352, I checked what the cloning feature does in dev.
The goal here is to make the cloning feature by @TFleury (see 87a3948 and #7400) retrocompatible to what is in 1.10.x.
In order to do that, I pulled those commits and reverted everything that was not directly related to Cloning (hence the number of commits in this branch's history).
Additionally, I introduced a fallback logic in the driver coordinators for cloning (see both ContentFieldDriverCoordinator and ContentPartDriverCoordinator):
The idea is that is a driver does not explicitly implement Cloning, the coordinator will clone the part by using the "old" logic of export/import. As a consequence, if we want a part (or field) to not be cloned, in at least one of its drivers we should declare a Cloning override that does nothing (e.g. see AutoroutePartDriver here).
I think with this fallback the cloning feature introduces no breaking changes to 1.10.x, but I'd like to have other people's opinions, because I might have missed a lot of things.
note:
I reverted most changes in the Orchard.Localization module, even though I liked them better than what's in it right now, to avoid mixing too many concerns in a single pull request. (Also, I'd rather have a Translating feature, that falls back to cloning as a default, than a Cloning feature that may optionally also do translation, but this is not the place to go on about this)