Opened 14 years ago
Closed 14 years ago
#16457 closed defect (bug) (worksforme)
Issues with DIRECTORY_SEPARATOR
Reported by: | grandslambert | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0.4 |
Component: | General | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
I recently switched my Recipe Press plugin to use the DIRECTORY_SEPARATOR instead of a hard coded '/', as suggested in another ticket. However, on a Windows Server this now breaks two parts of my plugin, two important parts.
The plugin registers a menu icon, which uses an object variable for the Plugin URL which is built using DIRECTORY_SEPARATOR. This works OK on *nix based machines, but NOT on Windows.
I also use DIRECTORY_SEPARATOR in wp_register_scripts() function, and on a Windows based machine the scripts do not load due to a missing separator between the plugin name and the folder the script is in.
So, do we continue to use DIRECTORY_SEPARATOR, which works in most instances, or just hard code a '/' and let the core convert it?
Change History (5)
#2
@
14 years ago
- Keywords reporter-feedback added; DIRECTORY_SEPARATOR removed
The plugin registers a menu icon, which uses an object variable for the Plugin URL which is built using DIRECTORY_SEPARATOR. This works OK on *nix based machines, but NOT on Windows.
Code, please.
#3
@
14 years ago
The plugin registers a menu icon, which uses an object variable for the Plugin URL which is built using DIRECTORY_SEPARATOR. This works OK on *nix based machines, but NOT on Windows.
DIRECTORY_SEPARATOR is the filesystem separator, Not a HTTP Separator, As such, attempting to use it in a string which is used as a URL will cause problems.
Core doesnt convert /, rather, in many places it converts "
" to / in order for a consistent path environment, You cant do str_replace() on strings which have mixed separators, nor strpos() etc, which causes havoc with certain functions, When you take into account that WordPress itself is using / in all the paths it hard-codes, it becomes even more of an awkward environment on windows.
Like scribu said however, Show us the code! We might need to add some win32=>linux path format sanitization in a few more places.
According to dd32's comment, I guess DIRECTORY_SEPARATOR should not be used. At least not for URLs. '/' is supported on both platforms.