Make WordPress Core

Opened 12 years ago

Closed 11 years ago

#29870 closed defect (bug) (fixed)

Pagination disappears after deleting the last page of post entries

Reported by: Greg Raven Owned by: wonderboymusic
Priority: normal Milestone: 4.4
Component: Posts, Post Types Version: 4.0
Severity: normal Keywords: needs-patch
Cc: Focuses:

Description

If you have multiple pages of posts listed in the All Posts listing, go to the last page of the posts. Click the checkbox to select all of the posts on that page. Bulk delete your selection. After WP deletes those entries, the pagination disappears from the top of the listing pane.

If you delete all posts from other pages, when the window content refreshes the pagination will be there.

Attachments (3)

29870.diff (1.9 KB ) - added by A5hleyRich 12 years ago.
29870.2.diff (1.9 KB ) - added by wonderboymusic 11 years ago.
29870.3.diff (1.0 KB ) - added by bradyvercher 11 years ago.

Download all attachments as: .zip

Change History (20)

#1 @helen
12 years ago

  • Keywords needs-patch needs-codex added
  • Milestone Awaiting ReviewFuture Release

Thanks for the report, sorry we missed this. Seems like we should check to make sure we're within the bounds of pagination and, if not, go to the last page.

#2 @helen
12 years ago

  • Keywords good-first-bug added; needs-codex removed

@A5hleyRich
12 years ago

#3 @A5hleyRich
12 years ago

This can be replicated by just appending the paged parameter with a page number greater than the total pages on the all posts screen.

#4 @A5hleyRich
12 years ago

  • Keywords has-patch added; needs-patch removed

#6 @helen
12 years ago

  • Keywords needs-patch added; has-patch removed

Should look into why what's in WP_List_Table doesn't seem to work.

#7 @A5hleyRich
12 years ago

I'm not sure WP_List_Table is at fault here, the issue is that the prepare_items method in the WP_Posts_List_Table class is not passing the correct values.

The reason for querying for the post counts separately is for performance reasons. The initial query doesn't return results because the SQL offset exceeds the amount of posts, but removing the offset will query and return all posts on every paginated page, hence the additional lookup.

#8 @pirasath
11 years ago

Thanks for the patch i tried it work.

#9 @obenland
11 years ago

  • Owner set to A5hleyRich
  • Status newassigned

#10 @wonderboymusic
11 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone Future Release4.4

#11 @wonderboymusic
11 years ago

  • Resolutionfixed
  • Status assignedclosed

In 34271:

Posts List Table: Use a more robust technique for calculating $total_items so that pagination still appears when items are removed on the last page of results and ->max_num_pages decreases.

Props A5hleyRich.
Fixes #29870.

#12 @ocean90
11 years ago

  • Keywords needs-patch added; good-first-bug has-patch removed
  • Resolution fixed
  • Status closedreopened

[34271] brokes the pagination for searches. It uses the total number of posts and not the number of search results.

#13 @DrewAPicture
11 years ago

  • Owner changed from A5hleyRich to wonderboymusic
  • Status reopenedassigned

@wonderboymusic Sounds like we need a follow-up re: comment:12.

#14 @wonderboymusic
11 years ago

  • Resolutionfixed
  • Status assignedclosed

In 35622:

List Tables: after [34271], account for searches when calculating pagination.

Fixes #29870.

#15 @bradyvercher
11 years ago

  • Resolution fixed
  • Status closedreopened

I ran into issues with this earlier today where the pagination no longer works with custom views that modify the query. The total items count used to be calculated based on $wp_query->found_posts, so pagination correctly accounted for any changes to the query, but that's no longer the case.

It tried to find a way to fix the pagination args from outside the list table, but it doesn't look like it's possible after [34271].

Version 0, edited 11 years ago by bradyvercher (next)

#16 @bradyvercher
11 years ago

I attached a new patch that continues using $wp_query->found_posts on the first page of results or when any posts are actually found, otherwise it'll use the post counts to determine if the request is out of bounds.

I also went ahead and removed the $total_pages calculation since that's done immediately in WP_List_Table::set_pagination_args().

#17 @wonderboymusic
11 years ago

  • Resolutionfixed
  • Status reopenedclosed

In 35683:

List Tables: After [35622] and [34271], improve pagination logic when queries are altered.

Props bradyvercher.
Fixes #29870.

Note: See TracTickets for help on using tickets.