WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 4 weeks ago

#39968 new defect (bug)

Media Library: deleting all items on the last page loses the pagination/navigation buttons and shows message

Reported by: donsony Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.7.2
Component: Media Keywords: has-patch
Focuses: ui Cc:

Description

While deleting all items on the last page of Media Library, the page loses the pagination/navigation buttons and shows the message "No Media Files found" with no way to access the earlier pages other than by going back to the "Media" link

Attachments (2)

Screen Shot 2018-12-20 at 3.09.37 PM.png (122.6 KB) - added by antpb 22 months ago.
illustration of the behavior
39968.1.patch (621 bytes) - added by Mista-Flo 7 weeks ago.

Download all attachments as: .zip

Change History (11)

#1 @karmatosed
3 years ago

  • Summary changed from Media Library to Media Library: deleting all items on the last page loses the pagination/navigation buttons and shows message

This ticket was mentioned in Slack in #core-media by mike. View the logs.


22 months ago

@antpb
22 months ago

illustration of the behavior

#3 @antpb
22 months ago

I've added an illustration of the behavior above, we have two options here that @desrosj outlined in the recent #core-media meeting:

"I would either return the user to page 1, or, send them to the _new_ last page."

#4 @desrosj
22 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

I looked at how other admin areas handle this. This is what I found:

  • Posts: reloads the page with paged - 1 (new last page).
  • Categories: reloads the page with paged - 1 (new last page).
  • Users: This flow is a bit different because there is a confirmation page in between. But, the user is always returned to the first page of users after deleting users.

My vote is to keep things consistent with the other post and term areas in core and redirect the user to the new last page (paged-1).

#5 @Mista-Flo
7 weeks ago

  • Keywords has-patch added; needs-patch removed

Hi there, it took me ages to understand what was wrong here.

For example, if you have just two pages of attachments and you are on page 2, just change the paged argument in the URL to 37 and it still loads the UI with no attachments at all.

After some digging, I have found out that $wp_query->found_posts and $wp_query->max_num_pages are equal to 0.

So even if it's on page 450 that does not exist, the posts list table have a count of the number of total posts which helps to identify the maximum number of pages in the pagination and redirect to the last existing page if the requested page is too high, check set_pagination_args function in wp-admin/includes/class-wp-list-table.php for more information.

So finally I just used the wp_count_attachments() function to mimic the behaviour of the post list table and it worked.

@Mista-Flo
7 weeks ago

This ticket was mentioned in Slack in #core-media by florian-tiar. View the logs.


7 weeks ago

#7 @justinahinon
7 weeks ago

39968.1.patch is fine and correctly solve the issue on my Trunk version.
When I delete all the items in the last page, it returns to the new last page.

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


6 weeks ago

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


4 weeks ago

Note: See TracTickets for help on using tickets.