Make WordPress Core

Opened 6 weeks ago

Last modified 5 weeks ago

#47858 reviewing defect (bug)

Incorrect redirect after deleting a term from a taxonomy of a custom post type

Reported by: johnbillion Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch
Focuses: administration Cc:


Given a taxonomy attached to a custom post type, deleting a term from the individual term editing screen redirects the user to the term listing screen without the post_type query var, which is incorrect and means the Posts menu is highlighted.

Steps to reproduce on a site with a taxonomy attached to a custom post type:

  • Navigate to the term listing screen for the taxonomy
  • Click the Edit link below a term
  • Click the Delete link at the bottom of the screen and confirm the prompt

Observe that the URL you're redirected to is missing the post_type query var and that the Posts admin menu is highlighted.

Attachments (2)

47858.diff (684 bytes) - added by donmhico 6 weeks ago.
47858.2.diff (587 bytes) - added by mukesh27 6 weeks ago.
Updated patch.

Download all attachments as: .zip

Change History (7)

6 weeks ago

#1 @donmhico
6 weeks ago

  • Keywords has-patch added; needs-patch removed

Nice find @johnbillion. I can't believe we've missed this up until now.

In my attached patch, 47858.diff, you'll notice that I removed esc_url() in

wp_redirect( $sendback );

This is because esc_url() will transform & to & which is not what we wanted in our url query args. Also, the base url is defined as $sendback = admin_url( 'edit-tags.php' ); and the url query args are added using add_query_arg() so I think it's safe to remove the esc_url().

#2 @SergeyBiryukov
6 weeks ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

6 weeks ago

Updated patch.

#3 @mukesh27
6 weeks ago

Updated patch 47858.2.diff with different code change.

@SergeyBiryukov, @donmhico Can you please check it.

#4 @donmhico
5 weeks ago

@mukesh27 IMHO

if ( 'post' !== get_current_screen()->post_type )

is better than

if ( ! empty( $typenow ) ) 

because the former is easier to understand.

#5 @mukesh27
5 weeks ago

@donmhico As per $taxnow variable we can access $typenow from parent code.

Check https://github.com/WordPress/WordPress/blob/master/wp-admin/term.php#L15

Note: See TracTickets for help on using tickets.