-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix GetAsync not work when option is AllVersion #11433
Conversation
x.ContentItemId == contentItemId && | ||
x.Published == false && | ||
x.Latest == true) | ||
x.ContentItemId == contentItemId) |
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.
Hmm, I think better to not take into account soft deleted items having both Published = Latest = false.
x.ContentItemId == contentItemId && (x.Latest || x.Published)
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 really, if you select AllVersion but it is still restricted. It's confusing
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.
Hmm, I think better to not take into account soft deleted items having both Published = Latest = false.
@jtkech Yes, you are right, if you want to get different versions, you need to specify the version number.
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.
We need to have a DeletedVersion option then too I think.
x.ContentItemId == contentItemId && (!x.Latest && !x.Published)
But maybe not necessary for now.
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.
But the current content state is a little bit too complicated. For example, as a new person, you need to look up code or documentation to fully understand what the state means
Can you describe what "doesn't work" so we can recommend the best approach? Maybe open an issue? |
Retrieving AllVersions all at once with the ContentManager. |
Or as I understood, return any active version, maybe in priority the published version if it exists, or a draft version if it exists, that' why here the suggested code uses But currently it then uses Maybe it should use |
Yes, it is the same problem as this one, Because my program uses SPA mode, much of the data manipulation is done through the Api |
mean is this filter option is never used in this method, But now it seems that just changing this doesn't make much sense, because if no filtering conditions are attached, a ContentItem will be obtained randomly (or with a minimum ID), so at least one ContentVersionId needs to be specified here |
Since this option doesn't serve any purpose, can we remove it? OrchardCore/src/OrchardCore/OrchardCore.ContentManagement.Abstractions/IContentManager.cs Line 265 in 5d3cdca
|
Maybe we could have used AllVersions for the GetAsync() that returns a collection, currently we use a For the GetAsync that returns only one item, hmm maybe we could have used an AnyVersion with the behavior I described here #11433 (comment), but was just an idea, maybe too confusing ;) So yes, if we keep the existing code I agree with you, maybe better to just get rid of the AllVersions option, or as said above and if we think it is worth, maybe use it for a GetAsync that returns a collection of items. Note: Here we are talking about active versions (Published or Latest), Published and Latest are not versions in themselves but properties of a given version (related to a given contentItemVersionId), a content item having some versions but no active versions is a soft removed item. |
@jtkech OrchardCore/src/OrchardCore/OrchardCore.ContentManagement/DefaultContentManager.cs Line 239 in 4093d2e
But even if I copied it, I found OrchardCore/src/OrchardCore/OrchardCore.ContentManagement/DefaultContentManager.cs Line 416 in 4093d2e
Finally, I wrote l index query directly by referring to the code in AdminController OrchardCore/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs Line 310 in 4093d2e
|
It allows to call the contentManager LoadAsync() on each contentItem which call handlers to activate correctly items if not yet done by looking at the contentManagerSession cache. |
Yes, I see. I mean, the current implementation of content manager is not complete enough |
As additional info, as it is done when using content manager GetAsync(), activating item meaning activating item parts/fields |
This pull request has merge conflicts. Please resolve those before requesting a review. |
@@ -262,12 +262,12 @@ public class VersionOptions | |||
/// <summary> | |||
/// Gets all versions. | |||
/// </summary> | |||
public static VersionOptions AllVersions { get { return new VersionOptions { IsAllVersions = true }; } } | |||
public static VersionOptions AnyVersion { get { return new VersionOptions { IsAnyVersions = true }; } } |
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.
Keep the property but with [Obsolete]
, telling people to use this, so they'll know what's up instead of wondering after a build error.
More importantly though, I think the intent here is indeed to return all the versions of a content item. So, while this might not make sense for GetAsync(IEnumerable<string> contentItemIds, VersionOptions options)
, it does for GetAsync(string id, VersionOptions options)
. So, I don't think this should be changed.
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.
Please provide unit tests.
We should rather remove |
Fixes #16027