Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#41200 closed defect (bug) (duplicate)

Documentation outdated for current_user_can()

Reported by: kluny's profile kluny Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0
Component: Users Keywords:
Focuses: docs Cc:

Description

https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/capabilities.php#L538

Doc says the function takes two parameters, but the source code allows for only one.

Change History (3)

#1 @swissspidy
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version changed from trunk to 2.0

Hey there,

Welcome to Trac!

The function actually takes one ore two arguments, see https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/capabilities.php#L544: $args = array_slice( func_get_args(), 2 );. func_get_args() returns everything you pass to the function (could be dozens of args), and the array_slice() call limits it to three.

I understand it can be a bit misleading though because the func_get_args() call is not obvious at first glance. It's probably been like this since the introduction of the function, so doing things like actually adding the parameters could perhaps break some things.

I'm therefore closing this ticket but if you feel like this should be handled differently, let us know.

#2 @SergeyBiryukov
8 years ago

  • Component changed from Comments to Users
  • Focuses docs added
  • Resolution changed from invalid to duplicate

Duplicate of #37393, see also #37402.

#3 @kluny
8 years ago

Thanks for the clarification!

Note: See TracTickets for help on using tickets.