wecodemore / wpstarter

Easily bootstrap whole site Composer packages for WordPress.
https://wecodemore.github.io/wpstarter/
MIT License
244 stars 34 forks source link

Change in root-folder `index.php` breaks some detection scripts #35

Closed schlessera closed 8 years ago

schlessera commented 8 years ago

The Codex article gives a very specific code snippet under point 9. of how to go about letting the site know about the subfolder WordPress is installed in.

Hosting providers like SiteGround rely on this line of code to detect whether WordPress was installed in a subfolder, and modify their system setup accordingly (for things like version detection, caching extensions, etc...).

WPStarter has changed this line to use realpath instead of the code that is recommended in the Codex, which breaks detection on these hosts.

Is there a specific reason why this was changed to use realpath? I'd like to investigate whether we could leave that particular file exactly as is recommended in the Codex, and solve whatever issue realpath was meant to solve in a different location.

gmazzap commented 8 years ago

@schlessera we can use the same line that core uses.

I myself add this issue once, and shipped the index.php under version control, then prevented WP Starter to edit it via prevent-overwrite setting.

The only reason for realpath was that the path to load is "calculated" by WP Starter. If something goes wrong in calculation, realpath return false so the line do nothing, and avoid to try to load an inexistent file which will cause a fatal error.

However, since I use WP Starter, bad calculation never happened, so I guess we can remove it with no issue.

If you have time for a PR I'll merge it, otherwise I'll do the change later today.

schlessera commented 8 years ago

Just tested, and an absolute path seems to work. Also, it does not seem to depend on specific whitespace.

So, your proposed change should solve this issue.

gmazzap commented 8 years ago

Solved with b3b84ef. The fix is included in v2.3.2.

GaryJones commented 8 years ago

I've got 2.3.2, and yet, when I do a new install, or rename wp-config.php to something else and call composer run wpstarter, I get wp-config.php with the realpath part still present.

GaryJones commented 8 years ago

Oh, this PR only affected index.php. Nevermind.