-
Notifications
You must be signed in to change notification settings - Fork 13
fix null user list when overwriting all users profiles #163
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,7 +30,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private static readonly Type? _userManagerType = Type.GetType("MediaBrowser.Controller.Library.IUserManager, MediaBrowser.Controller"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private static readonly MethodInfo? _userManagerGetUserById = _userManagerType?.GetMethod("GetUserById", [typeof(Guid)]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private static readonly PropertyInfo? _userManagerUsersProperty = _userManagerType?.GetProperty("Users"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private static readonly MethodInfo? _userManagerGetUsers = _userManagerType?.GetMethod("GetUsers"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private static readonly MethodInfo? _internalItemsQuerySetUser = typeof(InternalItemsQuery).GetMethod("SetUser", BindingFlags.Public | BindingFlags.Instance); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private static readonly PropertyInfo? _internalItemsQueryUserProperty = typeof(InternalItemsQuery).GetProperty(nameof(InternalItemsQuery.User), BindingFlags.Public | BindingFlags.Instance); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private static readonly MethodInfo? _baseItemIsVisible = typeof(BaseItem) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1038,7 +1038,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private List<Guid>? GetAllServerUserIds() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (_userManagerType == null || _userManagerUsersProperty == null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (_userManagerType == null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
_userManagerType can resolve while none of the user members do |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1049,7 +1049,8 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (_userManagerUsersProperty.GetValue(userManager) is not IEnumerable<object> users) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| object usersObject = _userManagerGetUsers.Invoke(userManager,["null"]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Check warning on line 1052 in backend/Api/MoonfinController.cs
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Three problems on this line: GetUsers() is parameterless so ["null"] throws TargetParameterCountException every call; ["null"] is the string "null", not a null ref; and _userManagerGetUsers isn't null-checked. Rework the body to prefer the direct Guid member and fall back to the User collection, using method-or-property on each so it spans from 10.10.7 to 12.0 nicely. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (usersObject is not IEnumerable<object> users) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
To support 10.10.7 through 12.0 we need both the 10.11+ methods and the 10.10 properties, for both the Guid list and the User list.