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

X-Pagination-Total-Count always = 0 after update composer #355

Open
pctin opened this issue Mar 4, 2025 · 11 comments
Open

X-Pagination-Total-Count always = 0 after update composer #355

pctin opened this issue Mar 4, 2025 · 11 comments

Comments

@pctin
Copy link

pctin commented Mar 4, 2025

After composer update from 2.1.5 to 2.1.6 then ActiveDataProvider return paging with totalCount =0 then X-Pagination-Total-Count for serialize to frontend = 0. The models still return correct.

@samdark
Copy link
Member

samdark commented Mar 4, 2025

Do you mean master or 2.1.5? There's no 2.1.6.

@pctin
Copy link
Author

pctin commented Mar 5, 2025

Yes, it's master. The problem is the pagination of ActiveDataProvider can't get the totalCount so it didnot assign to the Serializer of RestController.

@samdark
Copy link
Member

samdark commented Mar 5, 2025

If you roll back to 2.1.15, does it work?

@tarunjangra
Copy link

tarunjangra commented Mar 8, 2025

Hi, I can also confirm them. I upgraded to 2.1.5 about 4 days ago, since then pagging stopped working. I found totalCount remains 0. I just downgraded to 2.1.4, now it back to work.

@samdark
Copy link
Member

samdark commented Mar 11, 2025

Could be connected with #350 @lav45 would you please take a look?

@lav45
Copy link
Contributor

lav45 commented Mar 12, 2025

Please show an example of your code how you use the ActiveDataProvider.
@pctin @tarunjangra

@pctin
Copy link
Author

pctin commented Mar 13, 2025

Hi, this is my code below:

$dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSizeLimit' => [1, 500000]
            ],
            'sort' => [
                'defaultOrder' => [
                    'debt_no' => SORT_ASC,
                ]
            ],
        ]);
...
$query->addOptions(['track_total_hits' => 'true']);

return $dataProvider;

Just simple that, the code worked fine before update new version (from 2.1.5)

@lav45
Copy link
Contributor

lav45 commented Mar 16, 2025

@pctin This issue has been fixed in yiisoft/yii2:2.0.51

composer require 'yiisoft/yii2:>=2.0.51'

@samdark samdark closed this as completed Mar 16, 2025
@pctin
Copy link
Author

pctin commented Mar 17, 2025

@pctin This issue has been fixed in yiisoft/yii2:2.0.51

composer require 'yiisoft/yii2:>=2.0.51'

Hi, it did not work with version 2.0.51-52 of 'yiisoft/yii2'

@samdark samdark reopened this Mar 17, 2025
@lav45 lav45 mentioned this issue Mar 17, 2025
@lav45
Copy link
Contributor

lav45 commented Mar 17, 2025

@samdark my pagination-related changes have been canceled.
yiisoft/yii2#20226

I canceled them here too.
Fixed 2 bugs related to $provider->prepare(true); and $timestamp is float in microseconds.

@samdark
Copy link
Member

samdark commented Mar 18, 2025

@pctin, @tarunjangra would you please try #356?

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