WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 3 months ago

#42673 closed defect (bug) (fixed)

Themes page throws console error when there is only one installed theme

Reported by: kouratoras Owned by: westonruter
Milestone: 4.9.1 Priority: normal
Severity: normal Version: 4.9
Component: Themes Keywords: has-patch commit fixed-major
Focuses: Cc:

Description

In WordPress 4.9 fresh installation, when there is only one theme available in Themes page, a console error is thrown.

Steps to reproduce

  1. Install WordPress
  2. Go to Themes page
  3. Remove TwentySixteen and TwentyFifteen, so TwentySeventeen is the only installed theme
  4. Refresh the Themes page

What I see: The page is throwing a console error:

Uncaught TypeError: Cannot read property 'doSearch' of undefined
    at Object.init (load-scripts.php?c=1&load[]=hoverIntent,common,admin-bar,thickbox,underscore,backbone,wp-util,wp-backbone,wp-a11y,customize-base,theme,updates,svg-painter,h&load[]=eartbeat,wp-auth-check&ver=4.9:355)
    at HTMLDocument.<anonymous> (load-scripts.php?c=1&load[]=hoverIntent,common,admin-bar,thickbox,underscore,backbone,wp-util,wp-backbone,wp-a11y,customize-base,theme,updates,svg-painter,h&load[]=eartbeat,wp-auth-check&ver=4.9:355)
    at i (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils&ver=4.9:2)
    at Object.fireWith [as resolveWith] (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils&ver=4.9:2)
    at Function.ready (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils&ver=4.9:2)
    at HTMLDocument.K (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils&ver=4.9:2)

Attachments (1)

42673.diff (1.0 KB) - added by chetan200891 3 months ago.
Created patch for change searchView to SearchView to fix.

Download all attachments as: .zip

Change History (9)

#1 @afercia
3 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.9.1

Seems to me this was introduced in [42029]. Maybe just a matter of uppercase vs. lowercase SearchView / searchView. /cc @westonruter

@chetan200891
3 months ago

Created patch for change searchView to SearchView to fix.

#2 @johnbillion
3 months ago

  • Milestone changed from 4.9.1 to 4.9.2

#3 @westonruter
3 months ago

  • Keywords has-patch commit added; needs-patch removed
  • Owner set to westonruter
  • Status changed from new to accepted

@afercia looks like you're right. 42673.diff does appear to fix the issue that [42029] introduced.

It makes sense why this error is only happening when there is a single theme installed because of the condition that short-circuits when there is only one theme installed: https://github.com/WordPress/wordpress-develop/blob/a687253cce384f6f2e1d921ca6be639431a52e93/src/wp-admin/js/theme.js#L96-L99

When that short-circuit happens, then the searchView property never gets set, resulting in an error later when it is attempted to be accessed.

#4 @westonruter
3 months ago

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

In 42222:

Themes: Prevent JS error on Themes admin screen when only one theme is installed.

Amends [42029].
Props chetan200891, afercia.
See #42348.
Fixes #42673.

#5 @westonruter
3 months ago

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

This ticket was mentioned in Slack in #core by afercia. View the logs.


3 months ago

#7 @dd32
3 months ago

  • Milestone changed from 4.9.2 to 4.9.1

Seems fine for 4.9.1

#8 @dd32
3 months ago

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

In 42223:

Themes: Prevent JS error on Themes admin screen when only one theme is installed.

Amends [42029].
Props chetan200891, afercia.
See #42348, westonruter.
Merges [42222] to the 4.9 branch.
Fixes #42673.

Note: See TracTickets for help on using tickets.