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

Hotfix/migrate guest authors cli #3724

Open
wants to merge 5 commits into
base: release
Choose a base branch
from

Conversation

leogermani
Copy link
Contributor

All Submissions:

Changes proposed in this Pull Request:

This PR changes the logic of the guest author migration script.

Basically, the script was checking if a guest user already existed as a regular WP user based on the user_login. I'm changing that to check for the user_nicename.

In a regular situation, the nicename will usually be the same thing as the login, but there are cases where they can be different. One of them is when you migrated users from another system and treated these fields in a different way in the database.

CAP uses the $user->user_nicename to create and match the author term, and that's why this is the field we should look at.

How to test the changes in this Pull Request:

  1. Create a few guest authors and assign posts to them.
  2. Run the script and make sure the guest contributors users are created and the posts are correctly assigned.
  3. Create a guest author and make sure there is a wp user that has its nicename with the same value of the GA's login
  4. Run the script and make sure no new WP user is created, and the posts that were assigned to that GA is assigned to this WP user

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?

@leogermani leogermani added the [Status] Needs Review The issue or pull request needs to be reviewed label Feb 4, 2025
@leogermani leogermani self-assigned this Feb 4, 2025
@leogermani leogermani requested a review from a team as a code owner February 4, 2025 21:03
Copy link
Contributor

@eddiesshop eddiesshop left a comment

Choose a reason for hiding this comment

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

This seems to work as advertised from my testing. Just want to note though that after the first time I ran the script and the Guest Authors were converted to Users, I was unable to create another Guest Author with the same details because the system prevents the nicenames from being duplicated. So what I did instead was I added an extra character to the display name (which governs what nicename gets created), then manually went into the DB and updated the cap-user_login field for the GA to match the nicename of the previously converted user. The script worked just fine still, but if this level of intervention (manually updating values in the DB) isn't within the scope of testing please let me know.

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Approved The pull request has been reviewed and is ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants