cakephp/cakephp — pull request #2753 by Grafikart (2014-01-31 14:54:12+00:00)
Title: Cleaner URL for paginatorHelper

Avoid appending &sort and &direction if the sort parameters are the one from options

## Problem

PaginatorHelper is appending **sort** and **direction** parameter even if it's not needed

## Solution

Pass the default **sort** and **direction** into $this->request->params['paging'] (sortDefault and directionDefault)
Within the PaginatorHelper::url() method check if the params are the same and unset $url['sort'] and $url['direction']

## Use Case

// Controller
public $paginate = ['order' => ['Posts.created' => 'asc'], 'limit' => 10];

// View
$this->Paginator->numbers()
// Was generating
url?page=2&sort=Posts.created&direction=asc
// Now generates
url?page=2

If more than one order is defined my behavior is not used and the sort parameter is injected again

// Controller
public $paginate = ['order' => ['Posts.created' => 'asc', 'Posts.name' => 'asc'], 'limit' => 10];

// View
$this->Paginator->numbers()
// Was generating and will keep generating this
url?page=2&sort=Pots.created&direction=asc

That's still a problem but (since the default order will be lost) but in my opinion it's a specific use case.
I don't know if paginator is supposed to support multiple orders so I didn't edited this use case.