Opened 7 years ago
Closed 7 years ago
#42442 closed defect (bug) (fixed)
Install & Preview of themes doesn't work.
Reported by: | atachibana | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | 4.9 |
Component: | Customize | Keywords: | has-patch dev-reviewed commit |
Focuses: | javascript | Cc: |
Description
In 4.9-RC1-42115, Customizer's Install & Preview of themes does not work.
Step
- Start Customizer
- Click Change button of theme
- Select WordPress.org themes
- 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)
Change History (19)
#2
@
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
@
7 years ago
Hi @dd32
For quick investigation, I used logger tool
https://github.com/tarosky/talog/releases
It reports
[Trace] Undefined property: stdClass::$template Summary 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 REMOTE_ADDR 192.168.50.1 HTTP_X_FORWARDED_FOR HTTP_CLIENT_IP 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
#4
@
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' => "https://wordpress.org/themes/{$parent->post_name}/", ); } } }
#5
@
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: WordPress.org 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 w.org related to it.
If you need anything added to WordPress.org API's for projects like this, file a meta ticket with reasoning, we'll get it implemented.
#6
@
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 ) ) { deferred.reject({ 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.)
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
7 years ago
#9
@
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
@
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
@
7 years ago
@westonruter
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.
Wordaround
If I do once 'Live Preview' for any installed theme, then 'Install & Preview' runs successfully.
Reproduction
Cusomizer > Change button of theme > Select WordPress.org themes > Click Install & Preview of any theme
In my logger (see comment:3 for detail)
[Trace] Trying to get property of non-object Summary: 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: REMOTE_ADDR 192.168.33.1 HTTP_X_FORWARDED_FOR HTTP_CLIENT_IP 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
#13
@
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.
Hi @atachibana and welcome back to Trac,
A few questions, hopefully to help narrow down investigations: