Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#42673 closed defect (bug) (fixed)

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

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

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 9 years ago.
Created patch for change searchView to SearchView to fix.

Download all attachments as: .zip

Change History (9)

#1 @afercia
9 years ago

  • Keywords needs-patch added
  • Milestone Awaiting Review → 4.9.1

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

@chetan200891
9 years ago

Created patch for change searchView to SearchView to fix.

#2 @johnbillion
9 years ago

  • Milestone 4.9.1 → 4.9.2

#3 @westonruter
9 years ago

  • Keywords has-patch commit added; needs-patch removed
  • Owner set to westonruter
  • Status new → 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
9 years ago

  • Resolution → fixed
  • Status accepted → 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
9 years ago

  • Keywords fixed-major added
  • Resolution fixed
  • Status closed → reopened

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


9 years ago

#7 @dd32
9 years ago

  • Milestone 4.9.2 → 4.9.1

Seems fine for 4.9.1

#8 @dd32
9 years ago

  • Resolution → fixed
  • Status reopened → 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.