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

Issue #3230125: Improve profile feature cohesion #2478

Conversation

Kingdutch
Copy link
Member

@Kingdutch Kingdutch commented Aug 27, 2021

Problem/Motivation

Open Social has various modules that handle functionality related to user profiles (e.g. social_profile_privacy and social_profile_fields). Most of the functionality is optional but has a big impact on the way sites work when they're enabled. This requires modules that extend profile functionality to implement multiple paths depending on what configuration of modules is enabled.

Additionally each module implements their own features in a way that does not properly utilise Drupal's access and fields system but instead relies on form and display alter hooks.

Finally because the functionality is split among several modules, configuration forms are either split out over multiple pages or require using form alter hooks, leading to a poor user and developer experience.

Proposed resolution

Merge the functionality of the social_profile_fields, social_profile_privacy and our internal social_registration_fields module into the social_profile module.

Create a unified configuration screen that allows a site manager to edit whether a profile field is enabled, who can see it, who can edit it, whether it's required and whether it should be shown on the registration field.

Use Drupal's fields and permission system to handle the different options. For every editable profile field a "visibility" field is added to the profile as well. This is used to store the per-user visibility of their fields (this allows altering database or search queries based on field visibility) (this data was previously stored in users.data).

Issue tracker

https://www.drupal.org/project/social/issues/3230125

TODO

  • Provide user feedback on their profile about visibility of fields (the behaviour w.r.t. hide-profile-email.feature -- which was removed -- has changed in that a user viewing their own profile would not see their email if they hid it, but the new access levels makes this difficult, so a different indication is needed to show they can always see their own email)
  • Determine that an SM changing the privacy of a field has the correct behaviour if a user hasn't overwritten their visibility (i.e. should it follow the new setting, or should it have the value at the time of profile creation)
  • Ensure change records for this PR as well as the PRs split off from this one are correctly created and published.

How to test

TODO

Screenshots

TODO

Release notes

TODO

Change Record

Requires multiple change-records, Todo:

  • Introduce view debug information permission
  • Explain changes in user permissions, e.g. anonymous users may now access user profiles which is needed to view teaser profile information. However a new permission is required for list users to prevent access to pages like search or GraphQL lists and to disallow enumerating all users on a platform.
  • Removal of social_profile_fields
  • Removal of social_profile_privacy
  • Merge of social_profile_registration in social_profile
  • Introduction of visibility fields for profiles (and how to opt out)
  • Introduction of using field API and permissions to manage Social Profile settings.
  • user_information view has been removed, route view.user_information.user_information is replaced with social_profile.view_user_profile. Profile is now rendered using full view mode.
  • \Drupal\social_user\Controller\SocialUserController::accessUsersPages is removed and should be replaced with _entity_access: user.view. Access checking now properly happens on an entity level.

Translations

Translatable strings are always extracted from the latest development branch. To ensure translations remain available for platforms running older versions of Open Social the original string should be added to translations.php when it's changed or removed.

  • Changed or removed source strings are added to the translations.php file.

@Kingdutch Kingdutch added type: refactoring Updates code for improved maintenance without changing its functionality status: needs work This pull request needs more work before it's ready for review prio: high team: shipsters labels Aug 27, 2021
@Kingdutch Kingdutch self-assigned this Aug 27, 2021
@Kingdutch Kingdutch force-pushed the feature/improve-profile-feature-cohesion branch 3 times, most recently from 5b0337b to 4aa31b1 Compare September 2, 2021 10:05
@navneet0693 navneet0693 changed the base branch from 10.3.x to main September 8, 2021 09:03
@Kingdutch Kingdutch added this to the 11.0.0 milestone Sep 10, 2021
@Kingdutch Kingdutch force-pushed the feature/improve-profile-feature-cohesion branch 12 times, most recently from 930a328 to 3643139 Compare September 21, 2021 08:22
@Kingdutch Kingdutch added needs work: commit cleanup This change requires a decision record in Slite status: don't merge labels Sep 23, 2021
@Kingdutch Kingdutch force-pushed the feature/improve-profile-feature-cohesion branch from 3643139 to 8c0c3bd Compare September 23, 2021 09:22
@Kingdutch
Copy link
Member Author

Work and tests in this PR depends on #2512 and #2516 so these are temporarily included in this PR in a merge branch. The work from those PRs should be removed from this branch before moving. Hence the commit clean-up tags.

@Kingdutch Kingdutch force-pushed the feature/improve-profile-feature-cohesion branch from 8c0c3bd to c58dd56 Compare September 28, 2021 16:02
@Kingdutch Kingdutch removed the needs work: commit cleanup This change requires a decision record in Slite label Sep 28, 2021
@Kingdutch Kingdutch force-pushed the feature/improve-profile-feature-cohesion branch from 9e26c2d to 36a612b Compare September 30, 2021 12:21
To make our code simpler we require that a profile exists and use
hook_user_insert to make sure this happens regardless of how the user is
created. However there was an issue in the profile module that caused a
profile to be saved after use creation and its related hooks were
completed.

Depending on how we responded to that it would cause the profile not to
be created at all or it would cause a duplicate profile to be created
which then still failed being default.

This change includes a patch to optimize the way profiles are created in
the profile module during user registration which also ensures the
profile is available during welcome e-mail sending.
We want to protect the overview of users on platforms which is why we
introduced the `list user` permission which is also coming from Drupal
issue #2953566. Unverified users were already not allowed to view the
user search but they were still allowed to search for users through the
"all" search which is inconsistent.

This commit ensures that unverified users also can't use the all search
to enumerate users. We need a separate check for this with respect to
anonymous users because unverified users are able to see user profiles
with the fields that can be seen by unverified users whereas anonymous
users can't view profiles at all.
This was originally built because customers wanted real names to be
public while still providing the user with the ability to hide their
real name behind a nickname. However implementing this same logic in the
current system has become quite complicated.

Users now also have the ability to control the visibility of their
profile fields more specifically which allows them to also hide their
real name behind a nickname if the site managers give them the ability
to do so.

We ensure an upgrade path is included to make sure the behaviour doesn't
unexpectedly change.

This change reveals that the autocomplete still needs work to ensure it
works with the new permission system. We should probably change the
autocomplete to use the user search instead.
We expand our wordlist to include newly used words and the configuration
is updated to ignore Drupal's mangled field names in configuration for
the social_profile module.
The group update adds the variation cache module however code in the
group module is triggered during other updates which relies on that
module, causing a fatal error.

For background see
https://www.drupal.org/project/group/issues/3134690
https://www.drupal.org/project/group/issues/3135757
https://www.drupal.org/project/drupal/issues/3150512

See 0adf6c0
This moves the widget and formatter functionality from social_tagging
into a social_tag_split module. This allows it to also be reused by
other functionality like the social_profile's profile tagging, without
having to enable the social_tagging module which comes with content
tagging.
This commit removes the profile tag settings and brings the feature in
line with how content tagging works. We always enable the tag splitting
because the no-split scenario can be emulated by only creating a single
category. The access management can now be performed through the generic
field settings and no longer requires special settings. The
`use_category_parent` existed to allow searching for profiles with “any
tag in category” which doesn’t require selecting a special value during
editing but can be done during search using the facets widget.
In a9f41db we ensured that search
queries required the `list user` permission so that search can not be
used to enumerate users. This was needed because otherwise users might
show up on the "All" search page.

The user search still had a custom permission. However we don't actually
expose a configuration page for that permission. So we change the view
to use the permission that is actually needed in the underlying data
system and we remove the special purpose permission.
We had initially deprecated the SocialProfileTagSplitWidget in 12.0.0
for removal in 13.0.0. However, it relies on the SocialProfileTagService
for which we have already migrated and cleaned up the config, so in
practice those systems already don't work.

I think it's better to remove the code and have a hard-break than keep
the code around in a non-functioning matter creating subtle bugs for
people. I also don't want anyone to accidentally build on or extend the
old system.

Unfortunately it is not possible to deprecate these things in 11.x
already because the replacement can't be introduced until 12.0.0. This
makes the break a bit harder but we'll write an update guide to help out
developers.
The required setting for the profile tag field wasn't propagated to the
subfields that were being created.
This has been quite the challenge. There is code that's unaware of the
existence of profiles, but that inadvertently triggers code that
requires profiles. For example the `ginvite` module needs to send
notifications when a user is created and does this in
`hook_user_insert`. However this includes the display name of the
account to address the user. We want to do this with their name if
they've filled out this information on the registration page.

We use module_implements_alter to change the order in which hooks fire
to make sure the profile and social_profile hooks are always run first.
This ensures whenever a user is saved, a profile will exist (together
with the profile patch added earlier) and makes sure the user's name is
properly generated if available.

A backtrace is added to logging because figuring all this out without it
was a pain.
We already had this styling in our FollowTag formatting, but it's
actually a universal design pattern for tags in Open Social that they're
displayed as small pills. To accomplish this we add the classes in our
TagSplitFormatter so that themes can use this.

This is accompanied by a field file change in socialbase that ensures
the main label for the profile tag field is not shown but the individual
labels of the subfields are rendered as labels instead.
When the role was introduced we installed new sites with "Verified user"
capitalization but the update introduced it with "Verified User". In
case the roles are used in labels that are clicked in tests, these
differences in capitalization are problematic, and it also just doesn't
look the way we intend for a large part of our customerbase.

Our designer gave the following answer: "Based on our microcopy approach
(Slite/Humans/Product language) we don’t use Title Case, which means
that the right option is ‘Verified user’."

This commit updates existing sites and pulls them in line with the
correct spelling already used in new sites.
It's a bit weird to add a patch for something we manage. However we have
a chicken/egg problem. We can't add the new twig file to socialbase
because it'll break the existing profile tagging functionality. However,
we require it to properly display the new profile tagging display
structure and pass our tests.

We include the patch until the profile refactor is released, then we can
tag a new socialbase version with the fix and update within Open Social
while removing the patch.
Profile tagging was something that was allowed for content managers. So
in our upgrade path the content managers get the permission by default.
This breaks our test which expects the content manager not to have
access to any fields and thus see an access denied page.
The subfield settings upgrade path did not take the scenario where the
social_profile_fields module was disabled. We implement the fallback to
act as if the module was disabled and use the default address field
behaviour.
@Kingdutch Kingdutch force-pushed the feature/improve-profile-feature-cohesion branch from 0069c50 to dbacd5d Compare August 23, 2023 13:24
@Kingdutch Kingdutch added status: needs review This pull request is waiting for a requested review and removed status: don't merge status: needs work This pull request needs more work before it's ready for review labels Aug 23, 2023
@Kingdutch Kingdutch marked this pull request as ready for review August 23, 2023 14:55
@Kingdutch Kingdutch removed their assignment Aug 23, 2023
@Kingdutch Kingdutch merged commit 5650d70 into issue/3348399-3348407-3353443-solr-unified-search-with-content-tagging Aug 23, 2023
189 checks passed
@Kingdutch Kingdutch deleted the feature/improve-profile-feature-cohesion branch August 23, 2023 14:55
@ronaldtebrake ronaldtebrake modified the milestones: 13.0.0, 13.0.0-alpha1 Apr 23, 2024
@ronaldtebrake
Copy link
Contributor

Removed milestone since this likely will be postponed to 14.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prio: high status: needs review This pull request is waiting for a requested review type: refactoring Updates code for improved maintenance without changing its functionality
Development

Successfully merging this pull request may close these issues.

3 participants