yiisoft / yii-dataview

Data widgets
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
38 stars 21 forks source link

Any proposed way of setting or disabling pageSizeLimit #190

Closed armpogart closed 1 month ago

armpogart commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

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

armpogart commented 9 years ago

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 commented 9 years ago
$dataProvider = new ActiveDataProvider([
    'query' => $query,
    'pagination' => [
        'pageSizeLimit' => [1],
    ]
]);
armpogart commented 9 years ago

@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 commented 7 years ago

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 commented 1 month ago

Closing since there's no such limit anymore.

vjik commented 1 month ago

Suggestion: https://github.com/yiisoft/yii-dataview/issues/218