google-code-export / wordpress-custom-content-type-manager

Automatically exported from code.google.com/p/wordpress-custom-content-type-manager
2 stars 1 forks source link

Thickbox Sorts incorrectly after page navigation #502

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Open the thickbox, e.g. to select an image, flip through to the next page, then 
come back to page 1.  The items are not the same.  Looks like sort order has 
flipped -- what was the first result ends up on the last page.

Original issue reported on code.google.com by ever...@fireproofsocks.com on 17 May 2013 at 6:36

GoogleCodeExporter commented 9 years ago
The first pop of the thickbox, the default parameters are used, so you might 
have something like this:

Array
(
    [action] => get_posts
    [post_type] => movie
    [fieldname] => gallery
    [fieldtype] => image
    [wrap_thickbox] => 1
    [get_posts_nonce] => e9e8c3e33e
)

Note that the search_parameters are NOT set.  Default parameters are used:
    [orderby] => ID
    [order] => DESC

When you flip to page 2, notice that the search_parameters are set:

[search_parameters] => 
fieldname=gallery&fieldtype=image&page_number=2&orderby=ID&order=ASC&search_term
=&yearmonth=

When you click back on "First", the search_parameters are not explicitly set:

Array
(
    [action] => get_posts
    [post_type] => movie
    [fieldname] => gallery
    [fieldtype] => image
    [get_posts_nonce] => e9e8c3e33e
    [search_parameters] => fieldname=gallery&fieldtype=image&page_number=1&orderby=ID&order=ASC&search_term=&yearmonth=
)

Solution was to specify default arguments for the GetPostsQuery in the 
ajax-controllers/get_posts.php line 84

$args['orderby'] = 'ID';
$args['order'] = 'ASC';

Committed revision 747597.

Original comment by ever...@fireproofsocks.com on 29 Jul 2013 at 2:59