WordPress.org

Make WordPress Core

Opened 17 months ago

Closed 17 months ago

Last modified 17 months ago

#44455 closed defect (bug) (invalid)

PHP Doc for non-existing argument + Argument type mismatch

Reported by: subrataemfluence Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.1
Component: Users Keywords: close
Focuses: docs, coding-standards Cc:
PR Number:

Description

File name:/wp-includes/capabilities.php

Non-existing arguments in Doc comments:

function map_meta_cap( $cap, $user_id ) {
   ...
}

function current_user_can( $capability ) {
   ...
}

Argument type mismatch:

function is_super_admin( $user_id = false ) {
   ...
}

Uploading a proposed patch.

Attachments (1)

44455.diff (2.0 KB) - added by subrataemfluence 17 months ago.

Download all attachments as: .zip

Change History (3)

#1 @swissspidy
17 months ago

  • Keywords close added; needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Attention! map_meta_cap() and current_user_can() do have this second parameter. For various reasons, these aren't in the function signature but instead accessed via func_get_args()

Regarding the is_super_admin() change: your change would indicate that one can pass true or false to the function and expect it to work. However, that is not the case. Think of it as $user_id = null, where null (or in this case, false) is the default value. If we were to change this, it should be discussed & decided in the docs team first, and standardized in https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/. However, personally I'd rather change it to $user_id = null instead of adjusting the docs. But for BC reasons that's probably not possible in every case.

#2 @subrataemfluence
17 months ago

Thank you for correcting me.

Note: See TracTickets for help on using tickets.