#23175 closed enhancement (fixed)
Make get_home_path() return consistent slashes
Reported by: | SergeyBiryukov | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Filesystem API | Keywords: | has-patch |
Focuses: | Cc: |
Description (last modified by )
As noted in ticket:23073:40, get_home_path()
doesn't return consistent slashes.
If home
and siteurl
are identical, it falls back to ABSPATH
:
C:\wamp\www\multitest/
If home
and siteurl
are different:
C:/wamp/www/wordpress/test_subd/
Attachments (3)
Change History (15)
#3
@
12 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 23669:
#4
follow-up:
↓ 6
@
12 years ago
- Cc bananastalktome@… added
- Keywords needs-unit-tests added
- Resolution fixed deleted
- Status changed from closed to reopened
Breaks unit test test_get_home_path
in tests/admin/includesFile.php
1) Tests_Admin_includesFile::test_get_home_path Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'D:\root\vhosts\site\httpdocs/' +'D:/root/vhosts/site/httpdocs/'
(I'm reopening the ticket because of this, which I think is the proper thing to do in these cases. Please let me know if this is not what I should do.)
#5
@
12 years ago
In 1244/tests:
#6
in reply to:
↑ 4
@
12 years ago
- Keywords needs-unit-tests removed
- Resolution set to fixed
- Status changed from reopened to closed
Replying to bananastalktome:
I'm reopening the ticket because of this, which I think is the proper thing to do in these cases.
It is, thanks.
#7
@
12 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Could this have come from the various
define('ABSPATH', dirname(__FILE__).'/');
commands scaretted accross multiple files? I took the liberty of creating a diff.
#9
@
12 years ago
- Keywords dev-feedback removed
- Resolution set to fixed
- Status changed from reopened to closed
Yes, the trailing slash in ABSPATH
is inconsistent in Windows, but it's out of scope for this ticket, and it's not really an issue, since Windows allows to use both types of slashes.
23175.3.patch would make the slashes inconsistent on non-Windows installs.
#10
@
12 years ago
it's not really an issue, since Windows allows to use both types of slashes
Well, it could be if you are doing path string manipulations. What if we used DIRECTORY_SEPARATOR
instead?
define('ABSPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
Would that address non-Windows OSs?
it's out of scope for this ticket
If you agree with the above, should I create a new ticket and update the diff?
Thanks!
#11
@
12 years ago
I'd suggest to normalize the slashes with str_replace( '\\', '/', ... )
before doing any string manipulations. This is what the core does in a few functions.
Using DIRECTORY_SEPARATOR
was previously discussed in #15598, #17494, #20849, and #22267. The consensus in each ticket was that it's not needed.
I've reviewed all the instances of
get_home_path()
in core to make sure both types of slashes are allowed there (since it currently returns both types anyway).It's mostly used in
file_exists()
andwin_is_writable()
checks, which is fine.