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::totalCount initialized incorrectly #16891

Closed
taobig opened this issue Nov 16, 2018 · 3 comments
Closed

Pagination::totalCount initialized incorrectly #16891

taobig opened this issue Nov 16, 2018 · 3 comments

Comments

@taobig
Copy link
Contributor

taobig commented Nov 16, 2018

What steps will reproduce the problem?

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'totalCount' => $totalCount,//the value is difference from $query->count()
            'pagination' => [
            ],
        ]);
        echo $dataProvider->pagination->page;//always 0

What is the expected result?

$dataProvider->pagination->page == $_GET['page']

What do you get instead?

$dataProvider->pagination->page;//always 0

Additional info

correct code:

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'totalCount' => $totalCount,//the value is difference from $query->count()
            'pagination' => [
                totalCount' => $totalCount,// add this line
            ],
        ]);

or

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'totalCount' => $totalCount,//the value is difference from $query->count()
            'pagination' => [
            ],
        ]);
        $dataProvider->getModels();// add this line

I found yii\data\Pagination::getPageCount() to use totalCount without initialized.

Q A
Yii version 2.0.15.1
PHP version 7.2
Operating system
@taobig taobig changed the title Pagination totalCount initialized incorrectly Pagination::totalCount initialized incorrectly Nov 16, 2018
@cebe cebe added status:to be verified Needs to be reproduced and validated. type:bug Bug labels Nov 16, 2018
@samdark samdark removed the status:to be verified Needs to be reproduced and validated. label Nov 19, 2018
@samdark
Copy link
Member

samdark commented Nov 19, 2018

Yes. That's how it is currently. Any idea on how to fix it?

@samdark
Copy link
Member

samdark commented Jan 16, 2019

@GHopperMSK would you please check regression that's caused by solving this task? yiisoft/yii2-elasticsearch#201 Thanks!

@samdark
Copy link
Member

samdark commented Jan 17, 2019

Fixed in in ElasticSearch. Probably a good idea to release it first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants