Skip to content

Commit 40caf95

Browse files
committed
Fix for no args in CLI
1 parent 71da67e commit 40caf95

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

ext/standard/html.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1573,8 +1573,10 @@ PHP_FUNCTION(populate_post_data)
15731573

15741574
if (!content_type && input_stream_zv) {
15751575
zend_throw_error(NULL, "$content_type must be set if $input_stream is passed");
1576+
RETURN_THROWS();
15761577
} else if (content_type && !input_stream_zv) {
15771578
zend_throw_error(NULL, "$content_type must not be set if $input_stream is not passed");
1579+
RETURN_THROWS();
15781580
}
15791581

15801582
php_stream *input_stream = NULL;
@@ -1583,10 +1585,21 @@ PHP_FUNCTION(populate_post_data)
15831585
}
15841586
SG(rfc1867_input_stream) = input_stream;
15851587

1588+
const char *content_type_c;
1589+
if (content_type) {
1590+
content_type_c = ZSTR_VAL(content_type);
1591+
} else {
1592+
content_type_c = SG(request_info).content_type;
1593+
if (!content_type) {
1594+
zend_throw_error(NULL, "Request does not provide a content type");
1595+
RETURN_THROWS();
1596+
}
1597+
}
1598+
15861599
zval post, files;
15871600
array_init(&post);
15881601
array_init(&files);
1589-
sapi_read_post_data_ex(content_type ? ZSTR_VAL(content_type) : SG(request_info).content_type);
1602+
sapi_read_post_data_ex(content_type_c);
15901603
sapi_handle_post_ex(&post, &files);
15911604
RETURN_ARR(zend_new_pair(&post, &files));
15921605
}

0 commit comments

Comments
 (0)