Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#42442 closed defect (bug) (fixed)

Install & Preview of themes doesn't work.

Reported by: atachibana's profile atachibana Owned by: westonruter's profile westonruter
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.9
Component: Customize Keywords: has-patch dev-reviewed commit
Focuses: javascript Cc:


In 4.9-RC1-42115, Customizer's Install & Preview of themes does not work.


  1. Start Customizer
  2. Click Change button of theme
  3. Select themes
  4. Click Install & Preview of any theme

Then, Nothing happen.

In the same environment, I can successfully install the theme from Administration Screen > Appearance > Themes.

Attachments (3)

42442.notice.diff (1.8 KB) - added by dd32 7 years ago.
Notice fix (And clarification of how the .org API works)
42442.1.diff (1.9 KB) - added by westonruter 7 years ago.
42442.diff (1.9 KB) - added by obenland 7 years ago.

Download all attachments as: .zip

Change History (19)

#1 @dd32
7 years ago

Hi @atachibana and welcome back to Trac,

A few questions, hopefully to help narrow down investigations:

  1. Are there any warnings/notices/errors visible in the Javascript console?
  2. When you install from wp-admin, does it prompt for FTP details?
  3. Is your Site URL and Home URL the same location?

#2 @dd32
7 years ago

  • Milestone changed from Awaiting Review to 4.9

Reproduced, I can't find any errors in the console, and no ajax calls appear to be made.

@atachibana you can probably ignore the above questions unless you appear to see any JS errors.

#3 @atachibana
7 years ago

Hi @dd32

For quick investigation, I used logger tool

It reports

[Trace] Undefined property: stdClass::$template

type	8
message	Undefined property: stdClass::$template
file	/srv/www/wordpress-develop/public_html/src/wp-includes/class-wp-customize-manager.php
line	5449

				$theme->parent       = ( $theme->slug === $theme->template ) ? false : $theme->template; // The .org API does not seem to return the parent in a documented way; however, this check should yield a similar result in most cases.

Environment Variables
HTTP_USER_AGENT	Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36
HTTP_HOST	src.wordpress-develop.test
REQUEST_URI	/wp-admin/admin-ajax.php

7 years ago

Notice fix (And clarification of how the .org API works)

#4 @dd32
7 years ago

Added a patch which fixes the PHP Notice, and shows how that part of the API is supposed to work. It seems unrelated to the issue at hand though.

Here's that part of the API, easier than explaining it:

if ( $this->fields['template'] || $this->fields['parent'] ) {
	$parent = get_post( $theme->post_parent );
	if ( is_a( $parent, 'WP_Post' ) ) {
		if ( $this->fields['template'] ) {
			$phil->template = $parent->post_name;
		if ( $this->fields['parent'] ) {
			$phil->parent = array(
				'slug'     => $parent->post_name,
				'name'     => $parent->post_title,
				'homepage' => "{$parent->post_name}/",

#5 @dd32
7 years ago

Since this ticket already has a bunch of API stuff, @westonruter do you have any comments regarding this?

// 'extended_author' => true, @todo: throws a 500 server error when this is here.

If you have any examples, please file a meta ticket, I can't duplicate any issues and we haven't had any fatals on related to it.
If you need anything added to API's for projects like this, file a meta ticket with reasoning, we'll get it implemented.

#6 @celloexpressions
7 years ago

  • Focuses javascript added
  • Keywords needs-patch added

This appears to have been caused by [42113]. The check starting at line 3205 of customize-controls.js is incorrectly failing, and preventing the theme installation from being initialized:

// Prevent loading a non-active theme preview when there is a drafted/scheduled changeset.
if ( panel.canSwitchTheme( slug ) ) {
		errorCode: 'theme_switch_unavailable'
	return deferred.promise();

Commenting out that check, everything works. Looking at canSwitchTheme(), I'm guessing that the root issue is with the initial changeset status that gets set on a fresh load. The following line is returning false:

return 'publish' === api.state( 'selectedChangesetStatus' ).get() && ( '' === api.state( 'changesetStatus' ).get() || 'auto-draft' === api.state( 'changesetStatus' ).get() );

(Yes, the other issues are unrelated, but would be great to get cleaned up before release. I believe the documentation for a few aspects of that API was incomplete when the feature was first worked on last year; looks like those preliminary code comments slipped through without a review by anyone more familiar with it. If possible, it would be helpful for you to audit all of the related .org API calls for this feature for correctness @dd32. There should be todos or question-oriented comments for anything that seemed to behave oddly at any point.)

#7 @melchoyce
7 years ago

  • Owner set to westonruter
  • Status changed from new to assigned

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

7 years ago

7 years ago

#9 @westonruter
7 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

@celloexpressions @atachibana It looks like it's just an (embarrassing) logic inversion issue. Would you test 42442.1.diff?

This is indeed a regression introduced in [42113] via #42406.

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.

7 years ago

#11 @westonruter
7 years ago

I've never been able to reproduce the issue the issue with the PHP notice. I have been able to reproduce the issue with the installation buttons, and 42442.1.diff fixes it for me.

#12 @atachibana
7 years ago


It might be my environment failure, but unfortunately I cannot confirm the fix.
Anyone? @dd32 ?

I tried it on VVV & VCCW 4.9-RC1-42117.

If I do once 'Live Preview' for any installed theme, then 'Install & Preview' runs successfully.

Cusomizer > Change button of theme > Select themes > Click Install & Preview of any theme

In my logger (see comment:3 for detail)

[Trace] Trying to get property of non-object

type	8
message	Trying to get property of non-object
file	/var/www/html/wp-includes/class-wp-customize-manager.php
line	5451
             $theme->parent = $theme->parent->slug;

Environment Variables:
HTTP_USER_AGENT	Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Firefox/52.0
HTTP_HOST	vccw.test
REQUEST_URI	/wp-admin/admin-ajax.php

Last edited 7 years ago by atachibana (previous) (diff)

7 years ago

#13 @obenland
7 years ago

  • Keywords dev-feedback added; needs-testing removed

42442.diff is based on a best-of of @dd32's and @westonruter's patch.

The PHP notice is triggered in the ajax callback, you should be able to find it in your error log with the trunk version of Debug Bar enabled. $theme->parent is not an object but an array however, triggering another notice. Latest patch should fix all three.

#14 @atachibana
7 years ago


I confirmed the patch. Thank you.

#15 @westonruter
7 years ago

  • Keywords dev-reviewed commit added; dev-feedback removed
  • Status changed from assigned to accepted

#16 @westonruter
7 years ago

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

In 42122:

Customize: Fix logic inversion in [42113] which prevented themes from being installed in Customizer.

Also fix PHP notice related to parent themes and theme query results.

Props dd32, obenland, celloexpressions, westonruter, atachibana for testing.
See #42406, #37661.
Fixes #42442.

Note: See TracTickets for help on using tickets.