Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#51182 closed defect (bug) (fixed)

Theme_Installer_skin::do_overwrite does not work on a Windows server

Reported by: bobbingwide's profile bobbingwide Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.5.1 Priority: normal
Severity: normal Version: 5.5
Component: Upgrade/Install Keywords: has-patch commit dev-reviewed fixed-major
Focuses: Cc:

Description

In my local Windows development environment I tried the new logic to upload plugin and theme .zip files. It worked for plugins but not for themes.

I traced through the code and determined that $current_theme_data was never being set because this loop assumes the character separator is always '/'.

foreach ( $all_themes as $theme ) {
   if ( rtrim( $theme->get_stylesheet_directory(), '/' ) !== $folder ) {
	continue;
   }
   $current_theme_data = $theme;
} 

In my windows environment
$theme->get_stylesheet_directory() returns, for example

C:\apache\htdocs\cwiccer/wp-content/themes/twentyfifteen

whereas the value of $folder was

C:/apache/htdocs/cwiccer/wp-content/themes/twentyfifteen

Since $current_theme_data is not set the option to replace the theme is not displayed.

Attachments (2)

51182.diff (739 bytes) - added by bobbingwide 4 years ago.
patch to support Windows
51182-2.diff (690 bytes) - added by wpamitkumar 4 years ago.

Download all attachments as: .zip

Change History (11)

#1 @bobbingwide
4 years ago

This change resolves the problem.

foreach ( $all_themes as $theme ) {
    $stylesheet_dir = $theme->get_stylesheet_directory();
    $stylesheet_dir = str_replace( '\\', '/', $stylesheet_dir);
    if ( rtrim( $stylesheet_dir, '/' ) !== $folder ) {
	continue;
   }
   $current_theme_data = $theme;
}

@bobbingwide
4 years ago

patch to support Windows

#2 @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 5.5.1
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

Thanks for the patch! Just noting this should probably use wp_normalize_path() instead.

@wpamitkumar
4 years ago

#3 @wpamitkumar
4 years ago

  • Keywords has-patch added

#4 @mukesh27
4 years ago

Thanks for the patch @wpamitkumar

Patch working fine for me.

#5 @bobbingwide
4 years ago

Yup, 51182-2.diff is neater.

#6 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 48913:

Themes: Normalize the installed theme path in Theme_Installer_Skin::do_overwrite() before comparing with the uploaded theme.

This ensures that the data for the currently installed theme is picked up properly when uploading a theme update on Windows.

Follow-up to [48390].

Props bobbingwide, wpamitkumar, mukesh27.
Fixes #51182.

#7 @SergeyBiryukov
4 years ago

  • Keywords commit dev-feedback fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for backporting to the 5.5 branch after a second committer's review.

#8 @desrosj
4 years ago

  • Keywords dev-reviewed added; dev-feedback removed

Looks good for backporting.

#9 @desrosj
4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 48919:

Themes: Normalize the installed theme path in Theme_Installer_Skin::do_overwrite() before comparing with the uploaded theme.

This ensures that the data for the currently installed theme is picked up properly when uploading a theme update on Windows.

Follow-up to [48390].

Props bobbingwide, wpamitkumar, mukesh27.
Merges [48913] to the 5.5 branch.
Fixes #51182.

Note: See TracTickets for help on using tickets.