WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 5 months ago

#29051 new defect (bug)

get_raw_theme_root : Windows paths

Reported by: tivnet 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)

2014-07-29_1008.png (89.3 KB) - added by tivnet 5 years ago.

Download all attachments as: .zip

Change History (9)

#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: @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: @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

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: @SergeyBiryukov
5 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 @tivnet
5 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 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;

#7 @F J Kaiser
5 years ago

  • Keywords needs-patch added
  • Severity changed from normal to critical

Setting severity to critical as this bug breaks setups.

#8 @chriscct7
4 years ago

  • Priority changed from normal to high
Note: See TracTickets for help on using tickets.