Skip to content

Commit f0d8de4

Browse files
committed
Merge branch 'master' of https://git.php.net/repository/php-src
* 'master' of https://git.php.net/repository/php-src: (27 commits) final bits we need to use the full stream wrapper for filters let the libsqlite3 symbols be exported in dll NEWS/UPGRADING{,.INTERNALS} notes about temp POST stream Exclude bison 3.0 by Mike NEWS for added reserved ip addresses according to RFC 6598 Add RFC 6598 IPs to reserved addresses upload2G note NEWS for #60577 NEWS for bug #64441 Fix bug #64441 (FILTER_VALIDATE_URL rejects fully qualified domain names) EmptyIterator now implements Countable; fixes bug 60577 News for bugfix #64157 Bug 64157 Changed error message to make sense remove unused code tests make reading php://input JIT if enable_post_data_reading=0 revert stream cast fix ZTS build slim post data ...
2 parents 699b43f + e6084da commit f0d8de4

33 files changed

+660
-230
lines changed

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ PHP NEWS
99
. Made calls from incompatible context issue an E_DEPRECATED warning instead
1010
of E_STRICT (phase 1 of RFC: https://wiki.php.net/rfc/incompat_ctx).
1111
(Gustavo)
12+
. Uploads equal or greater than 2GB in size are now accepted.
13+
(Ralf Lang, Mike)
14+
. Reduced POST data memory usage by 200-300%. Removed INI setting
15+
always_populate_raw_post_data and the $HTTP_RAW_POST_DATA global
16+
variable. (Mike)
1217

1318
- cURL:
1419
. Implemented FR #65646 (re-enable CURLOPT_FOLLOWLOCATION with open_basedir

UPGRADING

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,23 @@ PHP X.Y UPGRADE NOTES
2020
1. Backward Incompatible Changes
2121
========================================
2222

23+
- Core:
24+
Removed $HTTP_RAW_POST_DATA global variable. Restore backwards compatibility
25+
by:
26+
<?php
27+
global $HTTP_RAW_POST_DATA;
28+
if (!isset($HTTP_RAW_POST_DATA)) {
29+
$HTTP_ROW_POST_DATA = file_get_contents("php://input");
30+
}
31+
?>
2332

2433
========================================
2534
2. New Features
2635
========================================
2736

37+
- Core:
38+
The php://input stream is now re-usable and can be used concurrently with
39+
enable_post_data_reading=0.
2840

2941
========================================
3042
2. Changes in SAPI modules
@@ -91,6 +103,8 @@ PHP X.Y UPGRADE NOTES
91103
10. Changes to INI File Handling
92104
========================================
93105

106+
- Core:
107+
Removed always_populate_raw_post_data.
94108

95109
========================================
96110
11. Other Changes

UPGRADING.INTERNALS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ UPGRADE NOTES - PHP X.Y
55
1. Internal API changes
66
a. Addition of do_operation and compare object handlers
77
b. return_value_ptr now always available, RETVAL_ZVAL_FAST macros
8+
c. POST data handling
89

910
2. Build system changes
1011
a. Unix build system changes
@@ -57,6 +58,15 @@ UPGRADE NOTES - PHP X.Y
5758
The macros behave similarly to the non-FAST variants with copy=1 and
5859
dtor=0, but will try to return the zval without making a copy by utilizing
5960
return_value_ptr.
61+
62+
c. POST data handling
63+
64+
The sapi_request_info's members post_data, post_data_len and raw_post_data as
65+
well as raw_post_data_len have been replaced with a temp PHP stream
66+
request_body.
67+
68+
The recommended way to access raw POST data is to open and use a php://input
69+
stream wrapper. It is safe to be used concurrently and more than once.
6070

6171
========================
6272
2. Build system changes

Zend/acinclude.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ AC_DEFUN([LIBZEND_BISON_CHECK],[
99
# non-working versions, e.g. "3.0 3.2";
1010
# remove "none" when introducing the first incompatible bison version an
1111
# separate any following additions by spaces
12-
bison_version_exclude="none"
12+
bison_version_exclude="3.0"
1313
1414
# for standalone build of Zend Engine
1515
test -z "$SED" && SED=sed

ext/date/lib/parse_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25002,7 +25002,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
2500225002
TIMELIB_CHECK_NUMBER;
2500325003
sec = timelib_get_nr_ex((char **) &ptr, 2, &length);
2500425004
if (sec == TIMELIB_UNSET || length != 2) {
25005-
add_pbf_error(s, "A two second minute could not be found", string, begin);
25005+
add_pbf_error(s, "A two digit second could not be found", string, begin);
2500625006
} else {
2500725007
s->time->s = sec;
2500825008
}

ext/date/lib/parse_date.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
20092009
TIMELIB_CHECK_NUMBER;
20102010
sec = timelib_get_nr_ex((char **) &ptr, 2, &length);
20112011
if (sec == TIMELIB_UNSET || length != 2) {
2012-
add_pbf_error(s, "A two second minute could not be found", string, begin);
2012+
add_pbf_error(s, "A two digit second could not be found", string, begin);
20132013
} else {
20142014
s->time->s = sec;
20152015
}

ext/date/tests/bug64157.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Test for bug #64157: DateTime::createFromFormat() reports confusing error message
3+
--CREDITS--
4+
Boro Sitnikovski <[email protected]>
5+
--INI--
6+
date.timezone = UTC
7+
--FILE--
8+
<?php
9+
DateTime::createFromFormat('s', '0');
10+
$lastErrors = DateTime::getLastErrors();
11+
print_r($lastErrors['errors'][0]);
12+
?>
13+
--EXPECT--
14+
A two digit second could not be found

ext/filter/logical_filters.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,6 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
484484
}
485485
s++;
486486
}
487-
488-
if (*(e - 1) == '.') {
489-
goto bad_url;
490-
}
491487
}
492488

493489
if (
@@ -718,6 +714,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
718714
if (flags & FILTER_FLAG_NO_RES_RANGE) {
719715
if (
720716
(ip[0] == 0) ||
717+
(ip[0] == 100 && (ip[1] == 0 || ip[1] <= 127)) ||
721718
(ip[0] == 128 && ip[1] == 0) ||
722719
(ip[0] == 191 && ip[1] == 255) ||
723720
(ip[0] == 169 && ip[1] == 254) ||

ext/filter/tests/018.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var_dump(filter_var("192.168.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE
1515
var_dump(filter_var("192.0.34.166", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE));
1616
var_dump(filter_var("127.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
1717
var_dump(filter_var("192.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
18+
var_dump(filter_var("100.0.0.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
19+
var_dump(filter_var("100.127.255.255", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
1820
var_dump(filter_var("192.0.34.166", FILTER_VALIDATE_IP));
1921
var_dump(filter_var("256.1237.123.1", FILTER_VALIDATE_IP));
2022
var_dump(filter_var("255.255.255.255", FILTER_VALIDATE_IP));
@@ -40,6 +42,8 @@ bool(false)
4042
string(12) "192.0.34.166"
4143
bool(false)
4244
string(9) "192.0.0.1"
45+
bool(false)
46+
bool(false)
4347
string(12) "192.0.34.166"
4448
bool(false)
4549
string(15) "255.255.255.255"

ext/filter/tests/bug64441.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
bug 64441, FILTER_VALIDATE_URL will invalidate a hostname that ended by dot
3+
--SKIPIF--
4+
<?php if (!extension_loaded("filter")) die("skip"); ?>
5+
--FILE--
6+
<?php
7+
var_dump(filter_var('http://example.com./', FILTER_VALIDATE_URL));
8+
var_dump(filter_var('http://example.com/', FILTER_VALIDATE_URL));
9+
--EXPECT--
10+
string(20) "http://example.com./"
11+
string(19) "http://example.com/"

ext/mbstring/mb_gpc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ SAPI_POST_HANDLER_FUNC(php_mb_post_handler)
364364
{
365365
const mbfl_encoding *detected;
366366
php_mb_encoding_handler_info_t info;
367+
char *post_data_str = NULL;
367368

368369
MBSTRG(http_input_identify_post) = NULL;
369370

@@ -376,7 +377,10 @@ SAPI_POST_HANDLER_FUNC(php_mb_post_handler)
376377
info.num_from_encodings = MBSTRG(http_input_list_size);
377378
info.from_language = MBSTRG(language);
378379

379-
detected = _php_mb_encoding_handler_ex(&info, arg, SG(request_info).post_data TSRMLS_CC);
380+
php_stream_rewind(SG(request_info).request_body);
381+
php_stream_copy_to_mem(SG(request_info).request_body, &post_data_str, PHP_STREAM_COPY_ALL, 0);
382+
detected = _php_mb_encoding_handler_ex(&info, arg, post_data_str TSRMLS_CC);
383+
STR_FREE(post_data_str);
380384

381385
MBSTRG(http_input_identify) = detected;
382386
if (detected) {

ext/soap/soap.c

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,48 +1560,45 @@ PHP_METHOD(SoapServer, handle)
15601560
}
15611561

15621562
if (ZEND_NUM_ARGS() == 0) {
1563-
if (SG(request_info).raw_post_data) {
1564-
char *post_data = SG(request_info).raw_post_data;
1565-
int post_data_length = SG(request_info).raw_post_data_length;
1563+
if (SG(request_info).request_body && 0 == php_stream_rewind(SG(request_info).request_body)) {
15661564
zval **server_vars, **encoding;
1565+
php_stream_filter *zf = NULL;
15671566

15681567
zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
15691568
if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **) &server_vars) == SUCCESS &&
15701569
Z_TYPE_PP(server_vars) == IS_ARRAY &&
15711570
zend_hash_find(Z_ARRVAL_PP(server_vars), "HTTP_CONTENT_ENCODING", sizeof("HTTP_CONTENT_ENCODING"), (void **) &encoding)==SUCCESS &&
15721571
Z_TYPE_PP(encoding) == IS_STRING) {
1573-
zval func;
1574-
zval retval;
1575-
zval param;
1576-
zval *params[1];
1577-
1578-
if ((strcmp(Z_STRVAL_PP(encoding),"gzip") == 0 ||
1579-
strcmp(Z_STRVAL_PP(encoding),"x-gzip") == 0) &&
1580-
zend_hash_exists(EG(function_table), "gzinflate", sizeof("gzinflate"))) {
1581-
ZVAL_STRING(&func, "gzinflate", 0);
1582-
params[0] = &param;
1583-
ZVAL_STRINGL(params[0], post_data+10, post_data_length-10, 0);
1584-
INIT_PZVAL(params[0]);
1585-
} else if (strcmp(Z_STRVAL_PP(encoding),"deflate") == 0 &&
1586-
zend_hash_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress"))) {
1587-
ZVAL_STRING(&func, "gzuncompress", 0);
1588-
params[0] = &param;
1589-
ZVAL_STRINGL(params[0], post_data, post_data_length, 0);
1590-
INIT_PZVAL(params[0]);
1572+
1573+
if (strcmp(Z_STRVAL_PP(encoding),"gzip") == 0
1574+
|| strcmp(Z_STRVAL_PP(encoding),"x-gzip") == 0
1575+
|| strcmp(Z_STRVAL_PP(encoding),"deflate") == 0
1576+
) {
1577+
zval filter_params;
1578+
1579+
INIT_PZVAL(&filter_params);
1580+
array_init_size(&filter_params, 1);
1581+
add_assoc_long_ex(&filter_params, ZEND_STRS("window"), 0x2f); /* ANY WBITS */
1582+
1583+
zf = php_stream_filter_create("zlib.inflate", &filter_params, 0 TSRMLS_CC);
1584+
zval_dtor(&filter_params);
1585+
1586+
if (zf) {
1587+
php_stream_filter_append(&SG(request_info).request_body->readfilters, zf);
1588+
} else {
1589+
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't uncompress compressed request");
1590+
return;
1591+
}
15911592
} else {
15921593
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Request is compressed with unknown compression '%s'",Z_STRVAL_PP(encoding));
15931594
return;
15941595
}
1595-
if (call_user_function(CG(function_table), (zval**)NULL, &func, &retval, 1, params TSRMLS_CC) == SUCCESS &&
1596-
Z_TYPE(retval) == IS_STRING) {
1597-
doc_request = soap_xmlParseMemory(Z_STRVAL(retval),Z_STRLEN(retval));
1598-
zval_dtor(&retval);
1599-
} else {
1600-
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't uncompress compressed request");
1601-
return;
1602-
}
1603-
} else {
1604-
doc_request = soap_xmlParseMemory(post_data, post_data_length);
1596+
}
1597+
1598+
doc_request = soap_xmlParseFile("php://input" TSRMLS_CC);
1599+
1600+
if (zf) {
1601+
php_stream_filter_remove(zf, 1 TSRMLS_CC);
16051602
}
16061603
} else {
16071604
zval_ptr_dtor(&retval);

ext/spl/internal/emptyiterator.inc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @version 1.0
1616
* @since PHP 5.1
1717
*/
18-
class EmptyIterator implements Iterator
18+
class EmptyIterator implements Iterator, Countable
1919
{
2020
/** No operation.
2121
* @return void
@@ -57,6 +57,15 @@ class EmptyIterator implements Iterator
5757
{
5858
// nothing to do
5959
}
60+
61+
/**
62+
* @return int
63+
*/
64+
function count()
65+
{
66+
return 0;
67+
}
68+
6069
}
6170

62-
?>
71+
?>

ext/spl/spl_iterators.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3241,12 +3241,23 @@ SPL_METHOD(EmptyIterator, next)
32413241
}
32423242
} /* }}} */
32433243

3244+
/* {{{ proto int EmptyIterator::count()
3245+
Does nothing */
3246+
SPL_METHOD(EmptyIterator, count)
3247+
{
3248+
if (zend_parse_parameters_none() == FAILURE) {
3249+
return;
3250+
}
3251+
RETURN_LONG(0);
3252+
} /* }}} */
3253+
32443254
static const zend_function_entry spl_funcs_EmptyIterator[] = {
32453255
SPL_ME(EmptyIterator, rewind, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
32463256
SPL_ME(EmptyIterator, valid, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
32473257
SPL_ME(EmptyIterator, key, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
32483258
SPL_ME(EmptyIterator, current, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
32493259
SPL_ME(EmptyIterator, next, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
3260+
SPL_ME(EmptyIterator, count, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
32503261
PHP_FE_END
32513262
};
32523263

@@ -3707,6 +3718,7 @@ PHP_MINIT_FUNCTION(spl_iterators)
37073718

37083719
REGISTER_SPL_STD_CLASS_EX(EmptyIterator, NULL, spl_funcs_EmptyIterator);
37093720
REGISTER_SPL_ITERATOR(EmptyIterator);
3721+
REGISTER_SPL_IMPLEMENTS(EmptyIterator, Countable);
37103722

37113723
REGISTER_SPL_SUB_CLASS_EX(RecursiveTreeIterator, RecursiveIteratorIterator, spl_RecursiveTreeIterator_new, spl_funcs_RecursiveTreeIterator);
37123724
REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "BYPASS_CURRENT", RTIT_BYPASS_CURRENT);

ext/spl/tests/bug60577.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
count(new EmptyIterator) should return zero
3+
--FILE--
4+
<?php
5+
$it = new EmptyIterator;
6+
var_dump(count($it));
7+
--EXPECT--
8+
int(0)

ext/sqlite3/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ARG_WITH("sqlite3", "SQLite 3 support", "no");
55

66
if (PHP_SQLITE3 != "no") {
7-
ADD_FLAG("CFLAGS_SQLITE3", "/D SQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 ");
7+
ADD_FLAG("CFLAGS_SQLITE3", "/D SQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 /D SQLITE_API=__declspec(dllexport) ");
88
EXTENSION("sqlite3", "sqlite3.c", null, "/I" + configure_module_dirname + "/libsqlite /I" + configure_module_dirname);
99

1010
ADD_SOURCES(configure_module_dirname + "/libsqlite", "sqlite3.c", "sqlite3");

0 commit comments

Comments
 (0)