Skip to content

Deprecate most obsolete cURL constants #5094

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 1 commit into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Jan 19, 2020

Over the years, libcurl has obsoleted several constants, and while
these are still defined in latest libcurl versions, they might be
removed anytime, and libcurl built with CURL_NO_OLDIES defined might
not define these constants at all. Therefore we deprecate most of
these obsolete constants, introduce constants which can be used to
replace the deprecated ones (unless these have already been available).
To no longer depend on the obsolete constants, we use the values of
their replacements where possible, and use hard-coded numbers
otherwise.

We exempt CURLOPT_FILE, CURLOPT_INFILE and CURLOPT_WRITEHEADER
for now, since deprecating these would be a more severe BC break,
especially since only CURLOPT_READDATA is already available in
ext/curl, but not CURLOPT_WRITEDATA and CURLOPT_HEADERDATA.

TODO:

Over the years, libcurl has obsoleted several constants, and while
these are still defined in latest libcurl versions, they might be
removed anytime, and libcurl built with `CURL_NO_OLDIES` defined might
not define these constants at all.  Therefore we deprecate most of
these obsolete constants, introduce constants which can be used to
replace the deprecated ones (unless these have already been available).
To no longer depend on the obsolete constants, we use the values of
their replacements where possible, and use hard-coded numbers
otherwise.

We exempt `CURLOPT_FILE`, `CURLOPT_INFILE` and `CURLOPT_WRITEHEADER`
for now, since deprecating these would be a more severe BC break,
especially since only `CURLOPT_READDATA` is already available in
ext/curl, but not `CURLOPT_WRITEDATA` and `CURLOPT_HEADERDATA`.
@@ -511,73 +511,73 @@ PHP_MINIT_FUNCTION(curl)

/* */
REGISTER_CURL_CONSTANT(CURLE_ABORTED_BY_CALLBACK);
REGISTER_CURL_CONSTANT(CURLE_BAD_CALLING_ORDER);
REGISTER_LONG_CONSTANT("CURLE_BAD_CALLING_ORDER", 44, CONST_PERSISTENT | CONST_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do these hardcoded values come from?

Assuming that these can never actually be returned by curl (anymore), it might make sense to map them to something that is definitely not going to be used, such as -1 or a large number. These specific constants look fragile.

@ekinhbayar
Copy link
Contributor

Just bumped into this PR, here are some other constants that can be found in master and have since been deprecated prior to the current minimum curl version of master (7.29.0). I've noted down the replacements I saw in curl docs, I couldn't find anything (not even a docs page) about the ones that do not have a replacement noted.

CURLOPT_DNS_USE_GLOBAL_CACHE     (deprecated since 7.11.1)   (from curl docs: Warning: this option is considered obsolete. Stop using it.
CURLOPT_FTPAPPEND      (deprecated since 7.16.4) - now it's CURLOPT_APPEND    https://curl.haxx.se/libcurl/c/CURLOPT_APPEND.html
CURLOPT_FTPLISTONLY    (deprecated since 7.16.4) - now it's CURLOPT_DIRLISTONLY    https://curl.haxx.se/libcurl/c/CURLOPT_DIRLISTONLY.html
CURLOPT_SSLCERTPASSWD  (deprecated since 7.9.2)  - now it's CURLOPT_KEYPASSWD    https://curl.haxx.se/libcurl/c/CURLOPT_KEYPASSWD.html
CURLOPT_SSLKEYPASSWD   (deprecated since 7.17.0) - now it's CURLOPT_KEYPASSWD    https://curl.haxx.se/libcurl/c/CURLOPT_KEYPASSWD.html
CURLOPT_FTP_SSL        (deprecated since 7.16.4) - now it's CURLOPT_USE_SSL   https://curl.haxx.se/libcurl/c/CURLOPT_USE_SSL.html
CURLOPT_KRB4LEVEL      (deprecated since 7.17.0) - now it's CURLOPT_KRBLEVEL  https://curl.haxx.se/libcurl/c/CURLOPT_KRBLEVEL.html
CURLFTPSSL_ALL         (deprecated since 7.17.0)
CURLFTPSSL_CONTROL     (deprecated since 7.17.0)
CURLFTPSSL_NONE        (deprecated since 7.17.0)
CURLFTPSSL_TRY         (deprecated since 7.17.0)

All these replacements seem to be defined in the source, though some are most likely missing from the documentation.

Leaving them noted here just in case it might come handy in your effort.

@cmb69
Copy link
Member Author

cmb69 commented Mar 30, 2021

Closing for time reasons for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants