Skip to content
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

Mark duplicate permissions as Obsolete #16176

Merged
merged 7 commits into from
May 29, 2024

Conversation

MikeAlhayek
Copy link
Member

I think these static properties were added at some point to provide backward compatibility.

I am marking these properties as obsolete for now, we can then remove them in 3.0 or later.

Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build is failing.

@MikeAlhayek MikeAlhayek requested a review from Piedone May 28, 2024 17:05
@@ -6,13 +7,17 @@ namespace OrchardCore.Apis.GraphQL;

public class Permissions : IPermissionProvider
{

[Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ExecuteGraphQLMutations'.")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not properties, but fields. And more importantly, a reference to the project/package name would help those consumers who don't have the whole of OC referenced:

Suggested change
[Obsolete("This property will be removed in future release. Instead use 'CommonPermissions.ExecuteGraphQLMutations'.")]
[Obsolete("This field will be removed in a future release. Instead use 'CommonPermissions.ExecuteGraphQLMutations' from OrchardCore.Apis.GraphQL.Abstractions.")]

Especially because there are many CommonPermissions classes.

Same for all the others.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

field is used when you are declaring a private property. a property when it is public. + Does it really matter? I ask this because these changes consume time for the PR creator to do. During a review, we should ask yourself these questions so that the PR creator does not have to spent lots of time doing changes that add no value. At the end of the day, we want to merge acceptable PR without burden the creators with lots of changes "when possible".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A field and a property are different language features, and this one here is a field. Both can be public and private (or else) too. I'm only pointing this out because it specified "property"; if it were "This will be removed..." or "This member will be removed.." (which are all alternatives BTW) I wouldn't ask for it to include "field".

You can do a search and replace for this and fix it in seconds though, perhaps less than what it takes to debate this :).

Note the more important second part of my comment about the package though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not about the debate here. The issues is that we need to think about the value of the comment if it out weight the effort. Many PR end up consuming lots of man hours from (reviewers and creator) due to this type of comment.

I have added the namespaces to the message for developers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not about this instance here, then let's take this conversation offline.

@MikeAlhayek MikeAlhayek requested a review from Piedone May 28, 2024 22:51
@hishamco
Copy link
Member

Why need to make them obsolete, while we're on the 2.0.0 release?

@MikeAlhayek
Copy link
Member Author

Why need to make them obsolete, while we're on the 2.0.0 release?

Just so that developers have a migration path. We can remove these Obsolete attributes in 3.0.

@hishamco
Copy link
Member

Stange!! I notice there are many obsolete methods already removed since 1.0.0, I'm not sure what the point of removing or keeping some while it's a major release (breaking changes are expected)

@MikeAlhayek
Copy link
Member Author

Strange!! I notice there are many obsolete methods already removed since 1.0.0, I'm not sure what the point of removing or keeping some while it's a major release (breaking changes are expected)

Because in the migration from v1 to v2 we instructed users to first update to 1.8 then just to 2.0. This way they resolve all warnings and get their databases to run on 1.8. then they can migrate to v2. Since these changes are part of the 2.0, we should give the users a migrations path.

@hishamco
Copy link
Member

The migration might be useful but not necessary from within the code base, SemVer all of us know that a major release will introduce breaking changes, it is just a comment, so we can make things right and consider user expectations

I spend years using ASP.NET Core and bumping the versions, when it's a major I expected anything I could change in my libraries or apps

Maybe, our fault since the beginning when we accept the breaking changes in minor releases. This is a side note but I don't want to disturb the PR

@Piedone
Copy link
Member

Piedone commented May 28, 2024

If we'd have a 1.9 with just these changes, and then remove all the obsolete methods in 2.0, then that would be the best. This is the approach every SemVer-following project, including ASP.NET Core, take. However, we can't release 1.9, so this is the next best thing.

Having a new major version means we can include breaking changes, not that we should. If we can feasibly make our users' lives easier with these upgrades (including ourselves, maintaining OC apps), then it's better we do that.

From 2.0 we can do better.

Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my recent commit; feel free to revert.

@@ -6,9 +6,10 @@ namespace OrchardCore.Search.Elasticsearch;

public class ElasticsearchIndexPermissionHelper
{
public static readonly Permission ManageElasticIndexes = new("ManageElasticIndexes", "Manage Elasticsearch Indexes");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if there was some kind of circular dependency issue or something else hard to see why this was necessary before, but testing Elasticsearch didn't bring up any issues. So, this just looks like an oversight.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing this was originally placed here incorrectly and kept that way. Everything passes so I don't see any issue from this.

@MikeAlhayek MikeAlhayek merged commit b527fb5 into main May 29, 2024
20 of 21 checks passed
@MikeAlhayek MikeAlhayek deleted the ma/obsolete-duplicate-permissions branch May 29, 2024 00:03
@hishamco
Copy link
Member

@Piedone but there're a few places that might break such as changing the documents in the database, I closed a few PRs because I was waiting for 2.0.0

@Piedone
Copy link
Member

Piedone commented May 29, 2024

I don't really see how that contradicts what I've said.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants