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

Any proposed way of setting or disabling pageSizeLimit #190

Closed
armpogart opened this issue Aug 14, 2015 · 8 comments
Closed

Any proposed way of setting or disabling pageSizeLimit #190

armpogart opened this issue Aug 14, 2015 · 8 comments

Comments

@armpogart
Copy link

yii2 REST API uses ActiveDataProvider to fetch and show data. This class has pageSizeLimit parameter which by default limit our pageSize to 50, so no matter how high is per-page (pageSizeParam) query parameter, maximum 50 rows are returned.

Is there any way to completely disable pageSizeLimit so that provider will show as many rows as we want by specifying per-page query parameter or defaultPageSize if not specified? Setting pageSizeLimit to false forces to always return defaultPageSize rows no matter what we pass by per-page.

Further investigation of source code showed, that setting pageSizeLimit to anything but false or two-dimensional array works, because the code in that case completely ignores pageSizeLimit link.

Won't it be better if we have framework proposed way of doing it and not hack, e.g. specifying only lower limit, or setting it true or something to obviously take the query param? I can make pull request if we come up with the way of specifying it...

@cebe
Copy link
Member

cebe commented Aug 14, 2015

You should always apply an upper bound to the page size because your system will run out of memory when processing too large pages.

@nineinchnick
Copy link
Contributor

It won't if you're using a DataReader and streaming the response without buffering 😄

You can write your own stream class that does that and hook it up in the Response object.

@armpogart
Copy link
Author

OK, I understand the limitation of running out of memory, but for the REST response:

  1. It is very difficult to run out of memory (usually)
  2. It's up to developer, I don't propose to change the default behavior, I propose to have way of disabling this limit at all.

At the end it was discussed many times here on github (under different issues) that the framework (yii) must not limit the developer, it can propose the right way to do something with its' defaults, but not limit him/her.

Currently I have very concise JSON objects in my response and I read 1000 row response without any problems and without increasing default php memory limit. And I can't say exactly yet how much more I will be able to read in one go. I'm using REST as backend for Android application which does it's job in seperate thread and it has no any limitation there either, and for now it is very much convenient for me to read the whole response from Android and not go page by page.

In my case: REST request is filtered and the response theoretically can't grow so much that I will hit any limit, so I don't see reason why I can't disable that limit on my own risk. (actually I can, but I don't think that using flow of code to disable it is the right way)

@mdmunir
Copy link
Contributor

mdmunir commented Aug 15, 2015

$dataProvider = new ActiveDataProvider([
    'query' => $query,
    'pagination' => [
        'pageSizeLimit' => [1],
    ]
]);

@armpogart
Copy link
Author

@mdmunir Your code is not the way of disabling pageSizeLimit, it is just a workaround. As I said anything but false and two dimensional array will work. Your way of doing it is the worst in my opinion, as you may think, tha giving one value in array will at least set lowet limit, but it will ignore that value.

@lgelfan
Copy link

lgelfan commented Jun 13, 2017

Now that some time has passed, is there a "best practice" for changing (not necessarily disabling) the default pagination values? I realize I can override the yii/rest/IndexAction and change the pagination attributes, but this seems like something that should be more a config change than an override.

@samdark samdark transferred this issue from yiisoft/yii2 Apr 24, 2019
@Tigrov Tigrov transferred this issue from yiisoft/active-record Jun 7, 2024
@vjik vjik transferred this issue from yiisoft/data Jun 7, 2024
@samdark
Copy link
Member

samdark commented Sep 27, 2024

Closing since there's no such limit anymore.

@samdark samdark closed this as completed Sep 27, 2024
@vjik
Copy link
Member

vjik commented Sep 29, 2024

Suggestion: #218

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

7 participants