Page MenuHomePhabricator

EventBus - user entity schema should differentiate between explicit and implicit user groups
Closed, DeclinedPublic

Description

The mediawiki.page_change schema designed in T308017: Design Schema for page state and page state with content (enriched) streams created a reusable user entity schema. This schema has a groups string array field to represent a user's groups.

When emitting mediawiki.page_change events from EventBus, the UserEntitySerializer calls UserGroupManager getUserEffectiveGroups to set the groups array. getUserEffectiveGroups returns both 'implicit' and 'explicit' user groups.

In T423952: Create mediawiki.user_change event stream, we want to emit an event for when a user's groups change. We can use the UserGroupsChanged hook. However, this hook only gives us the old and new explicit user groups.

We can choose to set user groups to the union of explicit $newGroups and getUserEffectiveGroups, but we have no way of knowing what the prior_state 'implicit' user groups are.

This means that prior_state.user.groups will only contain prior explicit groups, while user.groups will contain current implicit+explicit groups.

If explicit and implicit groups were in different fields, we could choose to only include prior_state for things that changed when UserGroupsChanged was fired: explicit user groups.

Event Timeline

Alternatively, we can assume that implicit groups do not change when UserGroupsChanged is fired. So, we can just set

user.groups = newGroups + getUserImplicitGroups()
prior_state.user.groups = oldGroups + getUserImplicitGroups()

I think that will be sufficient and backwards compatible. I'll try that, and if it works, will decline this task.

Declining this. The workaround in T425360#11887651 is probably sufficient. It would be nice to do it, but the impact would be minimal and the effort high.