WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#34473 closed defect (bug) (fixed)

Wrong default order for pages list table in 4.4

Reported by: szaqal21 Owned by: SergeyBiryukov
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.4
Component: Posts, Post Types Keywords: has-patch
Focuses: administration Cc:

Description

Default order of pages list table in 4.4 is "date". I've investigated source and found that this is caused by function wp_edit_posts_query():

if ( isset( $q['orderby'] ) ) {
		$orderby = $q['orderby'];
	} elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ) ) ) {
		$orderby = 'modified';
	} else {
		$orderby = 'date';
	}
}

else statement is causing this problem:

else {
	$orderby = 'date';
}

it wasn't present in 4.3.

Attachments (1)

34473-wrong-default-order-for-pages.diff (500 bytes) - added by ellie.roepken 5 years ago.
Check that the post type is hierarchical before assuming posts should be listed by date.

Download all attachments as: .zip

Change History (6)

#1 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 4.4

Introduced in [34728].

#2 @SergeyBiryukov
5 years ago

  • Version set to trunk

@ellie.roepken
5 years ago

Check that the post type is hierarchical before assuming posts should be listed by date.

#3 @afercia
5 years ago

  • Keywords has-patch added

#4 @SergeyBiryukov
5 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

There's a block for hierarchical post types in line 1048, which never runs after [34728], because $orderby is always set now.

34473-wrong-default-order-for-pages.diff looks good. No need to check if $post_type is set though, it's set above.

#5 @SergeyBiryukov
5 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 35482:

Post List Table: Hierarchical post types should not default to sorting by date.

Regression introduced in [34728].

Props ellie.roepken.
Fixes #34473. See #25493.

Note: See TracTickets for help on using tickets.