From 1ae4103b9d38dc8319d084b0aebce6e085dcdaa6 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sat, 23 Nov 2013 18:08:14 +0100 Subject: [PATCH] fixed Sort::params to be retrieved from Request instead of $_GET for consistency with paginiation --- framework/yii/data/Sort.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/framework/yii/data/Sort.php b/framework/yii/data/Sort.php index 7612641..8a1b36c 100644 --- a/framework/yii/data/Sort.php +++ b/framework/yii/data/Sort.php @@ -12,6 +12,7 @@ use yii\base\InvalidConfigException; use yii\base\Object; use yii\helpers\Html; use yii\helpers\Inflector; +use yii\web\Request; /** * Sort represents information relevant to sorting. @@ -240,7 +241,10 @@ class Sort extends Object { if ($this->_attributeOrders === null || $recalculate) { $this->_attributeOrders = []; - $params = $this->params === null ? $_GET : $this->params; + if (($params = $this->params) === null) { + $request = Yii::$app->getRequest(); + $params = $request instanceof Request ? $request->get() : []; + } if (isset($params[$this->sortVar]) && is_scalar($params[$this->sortVar])) { $attributes = explode($this->separators[0], $params[$this->sortVar]); foreach ($attributes as $attribute) { @@ -332,7 +336,10 @@ class Sort extends Object */ public function createUrl($attribute) { - $params = $this->params === null ? $_GET : $this->params; + if (($params = $this->params) === null) { + $request = Yii::$app->getRequest(); + $params = $request instanceof Request ? $request->get() : []; + } $params[$this->sortVar] = $this->createSortVar($attribute); $route = $this->route === null ? Yii::$app->controller->getRoute() : $this->route; $urlManager = $this->urlManager === null ? Yii::$app->getUrlManager() : $this->urlManager;