Opened 2 years ago
Closed 2 years ago
#57996 closed enhancement (fixed)
Change $search_columns type from array to string[].
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.2.1 | Priority: | normal |
Severity: | normal | Version: | 6.2 |
Component: | Query | Keywords: | fixed-major |
Focuses: | docs | Cc: |
Description
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.
Change History (6)
#2
@
2 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 55597:
#3
follow-up:
↓ 4
@
2 years ago
- Keywords fixed-major added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for 6.2.1 consideration.
Note: See
TracTickets for help on using
tickets.
Thanks for the ticket!
The
search_columns
parameter is already documented asstring[]
inWP_User_Query
as of [49693], and inWP_Site_Query
as of [51184], so it definitely makes sense forWP_Query
too. Introduced in [55248].To match the above two classes, I think
string[]
would be preferable here, rather thanstring|string[]
. While a string can technically be passed too, we should encourage passing an array for consistency.