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

Projects
None yet
3 participants
@noisysocks
Member

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
Fix exception when editing non-public CPTs
- 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`.
$post_type_obj = get_post_type_object( $post->post_type );
if ( ! is_post_type_viewable( $post_type_obj ) || ! $post_type_obj->public ) {
return $response;
}

This comment has been minimized.

@noisysocks

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

@pento

pento approved these changes Nov 22, 2018

🕺

@noisysocks noisysocks merged commit b7bfcd1 into master Nov 22, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@noisysocks noisysocks deleted the fix/editing-non-public-cpts branch Nov 22, 2018

@youknowriad youknowriad modified the milestones: WordPress 5.0 RC, 4.6 Nov 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment