[wp-trac] [WordPress Trac] #60059: Warning / Error in wp-includes/canonical.php when $_GET['author'] is an array

WordPress Trac noreply at wordpress.org
Wed Dec 13 13:13:11 UTC 2023


#60059: Warning / Error in wp-includes/canonical.php when $_GET['author'] is an
array
--------------------------+-----------------------------
 Reporter:  david.binda   |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Canonical     |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 On a WordPress install with pretty permalinks turned on, there is a PHP
 warning or error (depends on the PHP version) when viewing an author on
 frontend, while the `$_GET['author']` is an array. For instance:


 {{{
 /author/canonical-author/?author[1]=hello
 }}}

 produces following fatal error on PHP 8+:

 {{{
 Fatal error: Uncaught TypeError: preg_match(): Argument #2 ($subject) must
 be of type string, array given
 }}}

 and following warning on lower versions of PHP:

 {{{
 Warning: preg_match() expects parameter 2 to be string, array given
 }}}

 Related code line: https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/canonical.php?rev=56738#L319

 A fix seems to be to check if `is_string( $_GET['author'] )` before
 performing the `preg_match`.

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


More information about the wp-trac mailing list