Opened 10 months ago

Last modified 10 months ago

#21526 new defect (bug)

get_post_type_capabilities() assumes $args->capabilities is an array

Reported by: wpsmith Owned by:
Priority: normal Milestone: Awaiting Review
Component: Role/Capability Version:
Severity: normal Keywords: dev-feedback 2nd-opinion
Cc:

Description

get_post_type_capabilities() assumes $args->capabilities is an array and should check and confirm it. Otherwise a warning appears: Warning: array_merge() [function.array-merge]: Argument # 2 is not an array in /home/username/public_html/wp-includes/post.php on line 1183. I discovered this when I accidentally set this to null instead of array().

Type setting it seems to clear the warning, if we want to clear the warning.

$capabilities = array_merge( $default_capabilities, (array)$args->capabilities );

Attachments (1)

21526-post_capabilities_array_merge.patch (557 bytes) - added by wpsmith 10 months ago.

Download all attachments as: .zip

Change History (3)

  • Keywords dev-feedback 2nd-opinion added

This feels like a user error, and a error that should be left in place so that Developers *know* they've passed something wrong in..

Note: See TracTickets for help on using tickets.