Make WordPress Core

Opened 8 years ago

Last modified 5 days ago

#43880 assigned enhancement

Add functionality to add an anonymous user an get its ID for anonymization of data related to a WordPress user.

Reported by: TZ Media Owned by: tz-media
Priority: normal Milestone: Future Release
Component: Privacy Version:
Severity: normal Keywords: has-patch needs-unit-tests 2nd-opinion
Cc: Focuses:

Description

When we need to anonymize data that is (or can be) associated with a WordPress user, we anonymize it by changing the user ID of that data to a user that represents anonymized content. But currently no such user exists, so we set the ID to 0.

In order to display an actual user name (at least for posts), we would need an actual user 'Anonymous' that we can re-assign the content to.

This might be created on WordPress install by default (maybe even with a User ID of 0 that we can then hardcode into the anonymized functions), or by calling a function like _wp_privacy_get_anonymous_user_id() that creates the user if not already created and returns the user ID (that might be stored in a site_option).

Attachments (4)

43880.patch (1.9 KB ) - added by TZ Media 8 years ago.
Helper function to generate an anonymous user and get its ID.
43880.1.patch (2.0 KB ) - added by TZ Media 8 years ago.
Checks if cached user id actually exists instead of returning it blindly.
43880.2.diff (2.0 KB ) - added by lbenicio 8 years ago.
added unit tests to path 43880
43880.3.diff (544 bytes ) - added by lbenicio 8 years ago.
move unit test to the correct place

Download all attachments as: .zip

Change History (20)

@TZ Media
8 years ago

Helper function to generate an anonymous user and get its ID.

#1 @TZ Media
8 years ago

  • Keywords has-patch needs-testing needs-unit-tests 2nd-opinion added; needs-patch removed
  • Adds a helper function _wp_privacy_get_anonymous_user_id() that generates an anonymous user if none exists and return its ID.
    • Returns 0 if no user could be created.
  • Adds a type of user_id to the existing wp_privacy_anonymize_data() helper function to allow easy anonymization of a user ID.

Questions: How can we prevent logins and wp_admin access by that user by all means? I've set the password to null and the role to the non-existing role anonymous_user, but I hope there's a more elegant way to achieve this.

#2 @desrosj
8 years ago

  • Milestone Awaiting Review4.9.6
  • Owner set to tz-media
  • Status newassigned

@TZ Media
8 years ago

Checks if cached user id actually exists instead of returning it blindly.

#3 @TZ Media
8 years ago

Thinking of that... if we create a new user, because something went wrong with the old one (deleted by admin or whatever), should we reassign all posts/comments etc. to the newly created user automatically? And if so, should we do this inside the function itself, or schedule an event that reassigns them?

#4 @TZ Media
8 years ago

Note: This extends #43545, so that patch needs to be backported before this can be back ported to 4.9.6.

#5 @desrosj
8 years ago

  • Milestone 4.9.64.9.7

#6 @desrosj
8 years ago

  • Milestone 4.9.74.9.6

This ticket was mentioned in Slack in #gdpr-compliance by desrosj. View the logs.


8 years ago

#8 @allendav
8 years ago

Cool idea. If we create a user automagically, we should carefully consider roles/capabilities for the user, whether they should ever be able to log in (probably not), etc.

Maybe .7 to allow time for us to think this through?

#9 @desrosj
8 years ago

  • Milestone 4.9.64.9.7

@lbenicio
8 years ago

added unit tests to path 43880

#10 @desrosj
8 years ago

  • Milestone 4.9.7Future Release

Moving gdpr tickets that are not bugs to Future Release until the next steps can be properly evaluated.

#11 @desrosj
8 years ago

  • Component GeneralPrivacy

Moving to the new Privacy component.

@lbenicio
8 years ago

move unit test to the correct place

#12 @dejliglama
8 years ago

Instead of moving data to a fake user "anonymous" - why not use the anonymizing functions on what ever user we anonymize, and instead change the ROLE of the user to anonymous.

So what IS new in the system, is a role that has no rights what so ever.

Doing it like this, you keep any data integrity between posts, and other data, since you don't move things arround.

#13 @desrosj
8 years ago

  • Keywords gdpr removed

Removing the GDPR keyword. This has been replaced by the new Privacy component and privacy focuses in Trac.

#14 @huzaifaalmesbah
6 months ago

  • Keywords needs-refresh added; needs-testing removed

I attempted to apply the latest patch (43880.3.diff) against current trunk (7.0-alpha-61215-src).

The patch does not apply cleanly:

  • tests/phpunit/tests/functions/anonymization.php (.rej created)

Because the patch fails to apply, the changes cannot be tested at this time. The patch appears outdated and needs to be refreshed to match current trunk before further testing.

Removing needs-testing and adding needs-refresh.

#15 @sukhendu2002
5 days ago

I opened PR https://github.com/WordPress/wordpress-develop/pull/12396 to refresh the previous patch against current trunk.

The PR adds _wp_privacy_get_anonymous_user_id() to create/retrieve a marked anonymous user for anonymized content, and updates comment erasure so erased comments are assigned to that anonymous user instead of user ID 0. It also handles stale cached IDs, reuses an existing marked anonymous user, avoids granting the anonymous user any role, and includes updated PHPUnit coverage. Review and feedback would be appreciated.

#16 @sukhendu2002
5 days ago

  • Keywords needs-refresh removed
Note: See TracTickets for help on using tickets.