[wp-trac] [WordPress Trac] #59729: By setting int to the parameter of the function path_is_absolute(), a Notice will always be output.

WordPress Trac noreply at wordpress.org
Wed Oct 25 10:12:11 UTC 2023


#59729: By setting int to the parameter of the function path_is_absolute(), a
Notice will always be output.
----------------------------+-----------------------------
 Reporter:  mt8.biz         |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Filesystem API  |    Version:  2.5
 Severity:  trivial         |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 I found this problem from my client's server logs.

 The simplest way to reproduce it is as follows.

 {{{
 % wp eval 'var_dump(path_is_absolute(1));'
  PHP Warning:  Trying to access array offset on value of type int in
 /var/www/html/wp-includes/functions.php on line 2123
 Warning: Trying to access array offset on value of type int in
 /var/www/html/wp-includes/functions.php on line 2123
  PHP Warning:  Trying to access array offset on value of type int in
 /var/www/html/wp-includes/functions.php on line 2133
 Warning: Trying to access array offset on value of type int in
 /var/www/html/wp-includes/functions.php on line 2133
 bool(false)
 }}}


 This occurs because the first character of String is processed as an array
 within the function.

 The client had written code like this:

 {{{
 $new_path = path_join( $path, get_the_ID() );
 }}}

 I think get_the_ID() should be cast to String, but why not make the
 function return False if it's not a String as well?

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


More information about the wp-trac mailing list