Closed MarGraz closed 5 months ago
Isn't this what https://github.com/OrchardCMS/OrchardCore/pull/11433 addresses?
A note for this and https://github.com/OrchardCMS/OrchardCore/pull/11433 @hyzx86 about AllVersions
:
GetAsync(contentItemId, VersionOptions options)
: that method will always return at most a single content item, so it can't return all versions of a content item. That method should throw an exception with this input.GetAsync(IEnumerable<string> contentItemIds, VersionOptions options)
though, since it returns multiple items anyway. However, this might get confusing there, when you get back N ContentItem
s, but those are mixed as versions and content items.Also, there's no need for something like an AnyVersion
or to change this to satisfy the expectations of this bug report, since Latest
is already for that.
I suggest we remove the AllVersions
option since it's not used, and not working, and the expectations wouldn't be fulfilled when you pass multiple content item ids.
If a user wants historical list of version they would use the ContentItemIndex to filter them. We could add a custom method that takes a simple query filter and would use the Load from DefaultContentManager to handle the lifecyle events.
https://github.com/OrchardCMS/OrchardCore/pull/16077 takes the make it work approach, with throwing in GetAsync(contentItemId, VersionOptions options)
and returning all versions in GetAsync(IEnumerable<string> contentItemIds, VersionOptions options)
.
Any comments?
For an explanation, see comments below from https://github.com/OrchardCMS/OrchardCore/issues/16027#issuecomment-2115840661. We should remove
VersionOptions.AllVersions
.The original issue below is kept for context.
Describe the bug
The method
_contentManager.GetAsync(model.ContentItemId, VersionOptions.AllVersions)
fails to return any content items, whether published or draft. When debugging in Visual Studio with "Just my code" disabled, execution enters the conditionelse if (options.IsDraft || options.IsDraftRequired)
inDefaultContentManager
here.I'm unsure why this condition is satisfied, given that my content item is published and the boolean
IsDraft
andIsDraftRequired
are set tofalse
.Screenshots are provided for reference.
To Reproduce
Steps to reproduce the behavior:
IContentManager
from dependency injection to retrieve the Content Item by its ID withVersionOptions.AllVersions
set, like this:_contentManager.GetAsync(model.ContentItemId, VersionOptions.AllVersions)
Expected behavior
A published or drafted Content Item must be returned when I set
VersionOptions.AllVersions
Screenshots
My Content Item:
IsDraft
andIsDraftRequired
are false, why the condition is satisfied?