Skip to content

Commit

Permalink
Add E_DEPRECATED when populating $HTTP_RAW_POST_DATA
Browse files Browse the repository at this point in the history
  • Loading branch information
m6w6 committed Dec 30, 2013
1 parent 729f85f commit 4797f7a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions main/php_content_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
php_stream_rewind(SG(request_info).request_body);

SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, length);

sapi_module.sapi_error(E_DEPRECATED,
"Automatically populating $HTTP_RAW_POST_DATA is deprecated and "
"will be removed in a future version. To avoid this warning set "
"'always_populate_raw_post_data' to '-1' in php.ini and use the "
"php://input stream instead.");
}
}
}
Expand Down
1 change: 0 additions & 1 deletion main/php_variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,6 @@ static zend_bool php_auto_globals_create_post(const char *name, uint name_len TS

if (PG(variables_order) &&
(strchr(PG(variables_order),'P') || strchr(PG(variables_order),'p')) &&
!SG(headers_sent) &&
SG(request_info).request_method &&
!strcasecmp(SG(request_info).request_method, "POST")) {
sapi_module.treat_data(PARSE_POST, NULL, NULL TSRMLS_CC);
Expand Down
3 changes: 3 additions & 0 deletions tests/basic/024.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ a=ABC&y=XYZ&c[]=1&c[]=2&c[a]=3
var_dump($_POST, $HTTP_RAW_POST_DATA);
?>
--EXPECT--
Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0

Warning: Cannot modify header information - headers already sent in Unknown on line 0
array(3) {
["a"]=>
string(3) "ABC"
Expand Down
3 changes: 3 additions & 0 deletions tests/basic/026.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ a=1&b=ZYX
var_dump($_POST, $HTTP_RAW_POST_DATA);
?>
--EXPECT--
Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0

Warning: Cannot modify header information - headers already sent in Unknown on line 0
array(0) {
}
string(9) "a=1&b=ZYX"

0 comments on commit 4797f7a

Please sign in to comment.