Added ability to view all post types when Pulling from an External Connection
Description of the Change
Closes #861
How to test the Change
- Go to Distributor > Pull Content (Make sure you have added an internal as well as external connection)
- Check and confirm that "View All" filter is available for both internal and external connection
- Check and confirm that filtering with "View All", displays posts from all the post types for both internal and external connection
Changelog Entry
Fixed - Bug fix
Credits
Props @mehul0810 @ravinderk @cadic @peterwilsoncc
Checklist:
- [x] I agree to follow this project's Code of Conduct.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my change.
- [x] All new and existing tests pass.
In #1017 (awaiting merge) I've made a bunch of modifications to the rest api endpoint that should make this more achievable. It will probably cause a lot of conflicts to this PR though.
You'll be able to use post_type => any once that PR is merged as the custom endpoint will modify the value to only include post types the user can read, either because they have permission or the post type is publicly viewable.
@mehul0810 thanks for the PR! Could you please rebase your PR on top of the latest changes in the base branch?
@mehul0810 thanks for the PR! Could you please fill out the PR template with description, changelog, and credits information so that we can properly review and merge this?
I can confirm that I can see something strange as well. It looks like when we select "view all" only posts by "admin" users are shown. That's what it looks on the surface(which may not be the case as well), needs more investigation.
https://github.com/user-attachments/assets/0a4b3c88-a76e-466d-89f5-51af791adbda
I think what I and sid observed was perhaps a security fix, so it's all good? https://github.com/10up/distributor/pull/1003#pullrequestreview-2002371696
@peterwilsoncc if this looks good to you, please merge, thanks!
I think what I and sid observed was perhaps a security fix, so it's all good? #1003 (review)
It looks like it's a bug in WP_Query when querying multiple post types using the perm argument added as part of the security fix.
https://github.com/10up/distributor/blob/253cf825bb18ba6a5a7d22c3cec4034b9a09bfe3/includes/rest-api.php#L693
For multiple post types the edit_others_posts capability is ignored, for single post types it's checked and all posts are shown. I'm not sure whether it's by design to avoid overly complex SQL queries or an oversight.
E2E tests are failing on the main branch so bypassing the merge requirements.