-
Notifications
You must be signed in to change notification settings - Fork 43
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
fix: authors and guest authors in homepage posts #1082
Conversation
## [1.46.2-hotfix.1](v1.46.1...v1.46.2-hotfix.1) (2022-03-28) ### Bug Fixes * clauses filter when querying CAP guest authors in homepage posts ([a13707f](a13707f)) * fetchSavedAuthors query in editor ([bcbea28](bcbea28))
…b.com/Automattic/newspack-blocks into hotfix/author-query-in-homepage-posts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm no longer getting the query error but am still getting unexpected results:
I have a WP user linked to a guest author, let's name them Linked 1 and Guest 1. Guest 1 is the author of 2 posts and Linked 1 does not author any post.
I also have another guest author, Guest 2, not linked to a WP user, which is the author of 1 post.
With 2 blocks, one querying Linked 1 and the other Guest 2, I get the expected posts on the editor but the frontend only shows the posts from the Guest 2 block.
If I change the Linked 1 block to query from Guest 1, I get the same expected result on the editor but while the Guest 1 block shows the expected posts on the frontend, the Guest 2 block stops showing its posts.
@miguelpeixe you're right, there's still something weird going on here with the linked accounts. Investigating... |
@miguelpeixe This needed a lot more work to get functioning with multiple different guest author queries. I found that the Because this Lastly, the discrepancies between editor and front-end query results were tripping me up, so I refactored the editor-based query functions to use the same cc @kariae because I believe you added the Edit to add: b9fd0e4 fixes Specific Posts mode in the editor, which was broken by refactoring the posts endpoint params to more closely match the block attributes. |
I realize the changeset of this PR is getting a bit big for a hotfix, so let me know if you think we should rebase this on |
Thanks @dkoo, @miguelpeixe for digging into this.
I like the split fix you did here Derrick, and it did fix the above issues for me. IMHO, this is still a hotfix as we're using a workaround that fixed the discussed issues. But I think we need to stop it here, I dug a bit about how CAP do their queries and it seems a bit complex but I think we need to follow the same logic (so that we don't have to create smaller logic blocks depending on if we have co-authors or not or a mix of co-authors and WP users). The filter used by CAP to filter an author's posts , I think we can use the same logic in case we need to do some refactoring here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The blocks now work with all different combinations of deduplication and author/co-authors filters I've tried 🙌
There's also a good improvement in readability for this complex logic 🙇
I'm a bit hesitant to have this merged as a hotfix. Although not visible, it is a big change in a very core feature. I'll let you decide, @dkoo!
This is really helpful—thanks for digging this up! I'll do a bit of testing to see if I can refactor our
This was my fear, too—this change might directly affect the homepages of every Newspack publisher. I think the safe way to merge this feature would be to rebase the changes on |
@miguelpeixe and @kariae, based on the discussion above I'm closing this PR in favor of #1083. Please review the additional commit and testing instructions in that PR. |
All Submissions:
Changes proposed in this Pull Request:
Fixes four bugs related to author querying:
include
query param when fetching saved authors to display in the block sidebar controlsHow to test the changes in this Pull Request:
SQL syntax error and linked accounts
master
, add several Homepage Posts blocks to a post and filter them by a regular WP user, a guest author with no linked account, and a guest author with a linked account. For ease of testing, use the same authors in all blocks and add separators between block instances so you can easily see where one block ends and the next begins.Saved authors in block sidebar controls
master
and refresh the editor with your test blocks.Unrelated CAP guest author posts
master
. In one of the test Homepage Posts blocks, filter by the WP user in step 1. Observe that in the editor and on the front-end, the block displays post(s) created by the WP user but assigned to unrelated guest authors.Posts Carousel block
No changes were made to the Posts Carousel block, but it uses some of the same query functions and endpoints, so we should test it in the editor and on the front-end to ensure it still behaves as expected.
Other information: