yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework

Home Page:http://www.yiiframework.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pagination issue after upgrading to 2.0.50

fejan-malek opened this issue · comments

What steps will reproduce the problem?

  1. Create a simple CRUD.
  2. From search return all the records and from controller pass parameters for a filter like employee_id.

What is the expected result?

It must return data that is related to the particular employee documents only.

What do you get instead?

It returns 2 data in Gridview but the count is for all the employee-related documents.

Additional info

Q A
Yii version 2.0.50?
PHP version 8.0.25
Operating system Mac OS
Screenshot 2024-06-05 at 12 59 31 PM

Below is my search function look like.

    public function search($params)
    {
        $query = EmployeePayslip::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]],
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }
        $dataProvider->pagination->pageSize = $this->pageSize ?? Yii::$app->params['pageSize'];

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'employee_id' => $this->employee_id,
            'payslip_type' => $this->payslip_type,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);

        $query->andFilterWhere(['like', 'remark', $this->remark])
            ->andFilterWhere(['like', "DATE_FORMAT(pay_start_date, '%d-%m-%Y')", $this->pay_start_date])
            ->andFilterWhere(['like', "DATE_FORMAT(pay_end_date, '%d-%m-%Y')", $this->pay_end_date])
            ->andFilterWhere(['like', 'payslip_no', $this->payslip_no]);

        return $dataProvider;
    }

Well it looks like there is much much bigger problem with the new update. I bricked my whole CMS. Searching is broken but also saving of every model screams errors like
...vendor\yiisoft\yii2\db\ActiveQueryTrait.php(181): yii\db\BaseActiveRecord->getRelation('admi_csrf')
or
...vendor\yiisoft\yii2\db\ActiveQueryTrait.php(181): yii\db\BaseActiveRecord->getRelation('id')
even though there are not such relations. I'm still collecting data and info but I thing you just discovered one output of a bigger problem with this update.
I updated the Yii ASAP because of the security fixes, but this situation is unfortunate.

I updated this version with my production project and there I identified the issue.
But now I am downgraded to 2.0.49.