Make WordPress Core

Opened 10 years ago

Last modified 8 days ago

#38312 assigned defect (bug)

Network setup step 2 throws warning in certain server setups

Reported by: ruud@… Owned by: realloc
Priority: normal Milestone: Future Release
Component: Networks and Sites Version: 3.5
Severity: normal Keywords: has-patch
Cc: Focuses: multisite

Description

Hi,

I got this error on my local server:
Warning: Strpos(): Empty delimiter in wp-admin\includes\network.php line 344

I tracked this down to line:
$home_path = 0 === strpos( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();

After some more digging, it seems to me that it's possible that this line is causing the initial problem:
$document_root_fix = str_replace( '
', '/', realpath( $_SERVERDOCUMENT_ROOT ) );

Since realpath() can be false in some server setups, $document_root_fix can be empty as well (hence the error)

From http://stackoverflow.com/questions/7906513/realpath-returns-empty-string:

Note: The running script must have executable permissions on all directories in the hierarchy, otherwise realpath() will return FALSE.

So your web server should have access also to pre-webroot directories.

Leaving us with perhaps unexpected behavior of the lines following.

I'm not quite sure what to do next, since the next couple of lines are quite hard to grasp.

Thanks,
Ruud

Change History (3)

#1 @jeremyfelt
10 years ago

  • Version trunk3.5

Hi @ruud@…, thanks for opening a ticket. I haven't looked too closely yet, but this can be tracked back to #23073, which has some good background discussion / testing on this area.

This ticket was mentioned in PR #12916 on WordPress/wordpress-develop by @realloc.


8 days ago
#2

  • Keywords has-patch added

https://core.trac.wordpress.org/ticket/38312

When realpath( $_SERVER['DOCUMENT_ROOT'] ) returns false, $document_root_fix was an empty string, and str_starts_with() with an empty needle always returns true. This made the get_home_path() fallback unreachable in precisely the scenario it was intended for, leaving $home_path set to just the base path.

Also guards against $_SERVER['DOCUMENT_ROOT'] being unset, which triggered an undefined array key notice and a realpath( null ) deprecation on PHP 8.1+.

#3 @realloc
8 days ago

  • Milestone Awaiting ReviewFuture Release
  • Owner set to realloc
  • Status newassigned
Note: See TracTickets for help on using tickets.