Make WordPress Core

Opened 9 months ago

#59729 new defect (bug)

By setting int to the parameter of the function path_is_absolute(), a Notice will always be output.

Reported by: mt8biz's profile mt8.biz Owned by:
Milestone: Awaiting Review Priority: normal
Severity: trivial Version: 2.5
Component: Filesystem API Keywords:
Focuses: Cc:

Description

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?

Attachments (1)

path_is_absolute.patch (417 bytes) - added by mt8.biz 9 months ago.

Download all attachments as: .zip

Change History (1)

Note: See TracTickets for help on using tickets.