[wp-trac] [WordPress Trac] #47678: Modernize/simplify current_user_can()

WordPress Trac noreply at wordpress.org
Thu Jul 18 05:55:37 UTC 2019


#47678: Modernize/simplify current_user_can()
-------------------------------------+-------------------------------------
 Reporter:  jrf                      |       Owner:  pento
     Type:  enhancement              |      Status:  assigned
 Priority:  normal                   |   Milestone:  5.3
Component:  Role/Capability          |     Version:  trunk
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch has-unit-      |     Focuses:  performance, coding-
  tests commit needs-dev-note        |  standards
-------------------------------------+-------------------------------------

Comment (by jrf):

 I've just added another set of patches to this ticket.
 Passing build which includes all the patches in this ticket which haven't
 been committed yet: https://travis-ci.com/WordPress/wordpress-
 develop/builds/119576361

 == Notes for select patches in the current set

 === `walk_category_tree()` and `walk_category_dropdown_tree()`

 Both these functions referred in the documentation to a `walk()` method in
 one of the `Walker` child classes, but as the child classes in WP Core
 don't overload the `walk()` method, that link in the documentation
 resulted in a 404.

 I've changed those links now to `Walker:walk()` so they will resolve
 properly in the documentation.

 Refs:
 * https://developer.wordpress.org/reference/functions/walk_category_tree/
 *
 https://developer.wordpress.org/reference/functions/walk_category_dropdown_tree/

 === `do_action()`

 I'm removing the complete code block quoted below.

 This is PHP 4 code. In PHP 4, objects were not automatically passed by
 reference which is the only explanation I can come up for the current way
 of setting up the `$args` array.
 As of PHP 5, objects are always passed by reference, so what was being
 done here has not been needed for quite some time.


 {{{#!php
 <?php
         $args = array();
         if ( is_array( $arg ) && 1 == count( $arg ) && isset( $arg[0] ) &&
 is_object( $arg[0] ) ) { // array(&$this)
                 $args[] =& $arg[0];
         } else {
                 $args[] = $arg;
         }
         for ( $a = 2, $num = func_num_args(); $a < $num; $a++ ) {
                 $args[] = func_get_arg( $a );
         }
 }}}

 === `apply_filters()`

 Removing the call to `func_get_args()` would not have any benefits here,
 but we can remove the duplicate function call.



 == Review Status

 These are the last patches for the review of all `func_get_args()` calls
 in the codebase.
 For the remaining calls to `func_get_args()` I didn't see any real benefit
 in making this change for various reasons.

 Based on a review of the function calls to `call_user_func_array()`, I
 expect to add yet some more patches to this ticket.

 == Commit Status

 The following patches have not been committed yet:
 * `Walker::walk()` and `Walker::paged_walk()` - see discussion above.
 * `wp_register_sidebar_widget()`
 * The new patches just added.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47678#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list