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

Assorted changes 2 #98

Merged
merged 7 commits into from
May 23, 2024
Merged

Assorted changes 2 #98

merged 7 commits into from
May 23, 2024

Conversation

adekbadek
Copy link
Member

@adekbadek adekbadek commented May 13, 2024

All Submissions:

Changes proposed in this Pull Request:

  1. Tweaks to the memberships deduplication CLI command, added in Membership de-duplication CLI command #84
  2. A fix to username generation, to ensure too-long usernames are not used
  3. Adds handling of syncing of users who already exist on the other site, but have a non-synchronizable role
  4. Some refactoring

(Note: this is a part of integrating the changes from the data-integrity-improvements branch (#89))

How to test the changes in this Pull Request:

  1. Test membership deduplication command, as described in Membership de-duplication CLI command #84, but instead of a --dry-run flag observe it will dry run by default, making any changes only with --live flag provided. This brings it in line with other CLI command in this repository.
  2. On one network site, using CLI (front-end won't let you!), create a Subscriber user with an email address that exceeds 60 characters.
    1. Wait for the user to sync, or trigger a sync
    2. Observe that the user's username on the other network sites is based on the email address, but cut to not exceed 60 characters
  3. Create two users on two different network sites, with the same email address, but different roles:
    1. Create an Editor (a non-synchronizable role) using WP Admin or WP CLI
    2. Register using the Registration block (or the auth modal) on the second site
    3. Run the reader-registered-event backfill (wp newspack-network data-backfill reader_registered --start=2020-01-01 --end=2024-12-31 --live) from the second site
    4. Wait for the user to sync, or trigger a sync
    5. Observe that on the first site, the user has both roles now

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@adekbadek adekbadek requested a review from a team as a code owner May 13, 2024 09:00
Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

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

I'm not sure if this is something wrong with my local Network sites' setup, but for steps 2 and 3, when the node site's users got synced to my hub site, they came in without any role.

Screenshot 2024-05-15 at 5 29 19 PM

Also getting a fatal error in the Users page—see below.

@@ -8,14 +8,13 @@
namespace Newspack_Network\Hub\Admin;

use Newspack_Network\Admin as Network_Admin;
use const Newspack_Network\constants\EVENT_LOG_PAGE_SLUG;
Copy link
Contributor

Choose a reason for hiding this comment

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

This new constant needs to be imported in class-users.php, too: https://github.com/Automattic/newspack-network/blob/assorted-changes-2/includes/class-users.php#L78

Copy link
Member Author

@adekbadek adekbadek May 16, 2024

Choose a reason for hiding this comment

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

Fixed in 8f91df9, thanks!

@adekbadek
Copy link
Member Author

when the node site's users got synced to my hub site, they came in without any role.

That should not ever happen, can you please list the exact reproduction steps?

Also, I've realized the step 3 instructions were wrong (synced user has to register using RAS, not be created with CLI), so I've updated this step. I don't think this relates to the issue described above, though.

@adekbadek adekbadek requested a review from dkoo May 22, 2024 08:44
@adekbadek
Copy link
Member Author

@dkoo – I've requested a re-review, but what I meant was pinging you about the reproductions steps, as mentioned in the comment above.

@dkoo
Copy link
Contributor

dkoo commented May 22, 2024

Got this working. Everything is working as described except for this step:

Observe that the user's username on the other network sites is based on the email address, but cut to not exceed 60 characters

In my testing, the user with the really long email address got propagated across the network, but the username was set to match the username of the account on the original site (not the email address). This username string was already shorter than 60 characters because CLI wouldn't let me create a user with a username longer than that.

@adekbadek
Copy link
Member Author

Ah, that's right – the user_name will be overridden if already set on the origin site:

'user_login' => $this->data->user_login ?? $email,

@adekbadek adekbadek merged commit 9f74e75 into trunk May 23, 2024
3 checks passed
@adekbadek adekbadek deleted the assorted-changes-2 branch May 23, 2024 07:41
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.9.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request May 31, 2024
# [1.9.0-alpha.1](v1.8.0...v1.9.0-alpha.1) (2024-05-31)

### Features

* handle existing users by adding a role; username generation and membership dedupe command fixes ([#98](#98)) ([9f74e75](9f74e75)), closes [#84](#84)
matticbot pushed a commit that referenced this pull request Jun 12, 2024
# [1.9.0](v1.8.0...v1.9.0) (2024-06-12)

### Features

* handle existing users by adding a role; username generation and membership dedupe command fixes ([#98](#98)) ([9f74e75](9f74e75)), closes [#84](#84)
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants