Skip to content
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
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ PHP NEWS
. Fixed bug #76980 (Interface gets skipped if autoloader throws an exception).
(Nikita)

- cURL:
. Add missing CURLE_* constants. (Javier Spagnoletti)

- DOM:
. Fixed bug #78025 (segfault when accessing properties of DOMDocumentType).
(cmb)
Expand Down
41 changes: 41 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,47 @@ JSON:
Curl:
. CURLAUTH_BEARER
. CURLAUTH_GSSAPI
. CURLE_AGAIN
. CURLE_CHUNK_FAILED
. CURLE_CONV_FAILED
. CURLE_CONV_REQD
. CURLE_FTP_ACCEPT_FAILED
. CURLE_FTP_ACCEPT_TIMEOUT
. CURLE_FTP_BAD_FILE_LIST
. CURLE_FTP_COULDNT_SET_TYPE
. CURLE_FTP_PRET_FAILED
. CURLE_HTTP2
. CURLE_HTTP2_STREAM
. CURLE_INTERFACE_FAILED
. CURLE_LOGIN_DENIED
. CURLE_NOT_BUILT_IN
. CURLE_NO_CONNECTION_AVAILABLE
. CURLE_PEER_FAILED_VERIFICATION
. CURLE_QUOTE_ERROR
. CURLE_RANGE_ERROR
. CURLE_RECURSIVE_API_CALL
. CURLE_REMOTE_ACCESS_DENIED
. CURLE_REMOTE_DISK_FULL
. CURLE_REMOTE_FILE_EXISTS
. CURLE_REMOTE_FILE_NOT_FOUND
. CURLE_RTSP_CSEQ_ERROR
. CURLE_RTSP_SESSION_ERROR
. CURLE_SEND_FAIL_REWIND
. CURLE_SSL_CRL_BADFILE
. CURLE_SSL_ENGINE_INITFAILED
. CURLE_SSL_INVALIDCERTSTATUS
. CURLE_SSL_ISSUER_ERROR
. CURLE_SSL_SHUTDOWN_FAILED
. CURLE_TFTP_DISKFULL
. CURLE_TFTP_EXISTS
. CURLE_TFTP_ILLEGAL
. CURLE_TFTP_NOSUCHUSER
. CURLE_TFTP_NOTFOUND
. CURLE_TFTP_PERM
. CURLE_TFTP_UNKNOWNID
. CURLE_UNKNOWN_OPTION
. CURLE_UPLOAD_FAILED
. CURLE_USE_SSL_FAILED
. CURLE_WEIRD_SERVER_REPLY
. CURLINFO_APPCONNECT_TIME_T
. CURLINFO_CONNECT_TIME_T
Expand Down
93 changes: 90 additions & 3 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ PHP_MINIT_FUNCTION(curl)
REGISTER_CURL_CONSTANT(CURLE_ABORTED_BY_CALLBACK);
REGISTER_CURL_CONSTANT(CURLE_BAD_CALLING_ORDER);
REGISTER_CURL_CONSTANT(CURLE_BAD_CONTENT_ENCODING);
REGISTER_CURL_CONSTANT(CURLE_CONV_FAILED);
REGISTER_CURL_CONSTANT(CURLE_CONV_REQD);
Copy link
Member

Choose a reason for hiding this comment

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

Hm, some of these constants (such as these two) are not relevant for end users, because the character conversion functionality is not exported by PHP (and won't be). I'm wondering whether or not we should still define them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know about the use case for these constants, but IMO we should blacklist them given your explanation.
If the extension isn't really capable to get this kind of errors, the only use case I can imagine is to compare error codes returned by userland code, maybe a library using the system's cURL library directly via passthru() or similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the decision is to not include these constants, they must be added to IGNORED_CONSTANTS:

const IGNORED_CONSTANTS = [
'CURLOPT_PROGRESSDATA'
];

Copy link
Contributor

Choose a reason for hiding this comment

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

I also think they shouldn't be exposed.

REGISTER_CURL_CONSTANT(CURLE_BAD_DOWNLOAD_RESUME);
REGISTER_CURL_CONSTANT(CURLE_BAD_FUNCTION_ARGUMENT);
REGISTER_CURL_CONSTANT(CURLE_BAD_PASSWORD_ENTERED);
Expand Down Expand Up @@ -785,9 +787,11 @@ PHP_MINIT_FUNCTION(curl)
REGISTER_CURL_CONSTANT(CURLE_HTTP_POST_ERROR);
REGISTER_CURL_CONSTANT(CURLE_HTTP_RANGE_ERROR);
REGISTER_CURL_CONSTANT(CURLE_HTTP_RETURNED_ERROR);
REGISTER_CURL_CONSTANT(CURLE_INTERFACE_FAILED);
REGISTER_CURL_CONSTANT(CURLE_LDAP_CANNOT_BIND);
REGISTER_CURL_CONSTANT(CURLE_LDAP_SEARCH_FAILED);
REGISTER_CURL_CONSTANT(CURLE_LIBRARY_NOT_FOUND);
REGISTER_CURL_CONSTANT(CURLE_LOGIN_DENIED);
REGISTER_CURL_CONSTANT(CURLE_MALFORMAT_USER);
REGISTER_CURL_CONSTANT(CURLE_OBSOLETE);
REGISTER_CURL_CONSTANT(CURLE_OK);
Expand All @@ -798,25 +802,108 @@ PHP_MINIT_FUNCTION(curl)
REGISTER_CURL_CONSTANT(CURLE_READ_ERROR);
REGISTER_CURL_CONSTANT(CURLE_RECV_ERROR);
REGISTER_CURL_CONSTANT(CURLE_SEND_ERROR);
REGISTER_CURL_CONSTANT(CURLE_SEND_FAIL_REWIND);
REGISTER_CURL_CONSTANT(CURLE_SHARE_IN_USE);
REGISTER_CURL_CONSTANT(CURLE_SSL_CACERT);
REGISTER_CURL_CONSTANT(CURLE_SSL_CERTPROBLEM);
REGISTER_CURL_CONSTANT(CURLE_SSL_CIPHER);
REGISTER_CURL_CONSTANT(CURLE_SSL_CONNECT_ERROR);
REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_INITFAILED);
REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_NOTFOUND);
REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_SETFAILED);
REGISTER_CURL_CONSTANT(CURLE_SSL_PEER_CERTIFICATE);
#if LIBCURL_VERSION_NUM >= 0x072700 /* Available since 7.39.0 */
REGISTER_CURL_CONSTANT(CURLE_SSL_PINNEDPUBKEYNOTMATCH);
#endif
REGISTER_CURL_CONSTANT(CURLE_TELNET_OPTION_SYNTAX);
REGISTER_CURL_CONSTANT(CURLE_TFTP_DISKFULL);
REGISTER_CURL_CONSTANT(CURLE_TFTP_EXISTS);
REGISTER_CURL_CONSTANT(CURLE_TFTP_ILLEGAL);
REGISTER_CURL_CONSTANT(CURLE_TFTP_NOSUCHUSER);
REGISTER_CURL_CONSTANT(CURLE_TFTP_NOTFOUND);
REGISTER_CURL_CONSTANT(CURLE_TFTP_PERM);
REGISTER_CURL_CONSTANT(CURLE_TFTP_UNKNOWNID);
REGISTER_CURL_CONSTANT(CURLE_TOO_MANY_REDIRECTS);
REGISTER_CURL_CONSTANT(CURLE_UNKNOWN_TELNET_OPTION);
REGISTER_CURL_CONSTANT(CURLE_UNSUPPORTED_PROTOCOL);
REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT);
REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT_USER);
REGISTER_CURL_CONSTANT(CURLE_WRITE_ERROR);

#if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 */
REGISTER_CURL_CONSTANT(CURLE_REMOTE_FILE_NOT_FOUND);
REGISTER_CURL_CONSTANT(CURLE_SSL_SHUTDOWN_FAILED);
#endif

#if LIBCURL_VERSION_NUM >= 0x071003 /* Available since 7.16.3 */
REGISTER_CURL_CONSTANT(CURLE_UPLOAD_FAILED);
#endif

#if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_TYPE);
REGISTER_CURL_CONSTANT(CURLE_QUOTE_ERROR);
REGISTER_CURL_CONSTANT(CURLE_RANGE_ERROR);
REGISTER_CURL_CONSTANT(CURLE_REMOTE_ACCESS_DENIED);
REGISTER_CURL_CONSTANT(CURLE_REMOTE_DISK_FULL);
REGISTER_CURL_CONSTANT(CURLE_REMOTE_FILE_EXISTS);
REGISTER_CURL_CONSTANT(CURLE_USE_SSL_FAILED);
#endif

#if LIBCURL_VERSION_NUM >= 0x071101 /* Available since 7.17.1 */
REGISTER_CURL_CONSTANT(CURLE_PEER_FAILED_VERIFICATION);
#endif

#if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */
REGISTER_CURL_CONSTANT(CURLE_AGAIN);
#endif

#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
REGISTER_CURL_CONSTANT(CURLE_SSL_CRL_BADFILE);
REGISTER_CURL_CONSTANT(CURLE_SSL_ISSUER_ERROR);
#endif

#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
REGISTER_CURL_CONSTANT(CURLE_FTP_PRET_FAILED);
REGISTER_CURL_CONSTANT(CURLE_RTSP_CSEQ_ERROR);
REGISTER_CURL_CONSTANT(CURLE_RTSP_SESSION_ERROR);
#endif

#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
REGISTER_CURL_CONSTANT(CURLE_CHUNK_FAILED);
REGISTER_CURL_CONSTANT(CURLE_FTP_BAD_FILE_LIST);
#endif

#if LIBCURL_VERSION_NUM >= 0x071505 /* Available since 7.21.5 */
REGISTER_CURL_CONSTANT(CURLE_NOT_BUILT_IN);
REGISTER_CURL_CONSTANT(CURLE_UNKNOWN_OPTION);
#endif

#if LIBCURL_VERSION_NUM >= 0x071800 /* Available since 7.24.0 */
REGISTER_CURL_CONSTANT(CURLE_FTP_ACCEPT_FAILED);
REGISTER_CURL_CONSTANT(CURLE_FTP_ACCEPT_TIMEOUT);
#endif

#if LIBCURL_VERSION_NUM >= 0x071e00 /* Available since 7.30.0 */
REGISTER_CURL_CONSTANT(CURLE_NO_CONNECTION_AVAILABLE);
#endif

#if LIBCURL_VERSION_NUM >= 0x072600 /* Available since 7.38.0 */
REGISTER_CURL_CONSTANT(CURLE_HTTP2);
#endif

#if LIBCURL_VERSION_NUM >= 0x072700 /* Available since 7.39.0 */
REGISTER_CURL_CONSTANT(CURLE_SSL_PINNEDPUBKEYNOTMATCH);
#endif

#if LIBCURL_VERSION_NUM >= 0x072900 /* Available since 7.41.0 */
REGISTER_CURL_CONSTANT(CURLE_SSL_INVALIDCERTSTATUS);
#endif

#if LIBCURL_VERSION_NUM >= 0x073100 /* Available since 7.49.0 */
REGISTER_CURL_CONSTANT(CURLE_HTTP2_STREAM);
#endif

#if LIBCURL_VERSION_NUM >= 0x073b00 /* Available since 7.59.0 */
REGISTER_CURL_CONSTANT(CURLE_RECURSIVE_API_CALL);
#endif

/* cURL info constants */
REGISTER_CURL_CONSTANT(CURLINFO_CONNECT_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_DOWNLOAD);
Expand Down
2 changes: 1 addition & 1 deletion ext/curl/sync-constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'CURLOPT_PROGRESSDATA'
];

const CONSTANTS_REGEX_PATTERN = '~^CURL(?:OPT|_VERSION)_[A-Z0-9_]+$~';
const CONSTANTS_REGEX_PATTERN = '~^CURL(?:E|OPT|_VERSION)_[A-Z0-9_]+$~';

$curlConstants = getCurlConstants();
$sourceConstants = getSourceConstants();
Expand Down
2 changes: 2 additions & 0 deletions ext/curl/tests/curl_strerror_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ if ($curl_version['version_number'] < 0x070c00) {

var_dump(strtolower(curl_strerror(CURLE_OK)));
var_dump(strtolower(curl_strerror(CURLE_UNSUPPORTED_PROTOCOL)));
var_dump(strtolower(curl_strerror(CURLE_SEND_FAIL_REWIND)));
var_dump(strtolower(curl_strerror(-1)));

?>
--EXPECT--
string(8) "no error"
string(20) "unsupported protocol"
string(53) "send failed since rewinding of the data stream failed"
string(13) "unknown error"
21 changes: 21 additions & 0 deletions ext/curl/tests/curl_strerror_002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
curl_strerror test constants not defined with < 7.16.1
--SKIPIF--
<?php
if (!extension_loaded('curl')) {
exit('skip curl extension not loaded');
}
$curl_version = curl_version();
if ($curl_version['version_number'] >= 0x071001) {
exit('skip: test works only with curl < 7.16.1');
}
?>
--FILE--
<?php

var_dump(strtolower(curl_strerror(CURLE_REMOTE_FILE_NOT_FOUND)));

?>
--EXPECTF--
Warning: Use of undefined constant CURLE_SEND_FAIL_REWIND - assumed 'CURLE_SEND_FAIL_REWIND' (this will throw an Error in a future version of PHP) in %s on line %d
Warning: curl_strerror() expects parameter 1 to be integer, string given in %s on line %d
22 changes: 22 additions & 0 deletions ext/curl/tests/curl_strerror_003.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
curl_strerror test constants from >= 7.16.1
--SKIPIF--
<?php
if (!extension_loaded('curl')) {
exit('skip curl extension not loaded');
}
$curl_version = curl_version();
if ($curl_version['version_number'] < 0x071001) {
exit('skip: test works only with curl >= 7.16.1');
}
?>
--FILE--
<?php

var_dump(strtolower(curl_strerror(CURLE_REMOTE_FILE_NOT_FOUND)));
var_dump(strtolower(curl_strerror(CURLE_SSL_SHUTDOWN_FAILED)));

?>
--EXPECT--
string(21) "remote file not found"
string(38) "failed to shut down the ssl connection"