Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#41200 closed defect (bug) (duplicate)

Documentation outdated for current_user_can()

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

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
9 years ago

  • Milestone Awaiting Review
  • Resolution → invalid
  • Status new → closed
  • Version trunk → 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
9 years ago

  • Component Comments → Users
  • Focuses docs added
  • Resolution invalid → duplicate

Duplicate of #37393, see also #37402.

#3 @kluny
9 years ago

Thanks for the clarification!

Note: See TracTickets for help on using tickets.