WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#12448 closed defect (bug) (fixed)

pagination problem in unattached media page

Reported by: Denis-de-Bernardy Owned by: matdumsa
Milestone: 3.0 Priority: normal
Severity: normal Version: 2.9.2
Component: Administration Keywords:
Focuses: Cc:

Description

when visiting media / unattached with multiple unattached media, you seem to end up with the wrong number of total pages, as highlighted in the attached screenshot.

Attachments (3)

unattached-media-pages.png (47.7 KB) - added by Denis-de-Bernardy 4 years ago.
upload.diff (415 bytes) - added by matdumsa 4 years ago.
Path for this Ticket.. This patch was made from rev:13795
12448.diff (697 bytes) - added by PeteMall 4 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 matdumsa4 years ago

  • Keywords needs-patch added
  • Milestone changed from 3.0 to 2.9.3
  • Owner set to matdumsa
  • Status changed from new to accepted
  • Version changed from 3.0 to 2.9.2

I confirm the presence of the bug on my version of wordpress as well..

comment:2 matdumsa4 years ago

  • Keywords has-patch added; needs-patch removed

Actually I found the problem..

It lies in wp-admin/upload.php

It seems that the pagination system used by the media is the same as the one used for POSTS.. It relies on information usually provided by the user in the $_GET variable (query string).

The code for everything BUT orphan is the same.. all it does is call wp_edit_attachments_query() which hack the $_GET array into thinking that these values (posts_per_page) where provided.. In our case these values were unset so this is why you see 0..

The attached patch makes the “hack” work even for unattached elements..

BTW this whole pagination code is pretty ugly.. Maybe a re-write would be require to avoid such bugs in the future..

Enjoy

matdumsa4 years ago

Path for this Ticket.. This patch was made from rev:13795

comment:3 nacin4 years ago

  • Milestone changed from 2.9.3 to 3.0

comment:4 ocean904 years ago

  • Keywords needs-patch added; has-patch removed

If you use upload.diff you get a wrong number for $wp_query->found_posts. Its the total number of posts and not of the attachments.

PeteMall4 years ago

comment:5 PeteMall4 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

comment:6 wpmuguru4 years ago

(In [14185]) fix page count calc for unattached media, props PeteMall, see #12448

comment:7 PeteMall4 years ago

  • Keywords has-patch needs-testing removed
  • Resolution set to fixed
  • Status changed from accepted to closed
Note: See TracTickets for help on using tickets.