Make WordPress Core

Opened 14 hours ago

Last modified 7 hours ago

#63737 new defect (bug)

Theme update fails, creates duplicate directory after incorrect plugin update attempt

Reported by: leemon's profile leemon Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.8.2
Component: Upgrade/Install Keywords:
Focuses: Cc:

Description

When attempting to update an existing theme (e.g., my-theme) via ZIP upload using the WordPress admin installer, an issue arises if a prior, incorrect update attempt was made through the plugin installer.

Steps to reproduce:

  1. Have an existing theme installed (e.g., my-theme).
  2. Prepare a ZIP file of an updated version of my-theme.
  3. Navigate to Plugins > Add New > Upload Plugin.
  4. Attempt to upload the theme ZIP file.
  5. WordPress correctly displays the error: "The package could not be installed. No valid plugins were found. Plugin installation failed."
  6. Navigate to Appearance > Themes > Add New > Upload Theme.
  7. Attempt to upload the same theme ZIP file that was used in step 4.
  8. Expected behavior: WordPress should overwrite the existing wp-content/themes/my-theme directory with the contents of the uploaded ZIP file, effectively updating the theme.
  9. Actual behavior: Instead of overwriting, WordPress creates a new directory named wp-content/themes/my-theme-1 and installs the updated theme there. The original wp-content/themes/my-theme directory remains untouched.
  10. Subsequent attempts to update the theme through the theme installer will continue to create new directories, making it impossible to update the theme correctly.

This behavior suggests that the failed plugin installation attempt leaves a residual state or flag that incorrectly influences subsequent theme update attempts, preventing the proper overwrite of the existing theme directory. This can lead to a cluttered themes directory and a broken update mechanism for the affected theme.

I'm using WP 6.8.2, but this behavior affects previous versions, too.

Change History (2)

#1 @leemon
14 hours ago

The header of the my-theme theme is:

/*
Theme Name: My Theme
Theme URI:
Update URI: false
Author: An author
Author URI: https://mytheme.com/
Description: My theme is a simple theme.
Version: 1.0
Requires at least: 6.8
Tested up to: 6.8
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: block-styles, blog, custom-colors, custom-logo, custom-menu, e-commerce, footer-widgets, left-sidebar, photography, portfolio, right-sidebar, theme-options, translation-ready, threaded-comments, two-columns
Text Domain: my-theme
Domain Path: /languages

This theme, like WordPress, is licensed under the GPL.
*/

#2 @leemon
7 hours ago

Linking this somewhat related ticket: #29798

Note: See TracTickets for help on using tickets.