Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#17285 closed defect (bug) (fixed)

Pagination of plugins search results does not work

Reported by: pavelevap's profile pavelevap Owned by: dd32's profile dd32
Milestone: 3.2 Priority: normal
Severity: normal Version: 3.1
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

I tested several plugins and noticed that pagination of plugins search results does not work. Simply, search string is not passed to pagination links.

  • Go to Plugins menu.
  • Set small (testing) number in Screen tab for plugin pagination.
  • Enter for example "Menu" into searchbox (or any other word to have chance to find some installed plugins).
  • There are 11 items found, 3 pages available for me, I can see first 5 related plugins, everything looks well.
  • But when you click on "Next page" icon to see other search results, you are redirected to second page, but of all plugins. Search string is not passed to pagination links...

Attachments (1)

17285.diff (622 bytes) - added by dd32 13 years ago.

Download all attachments as: .zip

Change History (14)

#1 @scribu
13 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 3.2
  • Version changed from 3.2 to 3.1

Confirmed.

#2 @scribu
13 years ago

  • Component changed from General to Administration

#3 @ocean90
13 years ago

Seems like the plugins page is the last screen which uses method="post" instead of method="get".

#4 @dbernar1
13 years ago

  • Cc dbernar1 added

I was just saying the same thing on the wordpress-dev channel. Switching the form to a get form fixes the issue.

The "problem" there is that the URL generated by the get form looks like this:

/wp-admin/plugins.php?s=menu&plugin_status=search&paged=1&_wpnonce=14cb602e07&_wp_http_referer=%2Fwordpress-trunk%2Fwp-admin%2Fplugins.php%3Fs%3Dmenu%26plugin_status%3Dall%26paged%3D1%26_wpnonce%3D14cb602e07%26_wp_http_referer%3D%252Fwordpress-trunk%252Fwp-admin%252Fplugins.php%26action%3D-1%26action2%3D-1&action=-1&paged=1&action2=-1

I don't know for sure that this is a problem, but it seems like it might have some URL params that it does not need.

#5 @ocean90
13 years ago

Also bulk stuff will not work any longer, because they rely on $_POST.

#6 @dd32
13 years ago

Also bulk stuff will not work any longer, because they rely on $_POST.

For posts/etc it's fine as the checkboxes are ID's, for Plugins the checkbox values are going to be Plugin names, so on average lets say 20char long.. That'll easily make a looong url when you perform bulk actions on many plugins..

#7 @scribu
13 years ago

We can leave the action as POST, but make the search check $_REQUEST. Then, we could just pass 's' into the pagination URL.

#8 @dd32
13 years ago

  • Keywords has-patch added; needs-patch removed
  • Owner set to dd32
  • Status changed from new to accepted

Since the list tables have no filters of any kind on the pagination, it's a bit hard to do this any other way.

I seem to recall something bad about modifying $_SERVER['REQUEST_URI'] with add_query_arg(), but I can't remember what it was; So this is my patch: (Any comments?)

  • wp-admin/includes/class-wp-plugins-list-table.php

     
    2121                if ( $status != $default_status && 'search' != $status )
    2222                        update_user_meta( get_current_user_id(), 'plugins_last_view', $status );
    2323
     24
     25                if ( isset($_REQUEST['s']) )
     26                        $_SERVER['REQUEST_URI'] = add_query_arg('s', stripslashes($_REQUEST['s']) );
     27
    2428                $page = $this->get_pagenum();
    2529
    2630                parent::__construct( array(
Last edited 13 years ago by dd32 (previous) (diff)

#9 @scribu
13 years ago

It's cool that you can post diffs inline, but that makes it a chore to apply it to a local install.

#10 @dd32
13 years ago

I wasn't expecting you to attempt to apply it locally though :) I'll attach a diff

@dd32
13 years ago

#11 @scribu
13 years ago

Thanks :)

#12 @johnjamesjacoby
13 years ago

Tested 17285.diff.

Confirmed fixed.

#13 @ryan
13 years ago

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

In [18093]:

Fix paging through plugin search results. Props dd32. fixes #17285

Note: See TracTickets for help on using tickets.