Opened 11 years ago
Last modified 20 months ago
#29051 new defect (bug)
get_raw_theme_root : Windows paths
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | high |
| Severity: | critical | Version: | 3.9.1 |
| Component: | Themes | Keywords: | needs-patch |
| Focuses: | template | Cc: |
Description
I believe, this problem exists only if there are more than one theme directories.
For example, in my code I have:
register_theme_directory( ABSPATH . 'wp-content/themes/' );
Then, on Windows, the options table has:
INSERT INTO `xxx_options` VALUES (678,'template_root','C:\\the\\path\\to\\www.mysite.com\\wp/wp-content/themes/','yes');
INSERT INTO `xxx_options` VALUES (869,'_site_transient_theme_roots','a:2:{s:14:\"twentyfourteen\";s:57:\"C:\\the\\path\\to\\www.mysite.com\\wp/wp-content/themes/\";s:8:\"wpglobus\";s:7:\"/themes\";}','yes');
On UNIX, of course, I see
INSERT INTO `wpg_options` VALUES (678,'template_root','/the/path/to/www.mysite.com/wp/wp-content/themes/','yes');
INSERT INTO `wpg_options` VALUES (869,'_site_transient_theme_roots','a:2:{s:14:\"twentyfourteen\";s:55:\"/the/path/to/www.mysite.com/wp/wp-content/themes/\";s:8:\"wpglobus\";s:7:\"/themes\";}','yes');
And what happens is: when I mysqldump my database on Windows and load it on UNIX, WordPress gives me White Screen (no errors even in the error log).
I believe, always storing UNIX paths would solve this problem. They work the same on Windows and UNIX.
Attachments (1)
Change History (9)
#2
follow-up:
↓ 5
@
11 years ago
If we assume that the themes can be resided only under the DOCUMENT_ROOT, all the directories here can be stored as relative paths. Then, the comparison would work, I guess.
#3
follow-up:
↓ 4
@
11 years ago
We should probably use wp_normalize_path() there, like we do in plugin_basename() and a few other places.
#4
in reply to:
↑ 3
@
11 years ago
Replying to SergeyBiryukov:
We should probably use wp_normalize_path() there, like we do in
plugin_basename()and a few other places.
Might not work because it will still keep the C:// path.
What about my idea of using relative paths?
#5
in reply to:
↑ 2
;
follow-up:
↓ 6
@
11 years ago
Replying to tivnet:
If we assume that the themes can be resided only under the
DOCUMENT_ROOT, all the directories here can be stored as relative paths. Then, the comparison would work, I guess.
I think themes currently can be resided outside of ABSPATH too. But if the registered directory is under ABSPATH, we should probably store the relative path, yeah.
#6
in reply to:
↑ 5
@
11 years ago
Replying to SergeyBiryukov:
Replying to tivnet:
If we assume that the themes can be resided only under the
DOCUMENT_ROOT, all the directories here can be stored as relative paths. Then, the comparison would work, I guess.
I think themes currently can be resided outside of
ABSPATHtoo. But if the registered directory is underABSPATH, we should probably store the relative path, yeah.
You are right, there is no restriction in the register_theme_directory(). Only if the path not found, it tries to $directory = WP_CONTENT_DIR . '/' . $directory;
In
function get_theme_root(),this
ifwon't work because of the Win-Unix paths: