[wp-trac] [WordPress Trac] #47216: Block Editor crashes on custom post types without title support
WordPress Trac
noreply at wordpress.org
Thu Jun 20 11:38:08 UTC 2019
#47216: Block Editor crashes on custom post types without title support
--------------------------+-------------------------
Reporter: markjaquith | Owner: (none)
Type: defect (bug) | Status: new
Priority: high | Milestone: 5.3
Component: Editor | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses: javascript
--------------------------+-------------------------
Changes (by splitti):
* keywords: needs-patch => has-patch
Comment:
The problem is caused by
[https://github.com/WordPress/gutenberg/blob/54bae98f51dd4a12d68022ff1a2806253d18fefa/packages
/edit-post/src/components/sidebar/post-link/index.js#L37 this line] in
PostLink.
It assumes that {{{cleanForSlug}}}
([https://github.com/WordPress/gutenberg/blob/54bae98f51dd4a12d68022ff1a2806253d18fefa/packages/editor/src/utils/url.js#L41-43
see here]) can deal with parameters that aren't strings. If this were a
documentary, the narrator would now say "It can't."
There are at least two options on how to resolve this problem.
1. Make {{{cleanForSlug}}} bail whenever it gets invalid input.
2. Change the code in PostLink (and potentially elsewhere) to not call
{{{cleanForSlug}}} with something that isn't always a string.
Following the [https://en.wikipedia.org/wiki/Robustness_principle
Robustness Principle], I opted for (1) in my patch.
I'm not sure what's the best way to indicate that the function wasn't able
to perform the desired action, but I think returning undefined is probably
a good start, but I'd like to hear your opinions on that as well as any
preference for another option :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47216#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list