# WordPress.org

## Make WordPress Core

Opened 5 years ago

# get_raw_theme_root : Windows paths

Reported by: Owned by: tivnet Awaiting Review high critical 3.9.1 Themes needs-patch template

### 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.

### #1 @tivnet 5 years ago

In function get_theme_root(),

this if won't work because of the Win-Unix paths:

if ( ! in_array( $theme_root, (array)$wp_theme_directories ) )
$theme_root = WP_CONTENT_DIR .$theme_root;


### #2 follow-up: ↓ 5 @tivnet 5 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 @SergeyBiryukov 5 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 @tivnet 5 years ago

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 @SergeyBiryukov 5 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.

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 @tivnet 5 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.

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.

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;