[wp-trac] [WordPress Trac] #44591: PHP notice if optional argument isn't passed to map_meta_cap()
WordPress Trac
noreply at wordpress.org
Tue May 17 18:59:42 UTC 2022
#44591: PHP notice if optional argument isn't passed to map_meta_cap()
---------------------------------------------+-----------------------------
Reporter: henry.wright | Owner: SergeyBiryukov
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.1
Component: Users | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests commit | Focuses:
---------------------------------------------+-----------------------------
Changes (by SergeyBiryukov):
* status: accepted => closed
* resolution: => fixed
Comment:
In [changeset:"53408" 53408]:
{{{
#!CommitTicketReference repository="" revision="53408"
Users: Fail gracefully when checking mapped capabilities without providing
the required object ID.
This avoids an `Undefined array key 0` PHP warning for
`current_user_can()` capability checks that require a specific object to
check against but an object ID was not passed.
A `_doing_it_wrong()` notice is also added, so that developers and site
administrators are aware that the capability mapping is failing in the
absence of the required object ID.
The list of mapped capabilities that require an object ID:
* `delete_post` / `delete_page`
* `edit_post` / `edit_page`
* `read_post` / `read_page`
* `publish_post`
* `edit_(post|comment|term|user)_meta` / `delete_*_meta` / `add_*_meta`
* `edit_comment`
* `edit_term` / `delete_term` / `assign_term`
Follow-up to [34091], [34113], [47178].
Props jeherve, peterwilsoncc, henry.wright, johnbillion,
mattheweppelsheimer, hellofromTonya, JeffPaul, azouamauriac, Ninos Ego,
TobiasBg, wpsmith, GaryJ, nacin, johnstonphilip, azaozz, SergeyBiryukov.
Fixes #44591.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44591#comment:39>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list