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

Fix exception when editing non-public CPTs #12201

Merged
merged 2 commits into from
Nov 22, 2018

Conversation

noisysocks
Copy link
Member

@noisysocks noisysocks commented Nov 22, 2018

Fixes #12129.

  • Changes the posts API endpoint to only set permalink_template and generated_slug when the post is public and queryable. This matches the behaviour in Core.
  • Changes the getPermalink() and getPermalinkParts() selectors to return null when there is no permalink_template. This fixes an exception on non-public CPTs caused by attempting to parse an undefined permalink_template.

Testing

  1. Edit a non-public post using the block editor (e.g. a reusable block by going to Manage All Reusable Blocks and then clicking Edit)
  2. Publish a post and change its permalink using the sidebar
  3. Publish a post and change its permalink using the permalink editor in the post title

- Changes the posts API endpoint to only set `permalink_template` and
 `generated_slug` when the post is public and queryable. This matches the
 behaviour in Core.
- Changes the `getPermalink()` and `getPermalinkParts()` selectors to
 return null when there is no `permalink_template`. This fixes an
 exception on non-public CPTs caused by attempting to parse an undefined
 `permalink_template`.
@noisysocks noisysocks added [Type] Bug An existing feature does not function as intended [Priority] High Used to indicate top priority items that need quick attention labels Nov 22, 2018
@noisysocks noisysocks requested a review from pento November 22, 2018 03:06
$post_type_obj = get_post_type_object( $post->post_type );
if ( ! is_post_type_viewable( $post_type_obj ) || ! $post_type_obj->public ) {
return $response;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled this logic over from the 5.0 branch.

@noisysocks noisysocks modified the milestones: 4.5.2, WordPress 5.0 RC Nov 22, 2018
Copy link
Member

@pento pento left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editing a reusable block results in "The editor has encountered an unexpected error"
3 participants