Skip to content

Commit 5c21d39

Browse files
committed
Remove method member from php_curl_callback
For these callbacks a non-null callback already indicates that a user callback should be used. We don't need an additional member to tell us the same thing.
1 parent ee6cb72 commit 5c21d39

File tree

3 files changed

+62
-78
lines changed

3 files changed

+62
-78
lines changed

ext/curl/curl_private.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ typedef struct {
6565
typedef struct {
6666
zval func_name;
6767
zend_fcall_info_cache fci_cache;
68-
int method;
6968
} php_curl_callback;
7069

7170
typedef struct {

ext/curl/interface.c

Lines changed: 62 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,41 +1410,36 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
14101410
php_curl *ch = (php_curl *) ctx;
14111411
php_curl_callback *t = ch->handlers.fnmatch;
14121412
int rval = CURL_FNMATCHFUNC_FAIL;
1413-
switch (t->method) {
1414-
case PHP_CURL_USER: {
1415-
zval argv[3];
1416-
zval retval;
1417-
int error;
1418-
zend_fcall_info fci;
1419-
1420-
GC_ADDREF(&ch->std);
1421-
ZVAL_OBJ(&argv[0], &ch->std);
1422-
ZVAL_STRING(&argv[1], pattern);
1423-
ZVAL_STRING(&argv[2], string);
1424-
1425-
fci.size = sizeof(fci);
1426-
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
1427-
fci.object = NULL;
1428-
fci.retval = &retval;
1429-
fci.param_count = 3;
1430-
fci.params = argv;
1431-
fci.named_params = NULL;
1432-
1433-
ch->in_callback = 1;
1434-
error = zend_call_function(&fci, &t->fci_cache);
1435-
ch->in_callback = 0;
1436-
if (error == FAILURE) {
1437-
php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_FNMATCH_FUNCTION");
1438-
} else if (!Z_ISUNDEF(retval)) {
1439-
_php_curl_verify_handlers(ch, 1);
1440-
rval = zval_get_long(&retval);
1441-
}
1442-
zval_ptr_dtor(&argv[0]);
1443-
zval_ptr_dtor(&argv[1]);
1444-
zval_ptr_dtor(&argv[2]);
1445-
break;
1446-
}
1447-
}
1413+
zval argv[3];
1414+
zval retval;
1415+
int error;
1416+
zend_fcall_info fci;
1417+
1418+
GC_ADDREF(&ch->std);
1419+
ZVAL_OBJ(&argv[0], &ch->std);
1420+
ZVAL_STRING(&argv[1], pattern);
1421+
ZVAL_STRING(&argv[2], string);
1422+
1423+
fci.size = sizeof(fci);
1424+
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
1425+
fci.object = NULL;
1426+
fci.retval = &retval;
1427+
fci.param_count = 3;
1428+
fci.params = argv;
1429+
fci.named_params = NULL;
1430+
1431+
ch->in_callback = 1;
1432+
error = zend_call_function(&fci, &t->fci_cache);
1433+
ch->in_callback = 0;
1434+
if (error == FAILURE) {
1435+
php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_FNMATCH_FUNCTION");
1436+
} else if (!Z_ISUNDEF(retval)) {
1437+
_php_curl_verify_handlers(ch, 1);
1438+
rval = zval_get_long(&retval);
1439+
}
1440+
zval_ptr_dtor(&argv[0]);
1441+
zval_ptr_dtor(&argv[1]);
1442+
zval_ptr_dtor(&argv[2]);
14481443
return rval;
14491444
}
14501445
/* }}} */
@@ -1461,43 +1456,38 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
14611456
fprintf(stderr, "clientp = %x, dltotal = %f, dlnow = %f, ultotal = %f, ulnow = %f\n", clientp, dltotal, dlnow, ultotal, ulnow);
14621457
#endif
14631458

1464-
switch (t->method) {
1465-
case PHP_CURL_USER: {
1466-
zval argv[5];
1467-
zval retval;
1468-
int error;
1469-
zend_fcall_info fci;
1470-
1471-
GC_ADDREF(&ch->std);
1472-
ZVAL_OBJ(&argv[0], &ch->std);
1473-
ZVAL_LONG(&argv[1], (zend_long)dltotal);
1474-
ZVAL_LONG(&argv[2], (zend_long)dlnow);
1475-
ZVAL_LONG(&argv[3], (zend_long)ultotal);
1476-
ZVAL_LONG(&argv[4], (zend_long)ulnow);
1477-
1478-
fci.size = sizeof(fci);
1479-
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
1480-
fci.object = NULL;
1481-
fci.retval = &retval;
1482-
fci.param_count = 5;
1483-
fci.params = argv;
1484-
fci.named_params = NULL;
1485-
1486-
ch->in_callback = 1;
1487-
error = zend_call_function(&fci, &t->fci_cache);
1488-
ch->in_callback = 0;
1489-
if (error == FAILURE) {
1490-
php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION");
1491-
} else if (!Z_ISUNDEF(retval)) {
1492-
_php_curl_verify_handlers(ch, 1);
1493-
if (0 != zval_get_long(&retval)) {
1494-
rval = 1;
1495-
}
1496-
}
1497-
zval_ptr_dtor(&argv[0]);
1498-
break;
1499-
}
1500-
}
1459+
zval argv[5];
1460+
zval retval;
1461+
int error;
1462+
zend_fcall_info fci;
1463+
1464+
GC_ADDREF(&ch->std);
1465+
ZVAL_OBJ(&argv[0], &ch->std);
1466+
ZVAL_LONG(&argv[1], (zend_long)dltotal);
1467+
ZVAL_LONG(&argv[2], (zend_long)dlnow);
1468+
ZVAL_LONG(&argv[3], (zend_long)ultotal);
1469+
ZVAL_LONG(&argv[4], (zend_long)ulnow);
1470+
1471+
fci.size = sizeof(fci);
1472+
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
1473+
fci.object = NULL;
1474+
fci.retval = &retval;
1475+
fci.param_count = 5;
1476+
fci.params = argv;
1477+
fci.named_params = NULL;
1478+
1479+
ch->in_callback = 1;
1480+
error = zend_call_function(&fci, &t->fci_cache);
1481+
ch->in_callback = 0;
1482+
if (error == FAILURE) {
1483+
php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION");
1484+
} else if (!Z_ISUNDEF(retval)) {
1485+
_php_curl_verify_handlers(ch, 1);
1486+
if (0 != zval_get_long(&retval)) {
1487+
rval = 1;
1488+
}
1489+
}
1490+
zval_ptr_dtor(&argv[0]);
15011491
return rval;
15021492
}
15031493
/* }}} */
@@ -1924,7 +1914,6 @@ void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source)
19241914
if (!Z_ISUNDEF(source->handlers.progress->func_name)) {
19251915
ZVAL_COPY(&ch->handlers.progress->func_name, &source->handlers.progress->func_name);
19261916
}
1927-
ch->handlers.progress->method = source->handlers.progress->method;
19281917
curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, (void *) ch);
19291918
}
19301919

@@ -1933,7 +1922,6 @@ void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source)
19331922
if (!Z_ISUNDEF(source->handlers.fnmatch->func_name)) {
19341923
ZVAL_COPY(&ch->handlers.fnmatch->func_name, &source->handlers.fnmatch->func_name);
19351924
}
1936-
ch->handlers.fnmatch->method = source->handlers.fnmatch->method;
19371925
curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_DATA, (void *) ch);
19381926
}
19391927

@@ -2740,7 +2728,6 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
27402728
ch->handlers.progress->fci_cache = empty_fcall_info_cache;
27412729
}
27422730
ZVAL_COPY(&ch->handlers.progress->func_name, zvalue);
2743-
ch->handlers.progress->method = PHP_CURL_USER;
27442731
break;
27452732

27462733
case CURLOPT_READFUNCTION:
@@ -2849,7 +2836,6 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
28492836
ch->handlers.fnmatch->fci_cache = empty_fcall_info_cache;
28502837
}
28512838
ZVAL_COPY(&ch->handlers.fnmatch->func_name, zvalue);
2852-
ch->handlers.fnmatch->method = PHP_CURL_USER;
28532839
break;
28542840

28552841
default:

ext/curl/multi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ static int _php_curl_multi_setopt(php_curlm *mh, zend_long option, zval *zvalue,
466466
}
467467

468468
ZVAL_COPY(&mh->handlers.server_push->func_name, zvalue);
469-
mh->handlers.server_push->method = PHP_CURL_USER;
470469
error = curl_multi_setopt(mh->multi, option, _php_server_push_callback);
471470
if (error != CURLM_OK) {
472471
return 0;

0 commit comments

Comments
 (0)