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
dana-ross opened this issue Aug 10, 2018 · 10 comments
Labels
[Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.

Comments

@dana-ross
Copy link

dana-ross 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/[email protected]/lodash.min.js:6:91) at An.filter (https://unpkg.com/[email protected]/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/[email protected]/umd/react-dom.production.min.js:96:396) at lg (https://unpkg.com/[email protected]/umd/react-dom.production.min.js:120:88) at mg (https://unpkg.com/[email protected]/umd/react-dom.production.min.js:120:386) at gc (https://unpkg.com/[email protected]/umd/react-dom.production.min.js:127:202) at vb (https://unpkg.com/[email protected]/umd/react-dom.production.min.js:126:230) at ub (https://unpkg.com/[email protected]/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)
@dana-ross
Copy link
Author

This is similar to #8456 #8441

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

@dana-ross
Copy link
Author

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

@pento
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?

@dana-ross
Copy link
Author

dana-ross 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?

@dana-ross
Copy link
Author

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} }

@pento
Copy link
Member

pento commented Aug 10, 2018

Huh, interesting. Thanks for tracking that down. 🙂

@choujar
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
Copy link

choujar commented Dec 10, 2018

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

#9912 (comment)

@raininja
Copy link

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} }
}

@talhaimam
Copy link

@dana-ross I am running 5.9.3 with PHP FPM and apache2, and I am still seeing this error. Cant seem to make it work, any idea about apache2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.
Projects
None yet
Development

No branches or pull requests

6 participants