Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination issue after upgrading to 2.0.50 #20186

Closed
fejan-malek opened this issue Jun 5, 2024 · 3 comments
Closed

Pagination issue after upgrading to 2.0.50 #20186

fejan-malek opened this issue Jun 5, 2024 · 3 comments
Milestone

Comments

@fejan-malek
Copy link

fejan-malek commented Jun 5, 2024

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;
    }
@OndrejVasicek
Copy link
Contributor

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.

@fejan-malek
Copy link
Author

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

@terabytesoftw
Copy link
Member

terabytesoftw commented Jun 5, 2024

Related: #20175

PR: #20176

@samdark samdark added this to the 2.0.50.1 milestone Jun 5, 2024
@samdark samdark closed this as completed Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants