[wp-trac] [WordPress Trac] #57996: Change $search_columns type from array to string[].

WordPress Trac noreply at wordpress.org
Tue Mar 28 07:11:50 UTC 2023


#57996: Change $search_columns type from array to string[].
-----------------------------+-----------------------------
 Reporter:  tmatsuur         |      Owner:  (none)
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Query            |    Version:  trunk
 Severity:  normal           |   Keywords:
  Focuses:  docs             |
-----------------------------+-----------------------------
 The type of $search_columns added in version 6.2 is 'array'.

 {{{
          *     @type array           $search_columns          Array of
 column names to be searched. Accepts 'post_title',
          *
 'post_excerpt' and 'post_content'. Default empty array.
 }}}

 I think 'string[]' would be more appropriate for this 'array' to match
 other parameters.

 {{{
          *     @type string[]        $search_columns          Array of
 column names to be searched. Accepts 'post_title',
          *
 'post_excerpt' and 'post_content'. Default empty array.
 }}}

 This parameter is also converted to an array if it is not an array.

 {{{
 $search_columns         = ! empty( $q['search_columns'] ) ?
 $q['search_columns'] : $default_search_columns;
 if ( ! is_array( $search_columns ) ) {
         $search_columns = array( $search_columns );
 }
 }}}

 In light of the above, "string|string[]" would be better than "string[]".

 {{{
          *     @type string|string[] $search_columns          A column
 name (string) or array of column names to be searched.
          *                                                    Accepts
 'post_title', 'post_excerpt' and 'post_content'.
          *                                                    Default
 empty array.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57996>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list