Possible risks of the limit
method
#53910
Replies: 4 comments
-
Hi. About the exception part, it is better to put it 0 than to throw something. |
Beta Was this translation helpful? Give feedback.
-
In our example the limit being array or file will throw php exception which will result in empty response. For string or integer it will use the max response. |
Beta Was this translation helpful? Give feedback.
-
I very much agree with you. Never trust user input. But I still feel that a method should not have two functions that violate a single principle of design principles. |
Beta Was this translation helpful? Give feedback.
-
From past experience, helping users make choices can sometimes hide the problem, making it undetectable. Therefore, I also agree with the approach of throwing exceptions. Or bringing the "problem" to SQL to decide how to handle it. |
Beta Was this translation helpful? Give feedback.
-
Laravel Version
latest
PHP Version
8.x
Database Driver & Version
No response
Description
framework/src/Illuminate/Database/Query/Builder.php
Lines 2767 to 2776 in a306193
The example codes:
If "limit" is mistakenly passed as -1, it means that all data will be updated.
I believe that when the input value is less than 0, it should not be ignored directly but should throw an exception instead.
Steps To Reproduce
No need to provide reproduction steps
Beta Was this translation helpful? Give feedback.
All reactions