Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'show_ui' of undefined (solved by changing the Caddy setup) #8802

Closed
daveross opened this Issue Aug 10, 2018 · 9 comments

Comments

Projects
None yet
5 participants
@daveross
Copy link

daveross commented Aug 10, 2018

Describe the bug
Clicking "Add New" to create a new Post causes Gutenberg to appear briefly, then it's immediately replaced with the "The editor has encountered an unexpected error." screen showing three buttons.

Error is:

TypeError: Cannot read property 'show_ui' of undefined at https://csixty4.com/wp-content/plugins/gutenberg/build/editor/index.js?ver=1533864911:12:289913 at i (https://unpkg.com/lodash@4.17.5/lodash.min.js:6:91) at An.filter (https://unpkg.com/lodash@4.17.5/lodash.min.js:99:338) at https://csixty4.com/wp-content/plugins/gutenberg/build/editor/index.js?ver=1533864911:12:289878 at yh (https://unpkg.com/react-dom@16.4.1/umd/react-dom.production.min.js:96:396) at lg (https://unpkg.com/react-dom@16.4.1/umd/react-dom.production.min.js:120:88) at mg (https://unpkg.com/react-dom@16.4.1/umd/react-dom.production.min.js:120:386) at gc (https://unpkg.com/react-dom@16.4.1/umd/react-dom.production.min.js:127:202) at vb (https://unpkg.com/react-dom@16.4.1/umd/react-dom.production.min.js:126:230) at ub (https://unpkg.com/react-dom@16.4.1/umd/react-dom.production.min.js:126:65)

The site is running a third-party theme but switching to Twenty Seventeen doesn't fix. There's also an mu-plugin defining a custom taxonomy but removing it doesn't fix – and the error appears to be happening for the Categories taxonomy.

Debugging the code in question points to this code:

return Object(s.filter)(i, function(e) { return e.visibility.show_ui }).map(function(e) {

at that point, e looks like:

e:
description: ""
hierarchical: true
name: "Categories"
rest_base: "categories"
slug: "category"
types: ["post"]
_links: {collection: Array(1), wp:items: Array(1), curies: Array(1)}
proto: Object`

(no show_ui member)

To Reproduce
Steps to reproduce the behavior:

  1. Go to WordPress admin (happens when logged in as Administrator or other role)
  2. Click on '.Posts' → 'Add New'
  3. See error

Expected behavior
Gutenberg editor loads

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version 68.0.3440.106 (Official Build) (64-bit)
@daveross

This comment has been minimized.

Copy link
Author

daveross commented Aug 10, 2018

This is similar to #8456 #8441

I'm not using Cloudflare. WordPress is running in php-fpm behind Caddy web server.

@daveross

This comment has been minimized.

Copy link
Author

daveross commented Aug 10, 2018

Tested with the current .org version of Gutenberg and master from the repo.

@pento

This comment has been minimized.

Copy link
Member

pento commented Aug 10, 2018

Thanks for the bug report, @daveross!

What version of WordPress are you running?

Do you have any other plugins installed?

@daveross

This comment has been minimized.

Copy link
Author

daveross commented Aug 10, 2018

WordPress 4.9.8. No other plugins besides Gutenberg and the mu-plugin that registers the taxonomy.

Possibly related to WordPress commit 2f792d442bf771a3aade170cc9cae459f024c57b which removes visibility from the REST API response by default?

@daveross

This comment has been minimized.

Copy link
Author

daveross commented Aug 10, 2018

Closing this for now. Appears to be tied to the Caddy configuration usually recommended:

rewrite { if {path} not_match ^\/wp-admin# to {path} {path}/ /index.php?_url={uri} }

In WP Core, WP_REST_Server accesses $_GET directly, and in this case $_GET only contains _url.

Fixed by changing the Caddy setup for this site so it passes the query string unchanged:

rewrite { if {path} not_match ^\/wp-admin to {path} {path}/ /index.php?{query} }

@daveross daveross closed this Aug 10, 2018

@pento

This comment has been minimized.

Copy link
Member

pento commented Aug 10, 2018

Huh, interesting. Thanks for tracking that down. 🙂

@choujar

This comment has been minimized.

Copy link

choujar commented Dec 10, 2018

Hi, I'm running on nginx and getting this error straight after upgrading to Wordpress 5.0.

Any ideas? thanks!

@choujar

This comment has been minimized.

Copy link

choujar commented Dec 10, 2018

Just to confirm, the solution in #9912 worked for me...

#9912 (comment)

@raininja

This comment has been minimized.

Copy link

raininja commented Dec 20, 2018

Just wanted to report that I've had the same issue with my Caddyfile, and the solution above worked.

#rewrite {
#    if {path} not_match ^\/wp-admin
#    to {path} {path}/ /index.php?_url={uri}
#}

rewrite {
    if {path} not_match ^\/wp-admin
    to {path} {path}/ /index.php?{query} }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.