[php-src] Issue #10654: Exceeding max_file_uploads causes an apparently unrelated "cannot modify headers" warning before script execution
| From: | php4fan | Date: | Tue, 21 Feb 2023 19:28:08 +0000 |
| Subject: | [php-src] Issue #10654: Exceeding max_file_uploads causes an apparently unrelated "cannot modify headers" warning before script execution | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243768@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10654
Author: php4fan
### Description
The following code:
```php
<?php
if (!empty($_POST))
echo "Done.";
else {
?><!DOCTYPE html>
<html>
<head><title>xxxx</title></head>
<body>
<form method="post" enctype="multipart/form-data">
<div>Lalalala</div>
<input type="file" multiple name="diocane">
<input type="hidden" name="something" value="1">
<button type="submit">Upload</button>
</form>
</body>
</html>
<?php
}
```
when uploading 21 files (one more than the value of
max_file_uploads), resulted in this
output:
```
Warning: Maximum number of allowable file uploads has been exceeded in Unknown on line 0
Warning: Cannot modify header information - headers already sent in Unknown on line 0
Done.
```
But I expected this output instead:
```
Warning: Maximum number of allowable file uploads has been exceeded in Unknown on line 0
```
I am not attempting to set any header, and yet I get the "cannot modify header
information" error. I understand that headers cannot be set because of the output that was
generated because of the warning, but again, my code did not attempt to send any header.
It seems that PHP is trying to set some headers, during the startup phase (i.e. before my script
gets executed), but:
1. I'm not sure there's a good reason for that
2. if there is, do it before you handle uploaded files, or maybe silence the "cannot modify
header information" warning when you do.
3. give more information in the error message so that I can at least figure out what headers failed
to be sent.
### PHP Version
PHP 7.4.11
### Operating System
Debian 10