WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#25797 closed defect (bug) (fixed)

wp_guess_url() broken with symlinks involved

Reported by: bootc Owned by: dd32
Milestone: 3.8 Priority: normal
Severity: normal Version: 3.7
Component: Upgrade/Install Keywords: has-patch
Focuses: Cc:
PR Number:

Description

I was notified by a client that WordPress 3.7.1 was failing to install on their server. Essentially, the Apache DocumentRoot pointed at a location redirected using a symlink, and parts of the path pointed to by the symlink make their way into the URL during installation. This did not occur with WordPress 3.6. I developed a test case to replicate the problem:

  1. I installed a fresh Debian VM with a LAMP stack to test with.
  2. mkdir -p /srv/var/www
  3. rm -rf /var/www
  4. ln -s /srv/var/www /var/www
  5. Extract WordPress 3.7.1 into /srv/var/www.
  6. View the installation in a web browser.
  7. The Create a Configuration File link points at http://server/srv/wp-admin/setup-config.php instead of http://server/wp-admin/setup-config.php. Note the addition of /srv into the URL.

I'd say this was related to #25317, r25396, #24480, #16884, r25436.

Attachments (1)

25797.diff (860 bytes) - added by dd32 6 years ago.

Download all attachments as: .zip

Change History (10)

#1 @bootc
6 years ago

I should add that the bug can be worked around by defining WP_HOME and/or WP_SITEURL in the wp-settings.php file, or by changing Apache's DocumentRoot to point at the directory with all symlinks expanded.

#2 @backseat
6 years ago

  • Cc backseat added

#3 in reply to: ↑ description @loganbest
6 years ago

I can confirm that this also happens on FreeBSD. Had two clients report this today. However upgrading to 3.7 or 3.7.1 from 3.6.x works fine.

EDIT: This also happens with fresh 3.7 installs, not just 3.7.1.

Last edited 6 years ago by loganbest (previous) (diff)

#4 @SergeyBiryukov
6 years ago

  • Component changed from General to Upgrade/Install
  • Version changed from 3.7.1 to 3.7

#5 @dd32
6 years ago

  • Milestone changed from Awaiting Review to 3.8

Since this was a change in 3.7, arguably a regression, moving to 3.8 pending patch that can then be back ported if appropriate.

@dd32
6 years ago

#6 @dd32
6 years ago

  • Keywords has-patch reporter-feedback added

I wasn't able to duplicate this using the steps provided, but I was able to duplicate a similar issue when WordPress is installed in a subdirectory, and you're hitting an index.php in a higher level directory.

The string replace would replace /b/ in /a/b/c/ when it should be stripping off the /a/ as well, 25797.diff fixes that case.

I can't determine if that's the same problem as being reported here though, since the steps are radically different. Can you try the patch and see if it works for your case?

nginx unrolls symlinks in it's root, and Apache doesn't allow DocumentRoot to point to a Symlink (at least, not under default configurations), so the exact steps here were a bit hard to duplicate.

#7 @bootc
6 years ago

I've just tested attachment:25797.diff by applying it on top of 3.7.1, and this fixes the problem for me.

dd32: Not sure why you couldn't replicate the issue with my instructions, perhaps you were missing Options FollowSymLinks in your Apache configuration? It's on by default in Debian for /var/www.

Thanks!

#8 @bootc
6 years ago

  • Keywords reporter-feedback removed

#9 @dd32
6 years ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from new to closed

In 26031:

Fix a case where wp_guess_url() would leave a prefixed path in the generated URL when symlinks were involved. Fixes #25797

Note: See TracTickets for help on using tickets.