Skip to content

Fix UNKNOWN default values in ext/curl and remove the deprecated param of curl_version() #5734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ PHP 8.0 UPGRADE NOTES
checks for `false`. The curl_share_close() function no longer has an effect,
instead the CurlShareHandle instance is automatically destroyed if it is no
longer referenced.
. The deprecated parameter `$version` of curl_version() has been removed.

- Enchant:
. The enchant extension now uses libenchant-2 by default when available.
Expand Down
8 changes: 4 additions & 4 deletions ext/curl/curl.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ function curl_multi_setopt(CurlMultiHandle $multi_handle, int $option, mixed $va

function curl_exec(CurlHandle $handle): string|bool {}

function curl_file_create(string $filename, string $mimetype = UNKNOWN, string $postname = UNKNOWN): CURLFile {}
function curl_file_create(string $filename, ?string $mimetype = null, ?string $postname = null): CURLFile {}

function curl_getinfo(CurlHandle $handle, int $option = UNKNOWN): mixed {}
function curl_getinfo(CurlHandle $handle, ?int $option = null): mixed {}

function curl_init(string $url = UNKNOWN): CurlHandle|false {}
function curl_init(?string $url = null): CurlHandle|false {}

function curl_multi_add_handle(CurlMultiHandle $multi_handle, CurlHandle $handle): int {}

Expand Down Expand Up @@ -83,4 +83,4 @@ function curl_share_strerror(int $error_number): ?string {}

function curl_strerror(int $error_number): ?string {}

function curl_version(int $age = UNKNOWN): array|false {}
function curl_version(): array|false {}
9 changes: 4 additions & 5 deletions ext/curl/curl_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_curl_file_create, 0, 1, CURLFile, 0)
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, mimetype, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, postname, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mimetype, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, postname, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_curl_getinfo, 0, 1, IS_MIXED, 0)
ZEND_ARG_OBJ_INFO(0, handle, CurlHandle, 0)
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, option, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_curl_init, 0, 0, CurlHandle, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, url, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, url, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_curl_multi_add_handle, 0, 2, IS_LONG, 0)
Expand Down Expand Up @@ -137,7 +137,6 @@ ZEND_END_ARG_INFO()
#define arginfo_curl_strerror arginfo_curl_multi_strerror

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_curl_version, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, age, IS_LONG, 0)
ZEND_END_ARG_INFO()


Expand Down
4 changes: 2 additions & 2 deletions ext/curl/curl_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ static void curlfile_ctor(INTERNAL_FUNCTION_PARAMETERS)
ZEND_PARSE_PARAMETERS_START(1,3)
Z_PARAM_PATH_STR(fname)
Z_PARAM_OPTIONAL
Z_PARAM_STR(mime)
Z_PARAM_STR(postname)
Z_PARAM_STR_OR_NULL(mime)
Z_PARAM_STR_OR_NULL(postname)
ZEND_PARSE_PARAMETERS_END();

zend_update_property_string(curl_CURLFile_class, cf, "name", sizeof("name")-1, ZSTR_VAL(fname));
Expand Down
6 changes: 1 addition & 5 deletions ext/curl/curl_file.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

class CURLFile
{
public function __construct(
string $filename,
string $mimetype = UNKNOWN,
string $postname = UNKNOWN
) {}
public function __construct(string $filename, ?string $mimetype = null, ?string $postname = null) {}

/** @return string */
public function getFilename() {}
Expand Down
4 changes: 2 additions & 2 deletions ext/curl/curl_file_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_CURLFile___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, mimetype, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, postname, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mimetype, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, postname, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_CURLFile_getFilename, 0, 0, 0)
Expand Down
23 changes: 7 additions & 16 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1689,23 +1689,13 @@ static void curl_free_slist(zval *el)
}
/* }}} */

/* {{{ proto array curl_version([int version])
/* {{{ proto array curl_version()
Return cURL version information. */
PHP_FUNCTION(curl_version)
{
curl_version_info_data *d;
zend_long uversion = -1;

ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(uversion)
ZEND_PARSE_PARAMETERS_END();

if (uversion == CURLVERSION_NOW) {
php_error_docref(NULL, E_DEPRECATED, "The $version parameter is deprecated");
} else if (ZEND_NUM_ARGS() > 0) {
php_error_docref(NULL, E_WARNING, "$version argument ignored");
}
ZEND_PARSE_PARAMETERS_NONE();

d = curl_version_info(CURLVERSION_NOW);
if (d == NULL) {
Expand Down Expand Up @@ -1871,7 +1861,7 @@ PHP_FUNCTION(curl_init)

ZEND_PARSE_PARAMETERS_START(0,1)
Z_PARAM_OPTIONAL
Z_PARAM_STR(url)
Z_PARAM_STR_OR_NULL(url)
ZEND_PARSE_PARAMETERS_END();

cp = curl_easy_init();
Expand Down Expand Up @@ -3018,17 +3008,18 @@ PHP_FUNCTION(curl_getinfo)
{
zval *zid;
php_curl *ch;
zend_long option = 0;
zend_long option;
zend_bool option_is_null = 1;

ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_OBJECT_OF_CLASS(zid, curl_ce)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(option)
Z_PARAM_LONG_OR_NULL(option, option_is_null)
ZEND_PARSE_PARAMETERS_END();

ch = Z_CURL_P(zid);

if (ZEND_NUM_ARGS() < 2) {
if (option_is_null) {
char *s_code;
/* libcurl expects long datatype. So far no cases are known where
it would be an issue. Using zend_long would truncate a 64-bit
Expand Down
15 changes: 0 additions & 15 deletions ext/curl/tests/curl_version_error_001.phpt

This file was deleted.