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

Ensure author ID is correctly set. #1133

Merged
merged 2 commits into from
Sep 10, 2023

Conversation

peterwilsoncc
Copy link
Collaborator

@peterwilsoncc peterwilsoncc commented Sep 7, 2023

Description of the Change

In block themes an invalid author ID (such as zero) prevents the filter running on the author name due to some code in the post author block.

This modifies the check for an invalid author ID when pulling/pushing posts to ensure that a valid ID is used.

When pulling from an external post, this removes the author ID of the remove user and records the post as authored by the user pulling the post. Author IDs almost certainly do not match across external connections so there is a risk the author is being assigned to a user that ought not be able to edit the post.

Closes #1129

How to test the Change

  1. Install Distributor on a network
  2. Activate the 2023 theme if required
  3. Create a sub-site
  4. Use WPCLI to generate posts on the main site wp post generate --count=10 -- this will generate posts with the author 0
  5. On the sub-site, uncheck "pull as draft" pull one of the generated posts
  6. Once the post has been pulled, click view for the post
  7. The author block should correctly show the source site on the front end.

Changelog Entry

Fixed - Invalid author IDs being set when pushing and pulling posts.

Credits

Props @peterwilsoncc

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@peterwilsoncc peterwilsoncc marked this pull request as ready for review September 7, 2023 22:23
@peterwilsoncc peterwilsoncc requested a review from a team as a code owner September 7, 2023 22:23
@peterwilsoncc peterwilsoncc requested review from faisal-alvi and removed request for a team September 7, 2023 22:23
@peterwilsoncc peterwilsoncc self-assigned this Sep 7, 2023
@peterwilsoncc peterwilsoncc added this to the 2.0.1 milestone Sep 7, 2023
Copy link
Member

@faisal-alvi faisal-alvi left a comment

Choose a reason for hiding this comment

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

@peterwilsoncc I appreciate your pull request. It looks good to me.

I tested it in the develop branch, and the issue reappeared. Then, I examined the PR branch, and the problem has been resolved.

In the develop branch:

image

In this PR branch:

image

@peterwilsoncc peterwilsoncc merged commit 40b10f2 into develop Sep 10, 2023
18 checks passed
@peterwilsoncc peterwilsoncc deleted the fix/1129-ensure-author-id-set branch September 10, 2023 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Block themes] Pulled posts author details are not replaced as author is unset
2 participants