[wp-trac] [WordPress Trac] #44654: Use DIRECTORY_SEPARATOR instead of always using forward slash
WordPress Trac
noreply at wordpress.org
Thu Jul 26 19:03:57 UTC 2018
#44654: Use DIRECTORY_SEPARATOR instead of always using forward slash
--------------------------+-----------------------------
Reporter: mnelson4 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
If you try to run WordPress on windows, where the directory separator is a
backslash instead of a forward slash, there are a few spots where the
folder paths are wrong.
We should always be using forward slashes in URLs, but filepaths should
use the DIRECTORY_SEPARATOR constant. This way, the filepaths are ok on
Windows machines too.
For example, `wp-config-sample.php` has this:
{{{#!php
<?php
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
}}}
Which, in windows, is producing a path like this:
'E:\Software\laragon\www\laragonwp/`. Notice the last slash is the wrong
direction! That can cause problem when a Windows machine is trying to read
a file in that filepath.
That code should instead be
{{{#!php
<?php
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
}}}
I think these filepath issues have gone unnoticed because it's pretty rare
to run WordPress directly on a Windows machine (usually folks use a
virtual machine or linux subsystem on Windows 10). But I think this might
become more prevalent because I'm seeing some better tools for Windows (eg
https://laragon.org/) and running npm from within a virtual machine using
a Windows host has problems (eg
https://core.trac.wordpress.org/ticket/44271)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44654>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list