WordPress.org

Make WordPress Core

Opened 4 weeks ago

Last modified 4 weeks ago

#48401 new defect (bug)

Saving a Post Breaks in Gutenberg if you have a custom taxonomy named Status

Reported by: kingkool68 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: REST API Keywords: needs-patch
Focuses: Cc:
PR Number:

Description

Steps to reproduce:

Register a taxonomy called Status:

function custom_taxonomy() {

	$labels = array(
		'name'                       => 'Status',
	);
	$args = array(
		'labels'                     => $labels,
		'hierarchical'               => false,
		'public'                     => true,
		'show_ui'                    => true,
		'show_admin_column'          => true,
		'show_in_nav_menus'          => true,
		'show_tagcloud'              => true,
		'show_in_rest'               => true,
	);
	register_taxonomy( 'status', array( 'post' ), $args );

}
add_action( 'init', 'custom_taxonomy', 0 );

Create a new Post using the Gutenberg editor
Try and Publish the post
Publishing should fail.
Add rest_base => 'status_tax' and publishing a post should work as expected.

The issue is if the rest_base argument isn't specified register_taxonomy() will use the taxonomy key as the rest base. In this case that would be status which is already a REST API route.

There should be a check to make sure a reserved REST API base isn't used. Ideally it would modify the default used to avoid the conflict such as appending _tax. Or atleast an error or warning should be thrown somewhere.

There is some confusion out there that this is a conflict between different plugins as documented here --> https://wordpress.org/support/topic/conflict-between-cpt-ui-and-acf-pro-in-the-block-editor/

Change History (2)

#1 @SergeyBiryukov
4 weeks ago

Thanks for the ticket!

Apparently status should be added to the list of reserved terms (I thought it's already there).

A _doing_it_wrong() notice could also be added to avoid the conflict.

#2 @desrosj
4 weeks ago

  • Keywords needs-patch added
Note: See TracTickets for help on using tickets.