From:             mikko dot rantalainen at peda dot net
Operating system: Ubuntu Linux 6.06
PHP version:      5CVS-2007-07-12 (CVS)
PHP Bug Type:     Feature/Change Request
Bug description:  A feature to detect post_max_size exceeded (plus friends)

Description:
------------
As described in http://php.net/manual/en/ini.core.php#ini.post-max-size if
the POST data is greater than post_max_size, then both $_POST and $_FILES
are empty. The documentation shows a way using the $_GET array as a
workaround to detect the situation. However, such workaround cannot be
always used because script author may not be the author of the original
form and as such cannot add any GET parameters to said form. A method to
identify the situation where the user has exceeded post_max_size is
therefore required.

I'm suggesting a generic solution:

Add function get_server_status()

This function returns an integer which is a sum (bit mask) of following
constants

/** HTTP input has or had GET parameters */
SERVER_STATUS_HAD_GET_DATA 1
/** HTTP input has or had POST data */
SERVER_STATUS_HAD_POST_DATA 2
/** HTTP input has or had uploaded files */
SERVER_STATUS_HAD_FILES 4
/** post_max_size was exceeded, $_POST and $_FILES are empty */
SERVER_STATUS_POST_MAX_SIZE_TRIGGERED 8
/** max_filesize was exceeded */
SERVER_STATUS_UPLOAD_MAX_FILESIZE_TRIGGERED 16
/** memory_limit was exceeded before start of the script */
SERVER_STATUS_MEMORY_LIMIT_TRIGGERED 32
/** max_input_time exceeded before start of the script */
SERVER_STATUS_MAX_INPUT_TIME_TRIGGERED 64

This way a script could also handle the case there memory_limit was hit
because the uploaded file was too big (at least older versions of PHP
required at least as much memory as the size of the upload). However,
because the memory space that was not enough for file upload is now free to
use for PHP, the script should be able to handle the situation using that
same memory (e.g. tell the user about the issue in a nice way or redirect
to alternative method).

Note that I've named the function get_server_status() instead of
get_input_status() or get_http_input_status() so that this same function
can be extended in the future for other server/php host status.

Feel free to drop constants/situations that cannot be handled by the
script, they are of no use in any case.



-- 
Edit bug report at http://bugs.php.net/?id=41977&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41977&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41977&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41977&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41977&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41977&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41977&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41977&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41977&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41977&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41977&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41977&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41977&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41977&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41977&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41977&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41977&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41977&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41977&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41977&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41977&r=mysqlcfg

Reply via email to