diff options
Diffstat (limited to 'ext/curl')
56 files changed, 526 insertions, 388 deletions
diff --git a/ext/curl/config.m4 b/ext/curl/config.m4 index 8e688c1a11..7d36458aef 100644 --- a/ext/curl/config.m4 +++ b/ext/curl/config.m4 @@ -1,6 +1,4 @@ -dnl -dnl $Id$ -dnl +dnl config.m4 for extension curl PHP_ARG_WITH(curl, for cURL support, [ --with-curl[=DIR] Include cURL support]) @@ -30,12 +28,12 @@ if test "$PHP_CURL" != "no"; then fi if test -n "$PKNAME"; then - AC_MSG_CHECKING(for cURL 7.10.5 or greater) - if $PKG_CONFIG --atleast-version 7.10.5 $PKNAME; then + AC_MSG_CHECKING(for cURL 7.15.5 or greater) + if $PKG_CONFIG --atleast-version 7.15.5 $PKNAME; then curl_version_full=`$PKG_CONFIG --modversion $PKNAME` AC_MSG_RESULT($curl_version_full) else - AC_MSG_ERROR(cURL version 7.10.5 or later is required to compile php with cURL support) + AC_MSG_ERROR(cURL version 7.15.5 or later is required to compile php with cURL support) fi CURL_LIBS=`$PKG_CONFIG --libs $PKNAME` @@ -65,7 +63,7 @@ if test "$PHP_CURL" != "no"; then fi CURL_CONFIG="curl-config" - AC_MSG_CHECKING(for cURL 7.10.5 or greater) + AC_MSG_CHECKING(for cURL 7.15.5 or greater) if ${CURL_DIR}/bin/curl-config --libs > /dev/null 2>&1; then CURL_CONFIG=${CURL_DIR}/bin/curl-config @@ -77,13 +75,13 @@ if test "$PHP_CURL" != "no"; then curl_version_full=`$CURL_CONFIG --version` curl_version=`echo ${curl_version_full} | sed -e 's/libcurl //' | $AWK 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'` - if test "$curl_version" -ge 7010005; then + if test "$curl_version" -ge 7015005; then AC_MSG_RESULT($curl_version_full) CURL_LIBS=`$CURL_CONFIG --libs` CURL_INCL=`$CURL_CONFIG --cflags` CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL` else - AC_MSG_ERROR(cURL version 7.10.5 or later is required to compile php with cURL support) + AC_MSG_ERROR(cURL version 7.15.5 or later is required to compile php with cURL support) fi fi @@ -91,20 +89,20 @@ if test "$PHP_CURL" != "no"; then PHP_EVAL_LIBLINE($CURL_LIBS, CURL_SHARED_LIBADD) PHP_EVAL_INCLINE($CURL_INCL, CURL_SHARED_LIBADD) - + AC_MSG_CHECKING([for SSL support in libcurl]) if test -n "$CURL_SSL"; then AC_MSG_RESULT([yes]) AC_DEFINE([HAVE_CURL_SSL], [1], [Have cURL with SSL support]) - + save_CFLAGS="$CFLAGS" CFLAGS=$CURL_INCL save_LDFLAGS="$LDFLAGS" LDFLAGS=$CURL_LIBS - + AC_PROG_CPP AC_MSG_CHECKING([for openssl support in libcurl]) - AC_TRY_RUN([ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <strings.h> #include <curl/curl.h> @@ -120,7 +118,7 @@ int main(int argc, char *argv[]) } return 1; } - ],[ + ]])],[ AC_MSG_RESULT([yes]) AC_CHECK_HEADERS([openssl/crypto.h], [ AC_DEFINE([HAVE_CURL_OPENSSL], [1], [Have cURL with OpenSSL support]) @@ -130,16 +128,16 @@ int main(int argc, char *argv[]) ], [ AC_MSG_RESULT([no]) ]) - + AC_MSG_CHECKING([for gnutls support in libcurl]) - AC_TRY_RUN([ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <strings.h> #include <curl/curl.h> int main(int argc, char *argv[]) { curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); - + if (data && data->ssl_version && *data->ssl_version) { const char *ptr = data->ssl_version; @@ -148,7 +146,7 @@ int main(int argc, char *argv[]) } return 1; } -], [ +]])], [ AC_MSG_RESULT([yes]) AC_CHECK_HEADER([gcrypt.h], [ AC_DEFINE([HAVE_CURL_GNUTLS], [1], [Have cURL with GnuTLS support]) @@ -158,15 +156,15 @@ int main(int argc, char *argv[]) ], [ AC_MSG_RESULT([no]) ]) - + CFLAGS="$save_CFLAGS" LDFLAGS="$save_LDFLAGS" else AC_MSG_RESULT([no]) fi - PHP_CHECK_LIBRARY(curl,curl_easy_perform, - [ + PHP_CHECK_LIBRARY(curl,curl_easy_perform, + [ AC_DEFINE(HAVE_CURL,1,[ ]) ],[ AC_MSG_ERROR(There is something wrong. Please check config.log for more information.) diff --git a/ext/curl/config.w32 b/ext/curl/config.w32 index 112e5ea8f4..b2376a4623 100644 --- a/ext/curl/config.w32 +++ b/ext/curl/config.w32 @@ -1,4 +1,3 @@ -// $Id$ // vim:ft=javascript ARG_WITH("curl", "cURL support", "no"); diff --git a/ext/curl/curl_file.c b/ext/curl/curl_file.c index d30db86c54..f6657a17a8 100644 --- a/ext/curl/curl_file.c +++ b/ext/curl/curl_file.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -52,7 +50,7 @@ static void curlfile_ctor(INTERNAL_FUNCTION_PARAMETERS) } } -/* {{{ proto void CURLFile::__construct(string $name, [string $mimetype [, string $postfilename]]) +/* {{{ proto CURLFile::__construct(string $name, [string $mimetype [, string $postfilename]]) Create the CURLFile object */ ZEND_METHOD(CURLFile, __construct) { @@ -78,8 +76,7 @@ static void curlfile_get_property(char *name, size_t name_len, INTERNAL_FUNCTION return; } res = zend_read_property(curl_CURLFile_class, getThis(), name, name_len, 1, &rv); - ZVAL_DEREF(res); - ZVAL_COPY(return_value, res); + ZVAL_COPY_DEREF(return_value, res); } static void curlfile_set_property(char *name, size_t name_len, INTERNAL_FUNCTION_PARAMETERS) @@ -133,7 +130,7 @@ ZEND_METHOD(CURLFile, setPostFilename) } /* }}} */ -/* {{{ proto void CURLFile::__wakeup() +/* {{{ proto CURLFile::__wakeup() Unserialization handler */ ZEND_METHOD(CURLFile, __wakeup) { diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 3af7ec12e2..075491105a 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #ifdef HAVE_CONFIG_H @@ -210,7 +208,7 @@ static int php_curl_option_url(php_curl *ch, const char *url, const size_t len) return FAILURE; } - if (uri->scheme && !strncasecmp("file", uri->scheme, sizeof("file"))) { + if (uri->scheme && zend_string_equals_literal_ci(uri->scheme, "file")) { php_error_docref(NULL, E_WARNING, "Protocol 'file' disabled in cURL"); php_url_free(uri); return FAILURE; @@ -343,13 +341,10 @@ ZEND_BEGIN_ARG_INFO(arginfo_curl_close, 0) ZEND_ARG_INFO(0, ch) ZEND_END_ARG_INFO() -#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */ ZEND_BEGIN_ARG_INFO(arginfo_curl_reset, 0) ZEND_ARG_INFO(0, ch) ZEND_END_ARG_INFO() -#endif -#if LIBCURL_VERSION_NUM > 0x070f03 /* 7.15.4 */ ZEND_BEGIN_ARG_INFO(arginfo_curl_escape, 0) ZEND_ARG_INFO(0, ch) ZEND_ARG_INFO(0, str) @@ -365,7 +360,6 @@ ZEND_BEGIN_ARG_INFO(arginfo_curl_multi_setopt, 0) ZEND_ARG_INFO(0, option) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -#endif ZEND_BEGIN_ARG_INFO(arginfo_curl_multi_init, 0) ZEND_END_ARG_INFO() @@ -407,7 +401,6 @@ ZEND_BEGIN_ARG_INFO(arginfo_curl_multi_errno, 0) ZEND_ARG_INFO(0, mh) ZEND_END_ARG_INFO() -#if LIBCURL_VERSION_NUM >= 0x070c00 /* Available since 7.12.0 */ ZEND_BEGIN_ARG_INFO(arginfo_curl_strerror, 0) ZEND_ARG_INFO(0, errornum) ZEND_END_ARG_INFO() @@ -419,7 +412,6 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_curl_share_strerror, 0) ZEND_ARG_INFO(0, errornum) ZEND_END_ARG_INFO() -#endif ZEND_BEGIN_ARG_INFO(arginfo_curl_share_init, 0) ZEND_END_ARG_INFO() @@ -454,7 +446,7 @@ ZEND_END_ARG_INFO() /* {{{ curl_functions[] */ -const zend_function_entry curl_functions[] = { +static const zend_function_entry curl_functions[] = { PHP_FE(curl_init, arginfo_curl_init) PHP_FE(curl_copy_handle, arginfo_curl_copy_handle) PHP_FE(curl_version, arginfo_curl_version) @@ -465,18 +457,12 @@ const zend_function_entry curl_functions[] = { PHP_FE(curl_error, arginfo_curl_error) PHP_FE(curl_errno, arginfo_curl_errno) PHP_FE(curl_close, arginfo_curl_close) -#if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */ PHP_FE(curl_strerror, arginfo_curl_strerror) PHP_FE(curl_multi_strerror, arginfo_curl_multi_strerror) PHP_FE(curl_share_strerror, arginfo_curl_share_strerror) -#endif -#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */ PHP_FE(curl_reset, arginfo_curl_reset) -#endif -#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */ PHP_FE(curl_escape, arginfo_curl_escape) PHP_FE(curl_unescape, arginfo_curl_unescape) -#endif #if LIBCURL_VERSION_NUM >= 0x071200 /* 7.18.0 */ PHP_FE(curl_pause, arginfo_curl_pause) #endif @@ -489,9 +475,7 @@ const zend_function_entry curl_functions[] = { PHP_FE(curl_multi_info_read, arginfo_curl_multi_info_read) PHP_FE(curl_multi_close, arginfo_curl_multi_close) PHP_FE(curl_multi_errno, arginfo_curl_multi_errno) -#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */ PHP_FE(curl_multi_setopt, arginfo_curl_multi_setopt) -#endif PHP_FE(curl_share_init, arginfo_curl_share_init) PHP_FE(curl_share_close, arginfo_curl_share_close) PHP_FE(curl_share_setopt, arginfo_curl_share_setopt) @@ -553,38 +537,22 @@ PHP_MINFO_FUNCTION(curl) unsigned int i; static const struct feat feats[] = { -#if LIBCURL_VERSION_NUM >= 0x070a07 /* 7.10.7 */ {"AsynchDNS", CURL_VERSION_ASYNCHDNS}, -#endif -#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */ {"CharConv", CURL_VERSION_CONV}, -#endif -#if LIBCURL_VERSION_NUM >= 0x070a06 /* 7.10.6 */ {"Debug", CURL_VERSION_DEBUG}, {"GSS-Negotiate", CURL_VERSION_GSSNEGOTIATE}, -#endif -#if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */ {"IDN", CURL_VERSION_IDN}, -#endif {"IPv6", CURL_VERSION_IPV6}, {"krb4", CURL_VERSION_KERBEROS4}, -#if LIBCURL_VERSION_NUM >= 0x070b01 /* 7.11.1 */ {"Largefile", CURL_VERSION_LARGEFILE}, -#endif {"libz", CURL_VERSION_LIBZ}, -#if LIBCURL_VERSION_NUM >= 0x070a06 /* 7.10.6 */ {"NTLM", CURL_VERSION_NTLM}, -#endif #if LIBCURL_VERSION_NUM >= 0x071600 /* 7.22.0 */ {"NTLMWB", CURL_VERSION_NTLM_WB}, #endif -#if LIBCURL_VERSION_NUM >= 0x070a08 /* 7.10.8 */ {"SPNEGO", CURL_VERSION_SPNEGO}, -#endif {"SSL", CURL_VERSION_SSL}, -#if LIBCURL_VERSION_NUM >= 0x070d02 /* 7.13.2 */ {"SSPI", CURL_VERSION_SSPI}, -#endif #if LIBCURL_VERSION_NUM >= 0x071504 /* 7.21.4 */ {"TLS-SRP", CURL_VERSION_TLSAUTH_SRP}, #endif @@ -653,6 +621,8 @@ PHP_MINFO_FUNCTION(curl) } #endif php_info_print_table_end(); + + DISPLAY_INI_ENTRIES(); } /* }}} */ @@ -921,7 +891,7 @@ PHP_MINIT_FUNCTION(curl) REGISTER_CURL_CONSTANT(CURL_VERSION_LIBZ); REGISTER_CURL_CONSTANT(CURL_VERSION_SSL); -#if LIBCURL_VERSION_NUM >= 0x070a06 /* Available since 7.10.6 */ + /* Available since 7.10.6 */ REGISTER_CURL_CONSTANT(CURLOPT_HTTPAUTH); /* http authentication options */ REGISTER_CURL_CONSTANT(CURLAUTH_ANY); @@ -931,15 +901,13 @@ PHP_MINIT_FUNCTION(curl) REGISTER_CURL_CONSTANT(CURLAUTH_GSSNEGOTIATE); REGISTER_CURL_CONSTANT(CURLAUTH_NONE); REGISTER_CURL_CONSTANT(CURLAUTH_NTLM); -#endif -#if LIBCURL_VERSION_NUM >= 0x070a07 /* Available since 7.10.7 */ + /* Available since 7.10.7 */ REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CONNECTCODE); REGISTER_CURL_CONSTANT(CURLOPT_FTP_CREATE_MISSING_DIRS); REGISTER_CURL_CONSTANT(CURLOPT_PROXYAUTH); -#endif -#if LIBCURL_VERSION_NUM >= 0x070a08 /* Available since 7.10.8 */ + /* Available since 7.10.8 */ REGISTER_CURL_CONSTANT(CURLE_FILESIZE_EXCEEDED); REGISTER_CURL_CONSTANT(CURLE_LDAP_INVALID_URL); REGISTER_CURL_CONSTANT(CURLINFO_HTTPAUTH_AVAIL); @@ -951,9 +919,8 @@ PHP_MINIT_FUNCTION(curl) REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V4); REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V6); REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_WHATEVER); -#endif -#if LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */ + /* Available since 7.11.0 */ REGISTER_CURL_CONSTANT(CURLE_FTP_SSL_FAILED); REGISTER_CURL_CONSTANT(CURLFTPSSL_ALL); REGISTER_CURL_CONSTANT(CURLFTPSSL_CONTROL); @@ -961,67 +928,54 @@ PHP_MINIT_FUNCTION(curl) REGISTER_CURL_CONSTANT(CURLFTPSSL_TRY); REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL); REGISTER_CURL_CONSTANT(CURLOPT_NETRC_FILE); -#endif -#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */ + /* Available since 7.11.2 */ + REGISTER_CURL_CONSTANT(CURLOPT_TCP_NODELAY); + + /* Available since 7.12.2 */ REGISTER_CURL_CONSTANT(CURLFTPAUTH_DEFAULT); REGISTER_CURL_CONSTANT(CURLFTPAUTH_SSL); REGISTER_CURL_CONSTANT(CURLFTPAUTH_TLS); REGISTER_CURL_CONSTANT(CURLOPT_FTPSSLAUTH); -#endif -#if LIBCURL_VERSION_NUM >= 0x070d00 /* Available since 7.13.0 */ + /* Available since 7.13.0 */ REGISTER_CURL_CONSTANT(CURLOPT_FTP_ACCOUNT); -#endif - -#if LIBCURL_VERSION_NUM >= 0x070b02 /* Available since 7.11.2 */ - REGISTER_CURL_CONSTANT(CURLOPT_TCP_NODELAY); -#endif -#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */ + /* Available since 7.12.2 */ REGISTER_CURL_CONSTANT(CURLINFO_OS_ERRNO); -#endif -#if LIBCURL_VERSION_NUM >= 0x070c03 /* Available since 7.12.3 */ + /* Available since 7.12.3 */ REGISTER_CURL_CONSTANT(CURLINFO_NUM_CONNECTS); REGISTER_CURL_CONSTANT(CURLINFO_SSL_ENGINES); -#endif -#if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */ + /* Available since 7.14.1 */ REGISTER_CURL_CONSTANT(CURLINFO_COOKIELIST); REGISTER_CURL_CONSTANT(CURLOPT_COOKIELIST); REGISTER_CURL_CONSTANT(CURLOPT_IGNORE_CONTENT_LENGTH); -#endif -#if LIBCURL_VERSION_NUM >= 0x070f00 /* Available since 7.15.0 */ + /* Available since 7.15.0 */ REGISTER_CURL_CONSTANT(CURLOPT_FTP_SKIP_PASV_IP); -#endif -#if LIBCURL_VERSION_NUM >= 0x070f01 /* Available since 7.15.1 */ + /* Available since 7.15.1 */ REGISTER_CURL_CONSTANT(CURLOPT_FTP_FILEMETHOD); -#endif -#if LIBCURL_VERSION_NUM >= 0x070f02 /* Available since 7.15.2 */ + /* Available since 7.15.2 */ REGISTER_CURL_CONSTANT(CURLOPT_CONNECT_ONLY); REGISTER_CURL_CONSTANT(CURLOPT_LOCALPORT); REGISTER_CURL_CONSTANT(CURLOPT_LOCALPORTRANGE); -#endif -#if LIBCURL_VERSION_NUM >= 0x070f03 /* Available since 7.15.3 */ + /* Available since 7.15.3 */ REGISTER_CURL_CONSTANT(CURLFTPMETHOD_MULTICWD); REGISTER_CURL_CONSTANT(CURLFTPMETHOD_NOCWD); REGISTER_CURL_CONSTANT(CURLFTPMETHOD_SINGLECWD); -#endif -#if LIBCURL_VERSION_NUM >= 0x070f04 /* Available since 7.15.4 */ + /* Available since 7.15.4 */ REGISTER_CURL_CONSTANT(CURLINFO_FTP_ENTRY_PATH); -#endif -#if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */ + /* Available since 7.15.5 */ REGISTER_CURL_CONSTANT(CURLOPT_FTP_ALTERNATIVE_TO_USER); REGISTER_CURL_CONSTANT(CURLOPT_MAX_RECV_SPEED_LARGE); REGISTER_CURL_CONSTANT(CURLOPT_MAX_SEND_SPEED_LARGE); -#endif #if LIBCURL_VERSION_NUM >= 0x071000 /* Available since 7.16.0 */ REGISTER_CURL_CONSTANT(CURLE_SSL_CACERT_BADFILE); @@ -1370,15 +1324,10 @@ PHP_MINIT_FUNCTION(curl) REGISTER_CURL_CONSTANT(CURLOPT_TCP_FASTOPEN); #endif -#if CURLOPT_FTPASCII != 0 - REGISTER_CURL_CONSTANT(CURLOPT_FTPASCII); -#endif -#if CURLOPT_MUTE != 0 - REGISTER_CURL_CONSTANT(CURLOPT_MUTE); -#endif -#if CURLOPT_PASSWDFUNCTION != 0 - REGISTER_CURL_CONSTANT(CURLOPT_PASSWDFUNCTION); +#if LIBCURL_VERSION_NUM >= 0x073700 /* Available since 7.55.0 */ + REGISTER_CURL_CONSTANT(CURLOPT_REQUEST_TARGET); #endif + REGISTER_CURL_CONSTANT(CURLOPT_SAFE_UPLOAD); #ifdef PHP_CURL_NEED_OPENSSL_TSL @@ -1476,8 +1425,8 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx) int error; zend_fcall_info fci; + GC_ADDREF(ch->res); ZVAL_RES(&argv[0], ch->res); - Z_ADDREF(argv[0]); ZVAL_STRINGL(&argv[1], data, length); fci.size = sizeof(fci); @@ -1524,8 +1473,8 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string) int error; zend_fcall_info fci; + GC_ADDREF(ch->res); ZVAL_RES(&argv[0], ch->res); - Z_ADDREF(argv[0]); ZVAL_STRING(&argv[1], pattern); ZVAL_STRING(&argv[2], string); @@ -1577,8 +1526,8 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double int error; zend_fcall_info fci; + GC_ADDREF(ch->res); ZVAL_RES(&argv[0], ch->res); - Z_ADDREF(argv[0]); ZVAL_LONG(&argv[1], (zend_long)dltotal); ZVAL_LONG(&argv[2], (zend_long)dlnow); ZVAL_LONG(&argv[3], (zend_long)ultotal); @@ -1604,10 +1553,6 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double } } zval_ptr_dtor(&argv[0]); - zval_ptr_dtor(&argv[1]); - zval_ptr_dtor(&argv[2]); - zval_ptr_dtor(&argv[3]); - zval_ptr_dtor(&argv[4]); break; } } @@ -1635,11 +1580,11 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx) int error; zend_fcall_info fci; + GC_ADDREF(ch->res); ZVAL_RES(&argv[0], ch->res); - Z_ADDREF(argv[0]); if (t->res) { + GC_ADDREF(t->res); ZVAL_RES(&argv[1], t->res); - Z_ADDREF(argv[1]); } else { ZVAL_NULL(&argv[1]); } @@ -1658,9 +1603,7 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx) ch->in_callback = 0; if (error == FAILURE) { php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_READFUNCTION"); -#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */ length = CURL_READFUNC_ABORT; -#endif } else if (!Z_ISUNDEF(retval)) { _php_curl_verify_handlers(ch, 1); if (Z_TYPE(retval) == IS_STRING) { @@ -1672,7 +1615,6 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx) zval_ptr_dtor(&argv[0]); zval_ptr_dtor(&argv[1]); - zval_ptr_dtor(&argv[2]); break; } } @@ -1707,8 +1649,8 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx int error; zend_fcall_info fci; + GC_ADDREF(ch->res); ZVAL_RES(&argv[0], ch->res); - Z_ADDREF(argv[0]); ZVAL_STRINGL(&argv[1], data, length); fci.size = sizeof(fci); @@ -1751,7 +1693,7 @@ static int curl_debug(CURL *cp, curl_infotype type, char *buf, size_t buf_len, v if (type == CURLINFO_HEADER_OUT) { if (ch->header.str) { - zend_string_release(ch->header.str); + zend_string_release_ex(ch->header.str, 0); } if (buf_len > 0) { ch->header.str = zend_string_init(buf, buf_len, 0); @@ -1762,46 +1704,6 @@ static int curl_debug(CURL *cp, curl_infotype type, char *buf, size_t buf_len, v } /* }}} */ -#if CURLOPT_PASSWDFUNCTION != 0 -/* {{{ curl_passwd - */ -static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen) -{ - php_curl *ch = (php_curl *) ctx; - zval *func = &ch->handlers->passwd; - zval argv[3]; - zval retval; - int error; - int ret = -1; - - ZVAL_RES(&argv[0], ch->res); - Z_ADDREF(argv[0]); - ZVAL_STRING(&argv[1], prompt); - ZVAL_LONG(&argv[2], buflen); - - error = call_user_function(EG(function_table), NULL, func, &retval, 2, argv); - if (error == FAILURE) { - php_error_docref(NULL, E_WARNING, "Could not call the CURLOPT_PASSWDFUNCTION"); - } else if (Z_TYPE(retval) == IS_STRING) { - if (Z_STRLEN(retval) > buflen) { - php_error_docref(NULL, E_WARNING, "Returned password is too long for libcurl to handle"); - } else { - memcpy(buf, Z_STRVAL(retval), Z_STRLEN(retval) + 1); - } - } else { - php_error_docref(NULL, E_WARNING, "User handler '%s' did not return a string", Z_STRVAL_P(func)); - } - - zval_ptr_dtor(&argv[0]); - zval_ptr_dtor(&argv[1]); - zval_ptr_dtor(&argv[2]); - zval_ptr_dtor(&retval); - - return ret; -} -/* }}} */ -#endif - /* {{{ curl_free_string */ static void curl_free_string(void **string) @@ -2176,38 +2078,20 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ case CURLOPT_UNRESTRICTED_AUTH: case CURLOPT_UPLOAD: case CURLOPT_VERBOSE: -#if LIBCURL_VERSION_NUM >= 0x070a06 /* Available since 7.10.6 */ case CURLOPT_HTTPAUTH: -#endif -#if LIBCURL_VERSION_NUM >= 0x070a07 /* Available since 7.10.7 */ case CURLOPT_FTP_CREATE_MISSING_DIRS: case CURLOPT_PROXYAUTH: -#endif -#if LIBCURL_VERSION_NUM >= 0x070a08 /* Available since 7.10.8 */ case CURLOPT_FTP_RESPONSE_TIMEOUT: case CURLOPT_IPRESOLVE: case CURLOPT_MAXFILESIZE: -#endif -#if LIBCURL_VERSION_NUM >= 0x070b02 /* Available since 7.11.2 */ case CURLOPT_TCP_NODELAY: -#endif -#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */ case CURLOPT_FTPSSLAUTH: -#endif -#if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */ case CURLOPT_IGNORE_CONTENT_LENGTH: -#endif -#if LIBCURL_VERSION_NUM >= 0x070f00 /* Available since 7.15.0 */ case CURLOPT_FTP_SKIP_PASV_IP: -#endif -#if LIBCURL_VERSION_NUM >= 0x070f01 /* Available since 7.15.1 */ case CURLOPT_FTP_FILEMETHOD: -#endif -#if LIBCURL_VERSION_NUM >= 0x070f02 /* Available since 7.15.2 */ case CURLOPT_CONNECT_ONLY: case CURLOPT_LOCALPORT: case CURLOPT_LOCALPORTRANGE: -#endif #if LIBCURL_VERSION_NUM >= 0x071000 /* Available since 7.16.0 */ case CURLOPT_SSL_SESSIONID_CACHE: #endif @@ -2227,13 +2111,10 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ #endif #if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */ case CURLOPT_USE_SSL: -#elif LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */ - case CURLOPT_FTP_SSL: -#endif -#if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */ case CURLOPT_APPEND: case CURLOPT_DIRLISTONLY: #else + case CURLOPT_FTP_SSL: case CURLOPT_FTPAPPEND: case CURLOPT_FTPLISTONLY: #endif @@ -2306,11 +2187,8 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ #if LIBCURL_VERSION_NUM >= 0x073100 /* Available since 7.49.0 */ case CURLOPT_TCP_FASTOPEN: #endif -#if CURLOPT_MUTE != 0 - case CURLOPT_MUTE: -#endif lval = zval_get_long(zvalue); -#if LIBCURL_VERSION_NUM >= 0x71304 +#if LIBCURL_VERSION_NUM >= 0x071304 if ((option == CURLOPT_PROTOCOLS || option == CURLOPT_REDIR_PROTOCOLS) && (PG(open_basedir) && *PG(open_basedir)) && (lval & CURLPROTO_FILE)) { php_error_docref(NULL, E_WARNING, "CURLPROTO_FILE cannot be activated when an open_basedir is set"); @@ -2318,7 +2196,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ } #endif # if defined(ZTS) - if (option == CURLOPT_DNS_USE_GLOBAL_CACHE) { + if (option == CURLOPT_DNS_USE_GLOBAL_CACHE && lval) { php_error_docref(NULL, E_WARNING, "CURLOPT_DNS_USE_GLOBAL_CACHE cannot be activated when thread safety is enabled"); return 1; } @@ -2350,12 +2228,8 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ case CURLOPT_SSL_CIPHER_LIST: case CURLOPT_USERAGENT: case CURLOPT_USERPWD: -#if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */ case CURLOPT_COOKIELIST: -#endif -#if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */ case CURLOPT_FTP_ALTERNATIVE_TO_USER: -#endif #if LIBCURL_VERSION_NUM >= 0x071101 /* Available since 7.17.1 */ case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5: #endif @@ -2403,10 +2277,14 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ #if LIBCURL_VERSION_NUM >= 0x072d00 /* Available since 7.45.0 */ case CURLOPT_DEFAULT_PROTOCOL: #endif +#if LIBCURL_VERSION_NUM >= 0x073700 /* Available since 7.55.0 */ + case CURLOPT_REQUEST_TARGET: +#endif { - zend_string *str = zval_get_string(zvalue); + zend_string *tmp_str; + zend_string *str = zval_get_tmp_string(zvalue, &tmp_str); int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0); - zend_string_release(str); + zend_tmp_string_release(tmp_str); return ret; } @@ -2414,9 +2292,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ case CURLOPT_CUSTOMREQUEST: case CURLOPT_FTPPORT: case CURLOPT_RANGE: -#if LIBCURL_VERSION_NUM >= 0x070d00 /* Available since 7.13.0 */ case CURLOPT_FTP_ACCOUNT: -#endif #if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */ case CURLOPT_RTSP_SESSION_ID: #endif @@ -2438,9 +2314,10 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ if (Z_ISNULL_P(zvalue)) { error = curl_easy_setopt(ch->cp, option, NULL); } else { - zend_string *str = zval_get_string(zvalue); + zend_string *tmp_str; + zend_string *str = zval_get_tmp_string(zvalue, &tmp_str); int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0); - zend_string_release(str); + zend_tmp_string_release(tmp_str); return ret; } break; @@ -2449,18 +2326,20 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ /* Curl private option */ case CURLOPT_PRIVATE: { - zend_string *str = zval_get_string(zvalue); + zend_string *tmp_str; + zend_string *str = zval_get_tmp_string(zvalue, &tmp_str); int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 1); - zend_string_release(str); + zend_tmp_string_release(tmp_str); return ret; } /* Curl url option */ case CURLOPT_URL: { - zend_string *str = zval_get_string(zvalue); + zend_string *tmp_str; + zend_string *str = zval_get_tmp_string(zvalue, &tmp_str); int ret = php_curl_option_url(ch, ZSTR_VAL(str), ZSTR_LEN(str)); - zend_string_release(str); + zend_tmp_string_release(tmp_str); return ret; } @@ -2583,7 +2462,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ { zval *current; HashTable *ph; - zend_string *val; + zend_string *val, *tmp_val; struct curl_slist *slist = NULL; ph = HASH_OF(zvalue); @@ -2635,9 +2514,9 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ ZEND_HASH_FOREACH_VAL(ph, current) { ZVAL_DEREF(current); - val = zval_get_string(current); + val = zval_get_tmp_string(current, &tmp_val); slist = curl_slist_append(slist, ZSTR_VAL(val)); - zend_string_release(val); + zend_tmp_string_release(tmp_val); if (!slist) { php_error_docref(NULL, E_WARNING, "Could not build curl_slist"); return 1; @@ -2698,7 +2577,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ } ZEND_HASH_FOREACH_KEY_VAL(postfields, num_key, string_key, current) { - zend_string *postval; + zend_string *postval, *tmp_postval; /* Pretend we have a string_key here */ if (!string_key) { string_key = zend_long_to_str(num_key); @@ -2744,11 +2623,11 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ } } - zend_string_release(string_key); + zend_string_release_ex(string_key, 0); continue; } - postval = zval_get_string(current); + postval = zval_get_tmp_string(current, &tmp_postval); /* The arguments after _NAMELENGTH and _CONTENTSLENGTH * must be explicitly cast to long in curl_formadd @@ -2764,8 +2643,8 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ /* Not nice to convert between enums but we only have place for one error type */ error = (CURLcode)form_error; } - zend_string_release(postval); - zend_string_release(string_key); + zend_tmp_string_release(tmp_postval); + zend_string_release_ex(string_key, 0); } ZEND_HASH_FOREACH_END(); SAVE_CURL_ERROR(ch, error); @@ -2780,21 +2659,23 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ error = curl_easy_setopt(ch->cp, CURLOPT_HTTPPOST, first); } else { #if LIBCURL_VERSION_NUM >= 0x071101 - zend_string *str = zval_get_string(zvalue); + zend_string *tmp_str; + zend_string *str = zval_get_tmp_string(zvalue, &tmp_str); /* with curl 7.17.0 and later, we can use COPYPOSTFIELDS, but we have to provide size before */ error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, ZSTR_LEN(str)); error = curl_easy_setopt(ch->cp, CURLOPT_COPYPOSTFIELDS, ZSTR_VAL(str)); - zend_string_release(str); + zend_tmp_string_release(tmp_str); #else char *post = NULL; - zend_string *str = zval_get_string(zvalue); + zend_string *tmp_str; + zend_string *str = zval_get_tmp_string(zvalue, &tmp_str); post = estrndup(ZSTR_VAL(str), ZSTR_LEN(str)); zend_llist_add_element(&ch->to_free->str, &post); curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, post); error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, ZSTR_LEN(str)); - zend_string_release(str); + zend_tmp_string_release(tmp_str); #endif } break; @@ -2838,13 +2719,11 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ ch->handlers->write->method = PHP_CURL_USER; break; -#if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */ case CURLOPT_MAX_RECV_SPEED_LARGE: case CURLOPT_MAX_SEND_SPEED_LARGE: lval = zval_get_long(zvalue); error = curl_easy_setopt(ch->cp, option, (curl_off_t)lval); break; -#endif #if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */ case CURLOPT_POSTREDIR: @@ -2853,15 +2732,6 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ break; #endif -#if CURLOPT_PASSWDFUNCTION != 0 - case CURLOPT_PASSWDFUNCTION: - zval_ptr_dtor(&ch->handlers->passwd); - ZVAL_COPY(&ch->handlers->passwd, zvalue); - error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDFUNCTION, curl_passwd); - error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) ch); - break; -#endif - /* the following options deal with files, therefore the open_basedir check * is required. */ @@ -2869,9 +2739,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ case CURLOPT_COOKIEJAR: case CURLOPT_RANDOM_FILE: case CURLOPT_SSLCERT: -#if LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */ case CURLOPT_NETRC_FILE: -#endif #if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 */ case CURLOPT_SSH_PRIVATE_KEYFILE: case CURLOPT_SSH_PUBLIC_KEYFILE: @@ -2884,16 +2752,17 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ case CURLOPT_SSH_KNOWNHOSTS: #endif { - zend_string *str = zval_get_string(zvalue); + zend_string *tmp_str; + zend_string *str = zval_get_tmp_string(zvalue, &tmp_str); int ret; if (ZSTR_LEN(str) && php_check_open_basedir(ZSTR_VAL(str))) { - zend_string_release(str); + zend_tmp_string_release(tmp_str); return FAILURE; } ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0); - zend_string_release(str); + zend_tmp_string_release(tmp_str); return ret; } @@ -3015,7 +2884,7 @@ void _php_curl_cleanup_handle(php_curl *ch) { smart_str_free(&ch->handlers->write->buf); if (ch->header.str) { - zend_string_release(ch->header.str); + zend_string_release_ex(ch->header.str, 0); ch->header.str = NULL; } @@ -3269,7 +3138,6 @@ PHP_FUNCTION(curl_getinfo) } break; } -#if LIBCURL_VERSION_NUM >= 0x070c03 /* Available since 7.12.3 */ case CURLINFO_SLIST: { struct curl_slist *slist; @@ -3285,7 +3153,6 @@ PHP_FUNCTION(curl_getinfo) } break; } -#endif default: RETURN_FALSE; } @@ -3400,12 +3267,9 @@ static void _php_curl_close_ex(php_curl *ch) zval_ptr_dtor(&ch->handlers->write->func_name); zval_ptr_dtor(&ch->handlers->read->func_name); zval_ptr_dtor(&ch->handlers->write_header->func_name); -#if CURLOPT_PASSWDFUNCTION != 0 - zval_ptr_dtor(&ch->handlers->passwd); -#endif zval_ptr_dtor(&ch->handlers->std_err); if (ch->header.str) { - zend_string_release(ch->header.str); + zend_string_release_ex(ch->header.str, 0); } zval_ptr_dtor(&ch->handlers->write_header->stream); @@ -3442,7 +3306,6 @@ static void _php_curl_close(zend_resource *rsrc) } /* }}} */ -#if LIBCURL_VERSION_NUM >= 0x070c00 /* Available since 7.12.0 */ /* {{{ proto bool curl_strerror(int code) return string describing error code */ PHP_FUNCTION(curl_strerror) @@ -3462,9 +3325,7 @@ PHP_FUNCTION(curl_strerror) } } /* }}} */ -#endif -#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */ /* {{{ _php_curl_reset_handlers() Reset all handlers of a given php_curl */ static void _php_curl_reset_handlers(php_curl *ch) @@ -3538,9 +3399,7 @@ PHP_FUNCTION(curl_reset) _php_curl_set_default_options(ch); } /* }}} */ -#endif -#if LIBCURL_VERSION_NUM > 0x070f03 /* 7.15.4 */ /* {{{ proto void curl_escape(resource ch, string str) URL encodes the given string */ PHP_FUNCTION(curl_escape) @@ -3603,7 +3462,6 @@ PHP_FUNCTION(curl_unescape) } } /* }}} */ -#endif #if LIBCURL_VERSION_NUM >= 0x071200 /* 7.18.0 */ /* {{{ proto void curl_pause(resource ch, int bitmask) diff --git a/ext/curl/multi.c b/ext/curl/multi.c index 3afe8ac413..b65ca89132 100644 --- a/ext/curl/multi.c +++ b/ext/curl/multi.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #ifdef HAVE_CONFIG_H @@ -79,7 +77,6 @@ PHP_FUNCTION(curl_multi_add_handle) zval *z_ch; php_curlm *mh; php_curl *ch; - zval tmp_val; CURLMcode error = CURLM_OK; ZEND_PARSE_PARAMETERS_START(2,2) @@ -97,10 +94,8 @@ PHP_FUNCTION(curl_multi_add_handle) _php_curl_cleanup_handle(ch); - /* we want to create a copy of this zval that we store in the multihandle structure element "easyh" */ - ZVAL_DUP(&tmp_val, z_ch); - - zend_llist_add_element(&mh->easyh, &tmp_val); + GC_ADDREF(Z_RES_P(z_ch)); + zend_llist_add_element(&mh->easyh, z_ch); error = curl_multi_add_handle(mh->multi, ch->cp); SAVE_CURLM_ERROR(mh, error); @@ -330,7 +325,7 @@ PHP_FUNCTION(curl_multi_getcontent) } /* }}} */ -/* {{{ proto array curl_multi_info_read(resource mh [, long &msgs_in_queue]) +/* {{{ proto array curl_multi_info_read(resource mh [, int &msgs_in_queue]) Get information about the current transfers */ PHP_FUNCTION(curl_multi_info_read) { @@ -455,7 +450,6 @@ PHP_FUNCTION(curl_multi_errno) } /* }}} */ -#if LIBCURL_VERSION_NUM >= 0x070c00 /* Available since 7.12.0 */ /* {{{ proto bool curl_multi_strerror(int code) return string describing error code */ PHP_FUNCTION(curl_multi_strerror) @@ -475,7 +469,6 @@ PHP_FUNCTION(curl_multi_strerror) } } /* }}} */ -#endif #if LIBCURL_VERSION_NUM >= 0x072C00 /* Available since 7.44.0 */ @@ -531,18 +524,15 @@ static int _php_server_push_callback(CURL *parent_ch, CURL *easy, size_t num_hea error = zend_call_function(&fci, &t->fci_cache); zend_fcall_info_args_clear(&fci, 1); - zval_dtor(&headers); + zval_ptr_dtor_nogc(&headers); if (error == FAILURE) { php_error_docref(NULL, E_WARNING, "Cannot call the CURLMOPT_PUSHFUNCTION"); } else if (!Z_ISUNDEF(retval)) { if (CURL_PUSH_DENY != zval_get_long(&retval)) { rval = CURL_PUSH_OK; - - /* we want to create a copy of this zval that we store in the multihandle structure element "easyh" */ - zval tmp_val; - ZVAL_DUP(&tmp_val, &pz_ch); - zend_llist_add_element(&mh->easyh, &tmp_val); + GC_ADDREF(Z_RES(pz_ch)); + zend_llist_add_element(&mh->easyh, &pz_ch); } else { /* libcurl will free this easy handle, avoid double free */ ch->cp = NULL; @@ -551,10 +541,10 @@ static int _php_server_push_callback(CURL *parent_ch, CURL *easy, size_t num_hea return rval; } +/* }}} */ #endif -#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */ static int _php_curl_multi_setopt(php_curlm *mh, zend_long option, zval *zvalue, zval *return_value) /* {{{ */ { CURLMcode error = CURLM_OK; @@ -638,7 +628,6 @@ PHP_FUNCTION(curl_multi_setopt) } } /* }}} */ -#endif #endif diff --git a/ext/curl/package.xml b/ext/curl/package.xml deleted file mode 100644 index f54abaf872..0000000000 --- a/ext/curl/package.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE package SYSTEM "../pear/package.dtd"> -<package> - <name>curl</name> - <summary>Clib PDF functions</summary> - <maintainers> - <maintainer> - <user>sterling</user> - <name>Sterling Hughes</name> - <email>sterling@php.net</email> - <role>lead</role> - </maintainer> - </maintainers> - <description> -PHP supports libcurl, a library created by Daniel Stenberg, -that allows you to connect and communicate to many different -types of servers with many different types of protocols. -libcurl currently supports the http, https, ftp, gopher, -telnet, dict, file, and ldap protocols. libcurl also supports -HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this -can also be done with PHP's ftp extension), HTTP form based -upload, proxies, cookies, and user+password authentication. - </description> - <license>PHP</license> - <release> - <state>beta</state> - <version>5.0rc1</version> - <date>2004-03-19</date> - <notes> -package.xml added to support installation using pear installer - </notes> - <configureoptions> - <configureoption name="with-curl" default="autodetect" prompt="path to curl installation?"/> - </configureoptions> - <filelist> - <file role="doc" name="CREDITS"/> - <file role="src" name="config.m4"/> - <file role="src" name="config.w32"/> - <file role="src" name="interface.c"/> - <file role="src" name="multi.c"/> - <file role="src" name="share.c"/> - <file role="src" name="streams.c"/> - <file role="src" name="php_curl.h"/> - </filelist> - <deps> - <dep type="php" rel="ge" version="5" /> - </deps> - </release> -</package> -<!-- -vim:et:ts=1:sw=1 ---> diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h index f94e7d2898..df509c7dc5 100644 --- a/ext/curl/php_curl.h +++ b/ext/curl/php_curl.h @@ -17,8 +17,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #ifndef _PHP_CURL_H #define _PHP_CURL_H @@ -99,15 +97,11 @@ PHP_FUNCTION(curl_share_init); PHP_FUNCTION(curl_share_setopt); PHP_FUNCTION(curl_share_errno); -#if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */ PHP_FUNCTION(curl_strerror); PHP_FUNCTION(curl_multi_strerror); PHP_FUNCTION(curl_share_strerror); -#endif -#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */ PHP_FUNCTION(curl_reset); -#endif #if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */ PHP_FUNCTION(curl_escape); @@ -154,9 +148,6 @@ typedef struct { php_curl_write *write; php_curl_write *write_header; php_curl_read *read; -#if CURLOPT_PASSWDFUNCTION != 0 - zval passwd; -#endif zval std_err; php_curl_progress *progress; #if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */ diff --git a/ext/curl/share.c b/ext/curl/share.c index 2730763247..772f899ff6 100644 --- a/ext/curl/share.c +++ b/ext/curl/share.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id$ */ - #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #ifdef HAVE_CONFIG_H @@ -153,7 +151,6 @@ PHP_FUNCTION(curl_share_errno) /* }}} */ -#if LIBCURL_VERSION_NUM >= 0x070c00 /* Available since 7.12.0 */ /* {{{ proto bool curl_share_strerror(int code) return string describing error code */ PHP_FUNCTION(curl_share_strerror) @@ -173,7 +170,6 @@ PHP_FUNCTION(curl_share_strerror) } } /* }}} */ -#endif #endif diff --git a/ext/curl/sync-constants.php b/ext/curl/sync-constants.php new file mode 100644 index 0000000000..093483ed9c --- /dev/null +++ b/ext/curl/sync-constants.php @@ -0,0 +1,321 @@ +<?php + +/** + * This script checks the constants defined in the curl PHP extension, against those documented on the cURL website: + * https://curl.haxx.se/libcurl/c/symbols-in-versions.html + * + * See the discussion at: https://github.com/php/php-src/pull/2961 + */ + +const CURL_DOC_FILE = 'https://curl.haxx.se/libcurl/c/symbols-in-versions.html'; + +const SOURCE_FILE = __DIR__ . '/interface.c'; + +const MIN_SUPPORTED_CURL_VERSION = '7.15.5'; + +const IGNORED_CONSTANTS = [ + 'CURLOPT_PROGRESSDATA' +]; + +$curlConstants = getCurlConstants(); +$sourceConstants = getSourceConstants(); + +$notInPHP = []; // In cURL doc, but missing from PHP +$notInCurl = []; // In the PHP source, but not in the cURL doc +$outdated = []; // In the PHP source, but removed before the minimum supported cURL version + +foreach ($curlConstants as $name => [$introduced, $deprecated, $removed]) { + $inPHP = in_array($name, $sourceConstants); + + if ($removed !== null) { + if (version_compare($removed, MIN_SUPPORTED_CURL_VERSION) <= 0) { + // constant removed before the minimum supported version + continue; + } + } + + if (! $inPHP) { + $notInPHP[$name] = [$introduced, $removed]; + } +} + +foreach ($sourceConstants as $name) { + if (! isset($curlConstants[$name])) { + $notInCurl[] = $name; + continue; + } + + $removed = $curlConstants[$name][2]; + + if ($removed === null) { + continue; + } + + if (version_compare($removed, MIN_SUPPORTED_CURL_VERSION) <= 0) { + // constant removed before the minimum supported version + $outdated[$name] = $removed; + } +} + +$allGood = true; + +if ($notInPHP) { + uasort($notInPHP, function($a, $b) { + return version_compare($a[0], $b[0]); + }); + + $table = new AsciiTable(); + $table->add('Constant', 'Introduced', '', 'Removed', ''); + + foreach ($notInPHP as $name => [$introduced, $removed]) { + if ($removed === null) { + $removed = ''; + $removedHex = ''; + } else { + $removedHex = getHexVersion($removed); + } + + $table->add($name, $introduced, getHexVersion($introduced), $removed, $removedHex); + } + + echo "Constants missing from the PHP source:\n\n"; + echo $table, "\n"; + + $allGood = false; +} + +if ($notInCurl) { + $table = new AsciiTable(); + + foreach ($notInCurl as $name) { + $table->add($name); + } + + echo "Constants defined in the PHP source, but absent from the cURL documentation:\n\n"; + echo $table, "\n"; + + $allGood = false; +} + +if ($outdated) { + uasort($outdated, function($a, $b) { + return version_compare($a, $b); + }); + + $table = new AsciiTable(); + $table->add('Constant', 'Removed'); + + foreach ($outdated as $name => $version) { + $table->add($name, $version); + } + + echo "Constants defined in the PHP source, but removed before the minimum supported cURL version:\n\n"; + echo $table, "\n"; + + $allGood = false; +} + +if ($allGood) { + echo "All good! Source code and cURL documentation are in sync.\n"; +} + +/** + * Loads and parses the cURL constants from the online documentation. + * + * The result is an associative array where the key is the constant name, and the value is a numeric array with: + * - the introduced version + * - the deprecated version (nullable) + * - the removed version (nullable) + * + * @return array + */ +function getCurlConstants() : array +{ + $html = file_get_contents(CURL_DOC_FILE); + + // Extract the constant list from the HTML file (located in the only <pre> tag in the page) + preg_match('~<pre>([^<]+)</pre>~', $html, $matches); + $constantList = $matches[1]; + + /** + * Parse the cURL constant lines. Possible formats: + * + * Name Introduced Deprecated Removed + * CURLOPT_CRLFILE 7.19.0 + * CURLOPT_DNS_USE_GLOBAL_CACHE 7.9.3 7.11.1 + * CURLOPT_FTPASCII 7.1 7.11.1 7.15.5 + * CURLOPT_HTTPREQUEST 7.1 - 7.15.5 + */ + $regexp = '/^([A-Za-z0-9_]+) +([0-9\.]+)(?: +([0-9\.\-]+))?(?: +([0-9\.]+))?/m'; + preg_match_all($regexp, $constantList, $matches, PREG_SET_ORDER); + + $constants = []; + + foreach ($matches as $match) { + $name = $match[1]; + $introduced = $match[2]; + $deprecated = $match[3] ?? null; + $removed = $match[4] ?? null; + + if (strpos($name, 'CURLOPT_') !== 0) { + // not a CURLOPT_* constant + continue; + } + + if (in_array($name, IGNORED_CONSTANTS)) { + // purposefully ignored constant + continue; + } + + if ($deprecated === '-') { // deprecated version can be a hyphen + $deprecated = null; + } + + $constants[$name] = [$introduced, $deprecated, $removed]; + } + + return $constants; +} + +/** + * Parses the defined cURL constants from the PHP extension source code. + * + * The result is a numeric array whose values are the constant names. + * + * @return array + */ +function getSourceConstants() : array +{ + $source = file_get_contents(SOURCE_FILE); + + preg_match_all('/REGISTER_CURL_CONSTANT\(([A-Za-z0-9_]+)\)/', $source, $matches); + + $constants = []; + + foreach ($matches[1] as $name) { + if ($name === '__c') { // macro + continue; + } + + if (strpos($name, 'CURLOPT_') !== 0) { + // not a CURLOPT_* constant + continue; + } + + $constants[] = $name; + } + + return $constants; +} + +/** + * Converts a version number to its hex representation as used in the extension source code. + * + * Example: 7.25.1 => 0x071901 + * + * @param string $version + * + * @return string + * + * @throws \RuntimeException + */ +function getHexVersion(string $version) : string +{ + $parts = explode('.', $version); + + if (count($parts) === 2) { + $parts[] = '0'; + } + + if (count($parts) !== 3) { + throw new \RuntimeException('Invalid version number: ' . $version); + } + + $hex = '0x'; + + foreach ($parts as $value) { + if (! ctype_digit($value) || strlen($value) > 3) { + throw new \RuntimeException('Invalid version number: ' . $version); + } + + $value = (int) $value; + + if ($value > 255) { + throw new \RuntimeException('Invalid version number: ' . $version); + } + + $value = dechex($value); + + if (strlen($value) === 1) { + $value = '0' . $value; + } + + $hex .= $value; + } + + return $hex; +} + +/** + * A simple helper to create ASCII tables. + * It assumes that the same number of columns is always given to add(). + */ +class AsciiTable +{ + /** + * @var array + */ + private $values = []; + + /** + * @var array + */ + private $length = []; + + /** + * @var int + */ + private $padding = 4; + + /** + * @param string[] $values + * + * @return void + */ + public function add(string ...$values) : void + { + $this->values[] = $values; + + foreach ($values as $key => $value) { + $length = strlen($value); + + if (isset($this->length[$key])) { + $this->length[$key] = max($this->length[$key], $length); + } else { + $this->length[$key] = $length; + } + } + } + + /** + * @return string + */ + public function __toString() : string + { + $result = ''; + + foreach ($this->values as $values) { + foreach ($values as $key => $value) { + if ($key !== 0) { + $result .= str_repeat(' ', $this->padding); + } + + $result .= str_pad($value, $this->length[$key]); + } + + $result .= "\n"; + } + + return $result; + } +} diff --git a/ext/curl/tests/bug48514.phpt b/ext/curl/tests/bug48514.phpt index 0ea25754f1..66b81097ea 100644 --- a/ext/curl/tests/bug48514.phpt +++ b/ext/curl/tests/bug48514.phpt @@ -22,6 +22,6 @@ var_dump(get_resource_type($ch2)); ?> --EXPECTF-- resource(%d) of type (curl) -%string|unicode%(4) "curl" +string(4) "curl" resource(%d) of type (curl_multi) -%string|unicode%(10) "curl_multi" +string(10) "curl_multi" diff --git a/ext/curl/tests/bug52827.phpt b/ext/curl/tests/bug52827.phpt index 85a73fa797..f0faad68f5 100644 --- a/ext/curl/tests/bug52827.phpt +++ b/ext/curl/tests/bug52827.phpt @@ -28,5 +28,5 @@ $handle=curl_init('http://www.example.com'); curl_setopt($handle, CURLOPT_STDERR, $s); echo "Done."; ---EXPECTF-- +--EXPECT-- Done. diff --git a/ext/curl/tests/bug54995.phpt b/ext/curl/tests/bug54995.phpt index 4af59948be..e113d130a1 100644 --- a/ext/curl/tests/bug54995.phpt +++ b/ext/curl/tests/bug54995.phpt @@ -22,5 +22,5 @@ curl_exec($ch); curl_close($ch); ?> ---EXPECTF-- +--EXPECT-- bool(true) diff --git a/ext/curl/tests/bug55767.phpt b/ext/curl/tests/bug55767.phpt index bbeecb6b87..8690597ae8 100644 --- a/ext/curl/tests/bug55767.phpt +++ b/ext/curl/tests/bug55767.phpt @@ -33,7 +33,7 @@ include 'skipif.inc'; var_dump( $curl_content ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl sending through GET an POST *** string(203) "array(2) { ["test"]=> diff --git a/ext/curl/tests/bug62839.phpt b/ext/curl/tests/bug62839.phpt index e6988d6de1..be8646ea99 100644 --- a/ext/curl/tests/bug62839.phpt +++ b/ext/curl/tests/bug62839.phpt @@ -14,5 +14,5 @@ curl_copy_handle($curl); echo 'DONE!'; ?> ---EXPECTF-- +--EXPECT-- DONE! diff --git a/ext/curl/tests/bug66109.phpt b/ext/curl/tests/bug66109.phpt index 5a18e97294..c40d1e9667 100644 --- a/ext/curl/tests/bug66109.phpt +++ b/ext/curl/tests/bug66109.phpt @@ -19,6 +19,6 @@ var_dump(curl_exec($ch)); curl_close($ch); ?> ---EXPECTF-- +--EXPECT-- string(6) "DELETE" string(3) "GET" diff --git a/ext/curl/tests/bug68937.phpt b/ext/curl/tests/bug68937.phpt index 0f346cf3fa..ff8a906eba 100644 --- a/ext/curl/tests/bug68937.phpt +++ b/ext/curl/tests/bug68937.phpt @@ -36,5 +36,5 @@ function curl_read($ch, $fp, $len) { curl_exec($ch); curl_close($ch); ?> ---EXPECTF-- +--EXPECT-- NULL diff --git a/ext/curl/tests/bug71523.phpt b/ext/curl/tests/bug71523.phpt index 24aa83c620..84f1a17159 100644 --- a/ext/curl/tests/bug71523.phpt +++ b/ext/curl/tests/bug71523.phpt @@ -27,5 +27,5 @@ do { } while ($active); ?> okey ---EXPECTF-- +--EXPECT-- okey diff --git a/ext/curl/tests/curl_basic_001.phpt b/ext/curl/tests/curl_basic_001.phpt index 4921b69bdd..3feea49905 100644 --- a/ext/curl/tests/curl_basic_001.phpt +++ b/ext/curl/tests/curl_basic_001.phpt @@ -35,7 +35,7 @@ TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> } ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl_exec() : basic functionality *** string(25) "Hello World! Hello World!" diff --git a/ext/curl/tests/curl_basic_002.phpt b/ext/curl/tests/curl_basic_002.phpt index 69aef4b825..186fa66dfa 100644 --- a/ext/curl/tests/curl_basic_002.phpt +++ b/ext/curl/tests/curl_basic_002.phpt @@ -32,7 +32,7 @@ TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> var_dump( $curl_content ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); *** string(25) "Hello World! Hello World!" diff --git a/ext/curl/tests/curl_basic_003.phpt b/ext/curl/tests/curl_basic_003.phpt index 9c5967db8f..07cbad4b7a 100644 --- a/ext/curl/tests/curl_basic_003.phpt +++ b/ext/curl/tests/curl_basic_003.phpt @@ -34,7 +34,7 @@ TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> var_dump( $curl_content ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl sending through GET an POST *** string(208) "array(2) { ["test"]=> diff --git a/ext/curl/tests/curl_basic_004.phpt b/ext/curl/tests/curl_basic_004.phpt index 08dc7a1005..b520db6c70 100644 --- a/ext/curl/tests/curl_basic_004.phpt +++ b/ext/curl/tests/curl_basic_004.phpt @@ -33,7 +33,7 @@ TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> var_dump( $curl_content ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl setting referer *** string(19) "http://www.refer.er" ===DONE=== diff --git a/ext/curl/tests/curl_basic_005.phpt b/ext/curl/tests/curl_basic_005.phpt index 200db765dc..4d90ebfd37 100644 --- a/ext/curl/tests/curl_basic_005.phpt +++ b/ext/curl/tests/curl_basic_005.phpt @@ -33,7 +33,7 @@ TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> var_dump( $curl_content ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl with user agent *** string(9) "cURL phpt" ===DONE=== diff --git a/ext/curl/tests/curl_basic_006.phpt b/ext/curl/tests/curl_basic_006.phpt index e48a5ba70d..5d37297bb2 100644 --- a/ext/curl/tests/curl_basic_006.phpt +++ b/ext/curl/tests/curl_basic_006.phpt @@ -35,7 +35,7 @@ TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> echo "Data: $alldata"; ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl_setopt($ch, CURLOPT_WRITEFUNCTION, <closure>); *** Data: Hello World! Hello World!===DONE=== diff --git a/ext/curl/tests/curl_basic_007.phpt b/ext/curl/tests/curl_basic_007.phpt index b7eba4bc2a..539da71952 100644 --- a/ext/curl/tests/curl_basic_007.phpt +++ b/ext/curl/tests/curl_basic_007.phpt @@ -20,5 +20,5 @@ curl_close($ch); ?> --EXPECTF-- -%string|unicode%(%d) "No URL set!%w" +string(%d) "No URL set!%w" int(3) diff --git a/ext/curl/tests/curl_basic_011.phpt b/ext/curl/tests/curl_basic_011.phpt index 4e33082409..22be2b8b16 100644 --- a/ext/curl/tests/curl_basic_011.phpt +++ b/ext/curl/tests/curl_basic_011.phpt @@ -32,7 +32,7 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> var_dump( $curl_content ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl with cookie *** string(3) "bar" ===DONE=== diff --git a/ext/curl/tests/curl_basic_012.phpt b/ext/curl/tests/curl_basic_012.phpt index f136880dff..94afa73e26 100644 --- a/ext/curl/tests/curl_basic_012.phpt +++ b/ext/curl/tests/curl_basic_012.phpt @@ -32,7 +32,7 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> var_dump( $curl_content ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl with HTTP/1.0 *** string(8) "HTTP/1.0" ===DONE=== diff --git a/ext/curl/tests/curl_basic_013.phpt b/ext/curl/tests/curl_basic_013.phpt index 6d09517e8d..4e9233c080 100644 --- a/ext/curl/tests/curl_basic_013.phpt +++ b/ext/curl/tests/curl_basic_013.phpt @@ -32,7 +32,7 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> var_dump( $curl_content ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl with HTTP/1.1 *** string(8) "HTTP/1.1" ===DONE=== diff --git a/ext/curl/tests/curl_basic_015.phpt b/ext/curl/tests/curl_basic_015.phpt index e8e43e5686..00ad7c9b1d 100644 --- a/ext/curl/tests/curl_basic_015.phpt +++ b/ext/curl/tests/curl_basic_015.phpt @@ -11,6 +11,6 @@ Jean-Marc Fontaine <jmf@durcommefaire.net> var_dump($url == curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- bool(true) ===DONE=== diff --git a/ext/curl/tests/curl_basic_017.phpt b/ext/curl/tests/curl_basic_017.phpt index dc0bee926b..2dd06c778a 100644 --- a/ext/curl/tests/curl_basic_017.phpt +++ b/ext/curl/tests/curl_basic_017.phpt @@ -61,7 +61,7 @@ TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com> } ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl_exec() : basic functionality *** string(75) "Hello World! Hello World!Hello World! diff --git a/ext/curl/tests/curl_basic_018.phpt b/ext/curl/tests/curl_basic_018.phpt index 5c085c1c93..46b80ed982 100644 --- a/ext/curl/tests/curl_basic_018.phpt +++ b/ext/curl/tests/curl_basic_018.phpt @@ -64,7 +64,7 @@ TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com> ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl_exec() : basic functionality *** string(75) "Hello World! Hello World!Hello World! diff --git a/ext/curl/tests/curl_basic_019.phpt b/ext/curl/tests/curl_basic_019.phpt index 2c58500ef7..fde4dccb3d 100644 --- a/ext/curl/tests/curl_basic_019.phpt +++ b/ext/curl/tests/curl_basic_019.phpt @@ -19,7 +19,7 @@ Jean-Marc Fontaine <jmf@durcommefaire.net> curl_close($ch); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- Hello World! Hello World!bool(true) ===DONE=== diff --git a/ext/curl/tests/curl_basic_020.phpt b/ext/curl/tests/curl_basic_020.phpt index 1227ad3261..99ac93d192 100644 --- a/ext/curl/tests/curl_basic_020.phpt +++ b/ext/curl/tests/curl_basic_020.phpt @@ -17,7 +17,7 @@ Jean-Marc Fontaine <jmf@durcommefaire.net> curl_close($ch); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- Hello World! Hello World!int(200) ===DONE=== diff --git a/ext/curl/tests/curl_basic_021.phpt b/ext/curl/tests/curl_basic_021.phpt index e803d98837..46d21cd81b 100644 --- a/ext/curl/tests/curl_basic_021.phpt +++ b/ext/curl/tests/curl_basic_021.phpt @@ -17,6 +17,6 @@ Jean-Marc Fontaine <jmf@durcommefaire.net> curl_close($ch); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- string(24) "text/plain;charset=utf-8" ===DONE=== diff --git a/ext/curl/tests/curl_copy_handle_basic.phpt b/ext/curl/tests/curl_copy_handle_basic.phpt index 1a6ff41699..6aeb669abf 100644 --- a/ext/curl/tests/curl_copy_handle_basic.phpt +++ b/ext/curl/tests/curl_copy_handle_basic.phpt @@ -24,7 +24,7 @@ $ch2 = curl_copy_handle($ch); var_dump(curl_getinfo($ch) === curl_getinfo($ch2)); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl_copy_handle(): basic *** bool(true) ===DONE=== diff --git a/ext/curl/tests/curl_copy_handle_basic_001.phpt b/ext/curl/tests/curl_copy_handle_basic_001.phpt index aafa41ee2e..0f1cf9dfd7 100644 --- a/ext/curl/tests/curl_copy_handle_basic_001.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_001.phpt @@ -29,7 +29,7 @@ Rick Buitenman <rick@meritos.nl> var_dump( $curl_content ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl copy handle with simple GET *** string(106) "array(2) { ["test"]=> diff --git a/ext/curl/tests/curl_copy_handle_basic_002.phpt b/ext/curl/tests/curl_copy_handle_basic_002.phpt index 6e8214ad2b..6b2136bda2 100644 --- a/ext/curl/tests/curl_copy_handle_basic_002.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_002.phpt @@ -30,7 +30,7 @@ Rick Buitenman <rick@meritos.nl> var_dump( $curl_content ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl copy handle with simple POST *** string(163) "array(1) { ["test"]=> diff --git a/ext/curl/tests/curl_copy_handle_basic_004.phpt b/ext/curl/tests/curl_copy_handle_basic_004.phpt index c690180a55..cad1be9865 100644 --- a/ext/curl/tests/curl_copy_handle_basic_004.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_004.phpt @@ -31,7 +31,7 @@ Rick Buitenman <rick@meritos.nl> var_dump( $curl_content_copy ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Test curl_copy_handle() after exec() *** string(106) "array(2) { ["test"]=> diff --git a/ext/curl/tests/curl_copy_handle_basic_005.phpt b/ext/curl/tests/curl_copy_handle_basic_005.phpt index e92603324e..939ee7381b 100644 --- a/ext/curl/tests/curl_copy_handle_basic_005.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_005.phpt @@ -33,7 +33,7 @@ Rick Buitenman <rick@meritos.nl> var_dump( $curl_content_copy ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Test curl_copy_handle() after exec() with POST *** string(163) "array(1) { ["test"]=> diff --git a/ext/curl/tests/curl_copy_handle_basic_006.phpt b/ext/curl/tests/curl_copy_handle_basic_006.phpt index 0a5c2a25e6..e33857d57e 100644 --- a/ext/curl/tests/curl_copy_handle_basic_006.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_006.phpt @@ -31,7 +31,7 @@ Rick Buitenman <rick@meritos.nl> ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl copy handle with User Agent *** string(9) "cURL phpt" string(9) "cURL phpt" diff --git a/ext/curl/tests/curl_copy_handle_basic_007.phpt b/ext/curl/tests/curl_copy_handle_basic_007.phpt index 6334d2a4b8..23813d32c2 100644 --- a/ext/curl/tests/curl_copy_handle_basic_007.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_007.phpt @@ -28,7 +28,7 @@ Test curl_copy_handle() with simple POST var_dump( $curl_content ); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl copy handle with simple POST using array as arguments *** string(163) "array(1) { ["test"]=> diff --git a/ext/curl/tests/curl_copy_handle_basic_008.phpt b/ext/curl/tests/curl_copy_handle_basic_008.phpt index cdb7de374d..c48c76db22 100644 --- a/ext/curl/tests/curl_copy_handle_basic_008.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_008.phpt @@ -19,7 +19,7 @@ Test curl_copy_handle() with CURLOPT_PROGRESSFUNCTION echo curl_exec($ch2); ?> ---EXPECTF-- +--EXPECT-- Hello World! Hello World! Hello World! diff --git a/ext/curl/tests/curl_copy_handle_variation1.phpt b/ext/curl/tests/curl_copy_handle_variation1.phpt index da4522192d..8978e2650e 100644 --- a/ext/curl/tests/curl_copy_handle_variation1.phpt +++ b/ext/curl/tests/curl_copy_handle_variation1.phpt @@ -26,7 +26,7 @@ curl_setopt($ch2, CURLOPT_URL, 'http://www.bar.com/'); var_dump(curl_getinfo($ch) === curl_getinfo($ch2)); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl_copy_handle(): basic *** bool(false) ===DONE=== diff --git a/ext/curl/tests/curl_copy_handle_variation2.phpt b/ext/curl/tests/curl_copy_handle_variation2.phpt index 924bf6a470..36b5febf50 100644 --- a/ext/curl/tests/curl_copy_handle_variation2.phpt +++ b/ext/curl/tests/curl_copy_handle_variation2.phpt @@ -7,7 +7,7 @@ Francesco Fullone ff@ideato.it <?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?> ---COMMENT-- +--DESCRIPTION-- the only way to test if a option is setten on a curl handle is using the curl_getinfo() function. but this can only check on a limited amount of options... --FILE-- @@ -35,7 +35,7 @@ curl_setopt($ch2, CURLOPT_URL, 'http://www.bar.com/'); var_dump(curl_getinfo($ch) === curl_getinfo($ch2)); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- *** Testing curl_copy_handle(): add options after copy *** bool(true) bool(false) diff --git a/ext/curl/tests/curl_file_upload.phpt b/ext/curl/tests/curl_file_upload.phpt index c64e67aa5c..8d304c5f01 100644 --- a/ext/curl/tests/curl_file_upload.phpt +++ b/ext/curl/tests/curl_file_upload.phpt @@ -1,6 +1,5 @@ --TEST-- CURL file uploading ---INI-- --SKIPIF-- <?php include 'skipif.inc'; ?> --FILE-- diff --git a/ext/curl/tests/curl_ftp_pasv.phpt b/ext/curl/tests/curl_ftp_pasv.phpt index 6cd7429104..f63a710ae9 100644 --- a/ext/curl/tests/curl_ftp_pasv.phpt +++ b/ext/curl/tests/curl_ftp_pasv.phpt @@ -1,8 +1,7 @@ --TEST-- -Test curl_exec() function with basic functionality ---CREDITS-- +Test curl_exec() function with basic functionality --SKIPIF-- -<?php +<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); if (false === getenv('PHP_CURL_FTP_REMOTE_SERVER')) exit("skip PHP_CURL_FTP_REMOTE_SERVER env variable is not defined"); if (false === getenv('PHP_CURL_FTP_REMOTE_USER')) exit("skip PHP_CURL_FTP_REMOTE_USER env variable is not defined"); @@ -14,7 +13,7 @@ if (false === getenv('PHP_CURL_FTP_REMOTE_PASSWD')) exit("skip PHP_CURL_FTP_REM $username = getenv('PHP_CURL_FTP_REMOTE_USER'); $password = getenv('PHP_CURL_FTP_REMOTE_PASSWD'); - // FTP this script to a server + // FTP this script to a server $fp = fopen ( __FILE__ , "r" ); $url = "ftp://$username:$password@$host/test.phpt" ; @@ -54,6 +53,6 @@ if (false === getenv('PHP_CURL_FTP_REMOTE_PASSWD')) exit("skip PHP_CURL_FTP_REM ?> ===DONE=== ---EXPECTF-- +--EXPECT-- bool(true) ===DONE=== diff --git a/ext/curl/tests/curl_multi_close_basic001.phpt b/ext/curl/tests/curl_multi_close_basic001.phpt new file mode 100644 index 0000000000..0cabf2cbad --- /dev/null +++ b/ext/curl/tests/curl_multi_close_basic001.phpt @@ -0,0 +1,25 @@ +--TEST-- +curl_multi_close return false when suplied resorce not valid cURL multi handle +--SKIPIF-- +<?php +if (!extension_loaded('curl')) print 'skip'; +?> +--FILE-- +<?php +$cmh = curl_multi_init(); +var_dump($cmh); +$multi_close_result = curl_multi_close($cmh); +var_dump($multi_close_result); +var_dump($cmh); +$bad_mh_close_result = curl_multi_close($cmh); +var_dump($bad_mh_close_result); +?> +===DONE=== +--EXPECTF-- +resource(%d) of type (curl_multi) +NULL +resource(%d) of type (Unknown) + +Warning: curl_multi_close(): supplied resource is not a valid cURL Multi Handle resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/curl/tests/curl_multi_errno_strerror_001.phpt b/ext/curl/tests/curl_multi_errno_strerror_001.phpt index 1fcdfe9558..9842aeda33 100644 --- a/ext/curl/tests/curl_multi_errno_strerror_001.phpt +++ b/ext/curl/tests/curl_multi_errno_strerror_001.phpt @@ -23,7 +23,7 @@ $errno = curl_multi_errno($mh); echo $errno . PHP_EOL; echo curl_multi_strerror($errno) . PHP_EOL; ?> ---EXPECTF-- +--EXPECT-- 0 No error 6 diff --git a/ext/curl/tests/curl_multi_getcontent_basic3.phpt b/ext/curl/tests/curl_multi_getcontent_basic3.phpt index 190fe9d9c0..9c0f7ddeba 100644 --- a/ext/curl/tests/curl_multi_getcontent_basic3.phpt +++ b/ext/curl/tests/curl_multi_getcontent_basic3.phpt @@ -46,7 +46,7 @@ Rein Velt (rein@velt.org) echo $results2; ?> ---EXPECTF-- +--EXPECT-- array(2) { ["test"]=> string(7) "getpost" diff --git a/ext/curl/tests/curl_multi_segfault.phpt b/ext/curl/tests/curl_multi_segfault.phpt index dde8189411..8af4dde635 100644 --- a/ext/curl/tests/curl_multi_segfault.phpt +++ b/ext/curl/tests/curl_multi_segfault.phpt @@ -1,8 +1,7 @@ --TEST-- -Segfault due to libcurl connection caching ---CREDITS-- +Segfault due to libcurl connection caching --SKIPIF-- -<?php +<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); if (false === getenv('PHP_CURL_FTP_REMOTE_SERVER')) exit("skip PHP_CURL_FTP_REMOTE_SERVER env variable is not defined"); if (false === getenv('PHP_CURL_FTP_REMOTE_USER')) exit("skip PHP_CURL_FTP_REMOTE_USER env variable is not defined"); @@ -14,7 +13,7 @@ if (false === getenv('PHP_CURL_FTP_REMOTE_PASSWD')) exit("skip PHP_CURL_FTP_REM $username = getenv('PHP_CURL_FTP_REMOTE_USER'); $password = getenv('PHP_CURL_FTP_REMOTE_PASSWD'); - // FTP this script to a server + // FTP this script to a server $fp = fopen ( __FILE__ , "r" ); $url = "ftp://$username:$password@$host/" ; @@ -43,14 +42,14 @@ if (false === getenv('PHP_CURL_FTP_REMOTE_PASSWD')) exit("skip PHP_CURL_FTP_REM $mrc = curl_multi_exec($cmh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } - } - + } + var_dump(is_string(curl_multi_getcontent($ch))); curl_multi_remove_handle($cmh, $ch); curl_close($ch); curl_multi_close($cmh); ?> ===DONE=== ---EXPECTF-- +--EXPECT-- bool(true) ===DONE=== diff --git a/ext/curl/tests/curl_multi_strerror_001.phpt b/ext/curl/tests/curl_multi_strerror_001.phpt index ac330acaee..becaebd6cc 100644 --- a/ext/curl/tests/curl_multi_strerror_001.phpt +++ b/ext/curl/tests/curl_multi_strerror_001.phpt @@ -17,6 +17,6 @@ var_dump(strtolower(curl_multi_strerror(CURLM_OK))); var_dump(strtolower(curl_multi_strerror(CURLM_BAD_HANDLE))); ?> ---EXPECTF-- +--EXPECT-- string(8) "no error" string(20) "invalid multi handle" diff --git a/ext/curl/tests/curl_setopt_error.phpt b/ext/curl/tests/curl_setopt_error.phpt index b9727c8a55..ab864d4b2d 100644 --- a/ext/curl/tests/curl_setopt_error.phpt +++ b/ext/curl/tests/curl_setopt_error.phpt @@ -38,8 +38,8 @@ Warning: curl_setopt() expects exactly 3 parameters, 2 given in %s on line %d Warning: curl_setopt() expects exactly 3 parameters, 2 given in %s on line %d -Warning: curl_setopt() expects parameter 1 to be resource, boolean given in %s on line %d +Warning: curl_setopt() expects parameter 1 to be resource, bool given in %s on line %d -Warning: curl_setopt() expects parameter 2 to be integer, string given in %s on line %d +Warning: curl_setopt() expects parameter 2 to be int, string given in %s on line %d Warning: curl_setopt(): Invalid curl configuration option in %scurl_setopt_error.php on line %d diff --git a/ext/curl/tests/curl_share_close_basic001.phpt b/ext/curl/tests/curl_share_close_basic001.phpt new file mode 100644 index 0000000000..8addd5de4e --- /dev/null +++ b/ext/curl/tests/curl_share_close_basic001.phpt @@ -0,0 +1,19 @@ +--TEST-- +curl_share_close basic test +--SKIPIF-- +<?php if( !extension_loaded( 'curl' ) ) print 'skip'; ?> +--FILE-- +<?php + +$sh = curl_share_init(); +//Show that there's a curl_share resource +var_dump($sh); + +curl_share_close($sh); +//Show that resource is no longer a curl_share, and is therefore unusable and "closed" +var_dump($sh); + +?> +--EXPECTF-- +resource(%d) of type (curl_share) +resource(%d) of type (Unknown)
\ No newline at end of file diff --git a/ext/curl/tests/curl_share_errno_strerror_001.phpt b/ext/curl/tests/curl_share_errno_strerror_001.phpt index 91476cdaff..1db23c7b92 100644 --- a/ext/curl/tests/curl_share_errno_strerror_001.phpt +++ b/ext/curl/tests/curl_share_errno_strerror_001.phpt @@ -23,7 +23,7 @@ $errno = curl_share_errno($sh); echo $errno . PHP_EOL; echo curl_share_strerror($errno) . PHP_EOL; ?> ---EXPECTF-- +--EXPECT-- 0 No error 1 diff --git a/ext/curl/tests/curl_strerror_001.phpt b/ext/curl/tests/curl_strerror_001.phpt index f8a0de311b..f103f43966 100644 --- a/ext/curl/tests/curl_strerror_001.phpt +++ b/ext/curl/tests/curl_strerror_001.phpt @@ -18,7 +18,7 @@ var_dump(strtolower(curl_strerror(CURLE_UNSUPPORTED_PROTOCOL))); var_dump(strtolower(curl_strerror(-1))); ?> ---EXPECTF-- +--EXPECT-- string(8) "no error" string(20) "unsupported protocol" string(13) "unknown error" diff --git a/ext/curl/tests/curl_version_variation1.phpt b/ext/curl/tests/curl_version_variation1.phpt index 7c0106cb6a..cbf2d4cbac 100644 --- a/ext/curl/tests/curl_version_variation1.phpt +++ b/ext/curl/tests/curl_version_variation1.phpt @@ -110,23 +110,23 @@ bool(true) bool(true) -- Iteration 10 -- -Warning: curl_version() expects parameter 1 to be integer, array given in %s on line %d +Warning: curl_version() expects parameter 1 to be int, array given in %s on line %d bool(false) -- Iteration 11 -- -Warning: curl_version() expects parameter 1 to be integer, array given in %s on line %d +Warning: curl_version() expects parameter 1 to be int, array given in %s on line %d bool(false) -- Iteration 12 -- -Warning: curl_version() expects parameter 1 to be integer, array given in %s on line %d +Warning: curl_version() expects parameter 1 to be int, array given in %s on line %d bool(false) -- Iteration 13 -- -Warning: curl_version() expects parameter 1 to be integer, string given in %s on line %d +Warning: curl_version() expects parameter 1 to be int, string given in %s on line %d bool(false) -- Iteration 14 -- -Warning: curl_version() expects parameter 1 to be integer, string given in %s on line %d +Warning: curl_version() expects parameter 1 to be int, string given in %s on line %d bool(false) -- Iteration 15 -- @@ -146,11 +146,11 @@ bool(true) bool(true) -- Iteration 22 -- -Warning: curl_version() expects parameter 1 to be integer, object given in %s on line %d +Warning: curl_version() expects parameter 1 to be int, object given in %s on line %d bool(false) -- Iteration 23 -- -Warning: curl_version() expects parameter 1 to be integer, resource given in %s on line %d +Warning: curl_version() expects parameter 1 to be int, resource given in %s on line %d bool(false) -- Iteration 24 -- bool(true) diff --git a/ext/curl/tests/server.inc b/ext/curl/tests/server.inc index 27f0cbbc84..124e0f898c 100644 --- a/ext/curl/tests/server.inc +++ b/ext/curl/tests/server.inc @@ -8,7 +8,7 @@ function curl_cli_server_start() { if(getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { return getenv('PHP_CURL_HTTP_REMOTE_SERVER'); } - + $php_executable = getenv('TEST_PHP_EXECUTABLE'); $doc_root = __DIR__; $router = "responder/get.php"; @@ -36,7 +36,7 @@ function curl_cli_server_start() { $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root); } - + // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' // it might not be listening yet...need to wait until fsockopen() call returns $error = "Unable to connect to server\n"; |