changed upload limit calculation logic
Details
Static test code:
echo MAX_UPLOAD_SIZE; exit;
Dynamic test code:
ini_set('memory_limit', '');
Test Plan
- Put static test code in the index.php, after $application->Init();
- Put dynamic test code in the index.php, before $application->Init();
- For below listed test data confirm, that MAX_UPLOAD_SIZE constant value is calculated correctly using this data:
- 1G, 75000K, '50M' => 52428800
- 1G, 75000K, '100M' => 76800000
- 300000, 7500K, '100M' => 300000
- 300000, 0, '100M' => 300000
- 300000, 4K, '-1' => 4096
- 300000, 0, '-1' => 300000
How to read test data:
- first value goes into upload_max_filesize setting from php.ini file
- second value goes into post_max_size setting from php.ini file
- third value is set as second parameter in the dynamic test code
- value after => is what should be displayed on the screen
- restarting web server & memcache before starting each test
Diff Detail
- Repository
- rINP In-Portal
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
core/kernel/globals.php | ||
---|---|---|
1007–1025 ↗ | (On Diff #869) | Considering that method is called several times (3 at max) during each page load you though refactor it to make it maximally fast (maybe examples exist on the internet). Several ideas to consider, but feel free to do what you think is best:
|
core/kernel/startup.php | ||
118–123 ↗ | (On Diff #869) | Please wrap all that in self-invoking anonymous function (aka closure). All these temp variables used to calculate constant value pollute global scope. |
120 ↗ | (On Diff #869) | Please replace $post_max_size !== '0' with (string)$post_max_size !== '0'. I'm not sure if ini_get is doing any automatic type casting or not. |
122 ↗ | (On Diff #869) | Please replace $memory_limit !== '-1' with (string)$memory_limit !== '-1'. I'm not sure if ini_get is doing any automatic type casting or not. |
Also the test plan doesn't cover a glimpse of what's actually being checked in code. To test what you've done you need to manually change values of corresponding setting via ini_set (to cover each if/else created) before calling new code from startup.php to assert that result is desired number of bytes.