diff --git a/api/RestfulServer.php b/api/RestfulServer.php index b2825050e1b..32bdce941c2 100644 --- a/api/RestfulServer.php +++ b/api/RestfulServer.php @@ -203,10 +203,13 @@ function index() { * @return String The serialized representation of the requested object(s) - usually XML or JSON. */ protected function getHandler($className, $id, $relationName) { - $sort = array( - 'sort' => $this->request->getVar('sort'), - 'dir' => $this->request->getVar('dir') - ); + $sort = ''; + + if($this->request->getVar('sort')) { + $dir = $this->request->getVar('dir'); + $sort = array($this->request->getVar('sort') => ($dir ? $dir : 'ASC')); + } + $limit = array( 'start' => $this->request->getVar('start'), 'limit' => $this->request->getVar('limit')