Opened 4 years ago
Last modified 7 days ago
#56429 new defect (bug)
Gutenberg author box missing
| Reported by: | lgadzhev | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Editor | Version: | 6.0.1 |
| Severity: | normal | Keywords: | has-test-info has-patch has-unit-tests |
| Cc: | Focuses: | javascript, administration, rest-api |
Description
There is a bug related to the author box missing when all of the following conditions are true:
- When there are more than 70 users in a WP installation
- When an Editor creates a post and saves it as a draft. This must be the only post of that user
- If all the users are ordered alphabetically, that user must be above 60 in the order
When this is true, if another Editor opens that draft, the author box won't be visible. There is an additional request that should fetch that user and it's returning error 403
If Administrator opens it, the author box is present
The cause for the bug is the last condition that fails here - https://github.com/WordPress/WordPress/blob/master/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php#L445 because the function checks for the author of the post
Change History (9)
This ticket was mentioned in Slack in #core-test by ironprogrammer. View the logs.
4 years ago
#4
@
4 years ago
Will try to add the missing info:
Testing Instructions
These steps define how to reproduce the issue, and indicate the expected behavior.
Steps to Reproduce
- Log in to your local WP installation and create 100 "dummy" users with role Editor. If you have wp CLI enabled you can use this command
for i in {1..100}; do wp user create editor${i} editor${i}@editor${i}.com --user_pass=editor${i} --role=editor; done. This will create 100 users with equal combination of username and password like "usernameN"/"passwordN", e.g. editor1/editor1, editor2/editor2, editor3/editor3, etc. - Log in with user "editor1", create a new "Test Post" and set the Author to "editor99" (by searching in the input field) - https://i.imgur.com/Lxw1ybe.png
- 🐞 Log in in incognito mode or with a different browser with user "editor2" and open the very same post. You will notice that the Author post is not visible and you cannot change the Author - https://i.imgur.com/vG9QrTf.png
Expected Results
When testing a patch to validate it works as expected:
- ✅ The Author box should always be visible whether it's in the first 50 users in the dropdown ordered alphabetically or not. Every editor should have the ability to see who's the author of the post and have the ability to change it.
When reproducing a bug:
- ❌ The bug happens when inside a WP installation there are more than around 50 users. When a user enters the Block Editor, the author dropdown shows around 50 users max - https://nimb.ws/EtcaeH. You can freely use the dropdown search, even for editors but still, the initial load shows only around 50 users in the dropdown. Normally this is fetching the first users in alphabetical order. If the user is among the first 50 users, it's going to be shown as the author of the post and everything will be fine but if it's not, the Block Editor will make an additional call to fetch that specific user. Unlike the call that is used for the dropdown's search, this call returns more information about the user and requires some additional capabilities, which Editors as user role don't have and it's breaking the author box
#6
@
19 months ago
I’ve opened the issue on Gutenberg repository: https://github.com/WordPress/gutenberg/issues/69921
#7
@
19 months ago
Reposting similar findings from the GitHub issue:
There's a logic difference between get_item_permissions_check and get_items_permissions_check.
get_item_permissions_check- allowscontext=viewrequests as long as the user has one post published. https://github.com/WordPress/wordpress-develop/blob/a1bce5f880b7c7b125f92fa468c2adedd354ece5/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php#L488get_items_permissions_check- allowscontext=viewquery for authors as long as the current user can edit posts. https://github.com/WordPress/wordpress-develop/blob/9063e30f6f34d313ecdc3394f45ca63283732b24/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php#L236-L245
I believe these inconsistencies need to be addressed in the REST API, which enables the editor to access related data.
This ticket was mentioned in PR #15351 on WordPress/wordpress-develop by @Mamaduka.
7 days ago
#9
- Keywords has-patch has-unit-tests added; needs-patch removed
PR lets users without list_users filter wp/v2/users by the edit_posts capability of post types where they can edit_others_posts, and view a single user holding that capability. Before, an editor opening a draft whose author has no published posts got a 403 for that user, and the editor's author control was missing.
The single-user permission check allowed only users with published posts, but the editor needs to be able to assign any user as an author. The capabilities filter also gives the editor a replacement for the deprecated who=authors fallback:
who=authors | capabilities (this PR)
| |
|---|---|---|
| Required capability | edit_posts on any author-supporting type | edit_others_posts on that type
|
| Matches | Users with user_level other than 0 | Users holding that type's edit_posts capability
|
Type maps edit_posts to read | Subscribers can list all users above level 0 | Still requires edit_others_posts
|
| Listed user viewable by ID | No, 403 without published posts | Yes |
The single-user check reads $user->allcaps instead of has_cap() so it agrees with the capability__in query, which only sees stored capabilities, not ones added via map_meta_cap or user_has_cap. Users who can assign authors can now view any user holding these capabilities by ID, including administrators, matching what the collection returns.
To test:
- Create two editors:
wp user create editor1 editor1@example.com --role=editorandwp user create editor2 editor2@example.com --role=editor. - Log in as
editor2, open any post in the editor, and runawait wp.apiFetch( { path: '/wp/v2/users/<editor1 ID>' } )in the browser console. It returnseditor1instead of a 403.
To check the author control too, run wp user generate --count=100 --role=editor, assign a generated user as the author of a draft, and open that draft as editor2. The author control shows that user.
WP_Test_REST_Users_Controller passes on single site and multisite.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Implementation, security review and tests; reviewed and edited by me.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Thank you for the report, @lgadzhev, and welcome to Trac!
Detailed steps to reproduce the issue would be very useful here.