OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

IContentManager.CreateAsync() should not publish the content item by default

Open hishamco opened this issue 10 months ago • 2 comments

Fixes #18049

/cc @sebastienros

hishamco avatar Jun 16 '25 23:06 hishamco

The arguments sounds good, but this is a very risky change. I'm sure there was a reason for how this was done originally. Was it publishing from its inception? And it's a subtly breaking change that you only may notice during runtime, and as such, should be well documented.

Piedone avatar Jun 17 '25 00:06 Piedone

@Piedone seems there's a flaky test. I just re-run the failed jobs and they are passed :)

I agree that we need to document this, also I need to do a few tests

hishamco avatar Jun 17 '25 03:06 hishamco

Merging main to see if the tests will now pass

MikeAlhayek avatar Jun 18 '25 07:06 MikeAlhayek

It passes

hishamco avatar Jun 18 '25 12:06 hishamco

I agree with @Piedone, this is a risky change. Maybe it is better to make the VersionOptions parameter required, i.e. do not allow null anymore and remove the default. That would be a breaking change that is obvious to any caller.

gvkries avatar Jun 19 '25 07:06 gvkries

I avoid breaking change, while we document these changes, nothing risky IMHO BTW, we react to these changes, and I check the content management as it works as expected

It's more like behavior change, but I don't think someone is using 'create' for publishing when there's a publish option. However, I don't have any objection. Also, let's hear @sebastienros feedback, and it would be nice if we could triage this tonight

hishamco avatar Jun 19 '25 07:06 hishamco

In this we are changing behavior of an existing interface which no one will notice until it breaks at runtime. If we change it (and I think your reasoning makes sense), we should break the build in such cases.

gvkries avatar Jun 19 '25 07:06 gvkries

In this we are changing behavior of an existing interface which no one will notice until it breaks at runtime. If we change it (and I think your reasoning makes sense), we should break the build in such cases.

I agree. I think you should modify the IContentManager.CreateAsync by making the second argument required. and document that If you want to created a published version, then pass VersionOptions.Published as the second argument otherwise, we suggest passing VersionOptions.DraftRequired and publish using the PublishAsync api

MikeAlhayek avatar Jun 19 '25 16:06 MikeAlhayek

We should close this PR and improve the documentation instead (at least the API doc).

sebastienros avatar Jun 19 '25 17:06 sebastienros

I might agree with @gvkries & @MikeAlhayek

@sebastienros it's not a matter of the documentation, it doesn't make sense to publish the content while there's a specific API, but it could be done explicitly

hishamco avatar Jun 19 '25 18:06 hishamco

After thorough discussion, we have decided to maintain the current behavior of the API. While we acknowledge that the existing design is not ideal from a modern API design perspective, we believe that altering the behavior at this stage would introduce unnecessary risk and limited benefit. Below are the key reasons supporting this decision:

  1. Longstanding Design Stability The current API design has remained unchanged since Orchard 1 (O1), providing a consistent and predictable interface for developers over many years.

  2. Minimal Demand for Change There have been very few requests or issues raised by the community regarding this method, suggesting that the current behavior is either well-understood or not problematic in practice.

  3. Risk of Breaking Changes Modifying the behavior of this method would constitute a breaking change, potentially impacting existing applications that rely on the current implementation. Given the API’s long history, the cost of such a change outweighs the benefits.

  4. Improved Documentation as a Mitigation Strategy To address any confusion or limitations in the current design, we propose enhancing the documentation: particularly by adding detailed remarks in the source code. This approach provides clarity without disrupting existing consumers of the API.

gvkries avatar Jun 20 '25 07:06 gvkries

If that's the case I will close this PR and open another one by providing a docs in that method

hishamco avatar Jun 20 '25 11:06 hishamco

Closed in favor of #18069

hishamco avatar Jun 20 '25 11:06 hishamco