[wp-trac] [WordPress Trac] #50067: Notice if arg passed is an array in author

WordPress Trac noreply at wordpress.org
Sun May 3 11:45:52 UTC 2020


#50067: Notice if arg passed is an array in author
--------------------------+------------------------
 Reporter:  malthert      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Canonical     |     Version:  5.4
 Severity:  normal        |  Resolution:  duplicate
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------
Changes (by SergeyBiryukov):

 * status:  new => closed
 * resolution:   => duplicate
 * milestone:  Awaiting Review =>


Old description:

> If bots try urls like: /?author[]=1
> The following code will give a notice:
> Warning: preg_match() expects parameter 2 to be string, array given
>
> `} elseif ( is_author() && ! empty( $_GET['author'] ) && preg_match(
> '|^[0-9]+$|', $_GET['author'] ) ) {`
>

> Fix:
>
> ```
> } elseif ( is_author() && ! empty( $_GET['author'] ) && ! is_array(
> $_GET['author'] ) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) {
> ```

New description:

 If bots try urls like: /?author[]=1
 The following code will give a notice:
 Warning: preg_match() expects parameter 2 to be string, array given

 `} elseif ( is_author() && ! empty( $_GET['author'] ) && preg_match(
 '|^[0-9]+$|', $_GET['author'] ) ) {`


 Fix:

 `} elseif ( is_author() && ! empty( $_GET['author'] ) && ! is_array(
 $_GET['author'] ) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) {`

--

Comment:

 Hi there, welcome back to WordPress Trac!

 Thanks for the report, we're already tracking this issue in #17737.

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


More information about the wp-trac mailing list