summaryrefslogtreecommitdiff
path: root/ext/odbc
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-08-24 20:42:29 +0200
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-09-02 11:11:38 +0200
commit3e800e997bddc29cd28924c44846f7d2133a8933 (patch)
treee650686b950164531a16af82642dd52b826fb1d3 /ext/odbc
parentddc2a2d381843e086fc36388981d0b8ba1ea789d (diff)
downloadphp-git-3e800e997bddc29cd28924c44846f7d2133a8933.tar.gz
Move custom type checks to ZPP
Closes GH-6034
Diffstat (limited to 'ext/odbc')
-rw-r--r--ext/odbc/odbc.stub.php7
-rw-r--r--ext/odbc/odbc_arginfo.h4
-rw-r--r--ext/odbc/php_odbc.c24
3 files changed, 16 insertions, 19 deletions
diff --git a/ext/odbc/odbc.stub.php b/ext/odbc/odbc.stub.php
index 89371024eb..cb318f7ac9 100644
--- a/ext/odbc/odbc.stub.php
+++ b/ext/odbc/odbc.stub.php
@@ -57,11 +57,8 @@ function odbc_fetch_into($result_id, &$result_array, int $rownumber = 0): int|fa
/** @param resource $result_id */
function odbc_fetch_row($result_id, int $row_number = UNKNOWN): bool {}
-/**
- * @param resource $result_id
- * @param string|int $field
- */
-function odbc_result($result_id, $field): string|bool|null {}
+/** @param resource $result_id */
+function odbc_result($result_id, string|int $field): string|bool|null {}
/** @param resource $result_id */
function odbc_result_all($result_id, string $format = ''): int|false {}
diff --git a/ext/odbc/odbc_arginfo.h b/ext/odbc/odbc_arginfo.h
index 2f5ffbe547..778ab242a0 100644
--- a/ext/odbc/odbc_arginfo.h
+++ b/ext/odbc/odbc_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 14702a5bd87902871d456de2289f4ae236e5bfa5 */
+ * Stub hash: cf17952d8c3b88f218bbb8d1c21ba40079574c04 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_close_all, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
@@ -70,7 +70,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_result, 0, 2, MAY_BE_STRING|MAY_BE_BOOL|MAY_BE_NULL)
ZEND_ARG_INFO(0, result_id)
- ZEND_ARG_INFO(0, field)
+ ZEND_ARG_TYPE_MASK(0, field, MAY_BE_STRING|MAY_BE_LONG, NULL)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_result_all, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 7a4495f0d1..af62ecb29d 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -1736,31 +1736,31 @@ PHP_FUNCTION(odbc_fetch_row)
PHP_FUNCTION(odbc_result)
{
char *field;
- zend_string *field_str;
+ zend_string *field_str, *pv_field_str;
+ zend_long pv_field_long;
int field_ind;
SQLSMALLINT sql_c_type = SQL_C_CHAR;
odbc_result *result;
int i = 0;
RETCODE rc;
SQLLEN fieldsize;
- zval *pv_res, *pv_field;
+ zval *pv_res;
#ifdef HAVE_SQL_EXTENDED_FETCH
SQLULEN crow;
SQLUSMALLINT RowStatus[1];
#endif
- field_ind = -1;
- field = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz", &pv_res, &pv_field) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_RESOURCE(pv_res)
+ Z_PARAM_STR_OR_LONG(pv_field_str, pv_field_long)
+ ZEND_PARSE_PARAMETERS_END();
- if (Z_TYPE_P(pv_field) == IS_STRING) {
- field = Z_STRVAL_P(pv_field);
+ if (pv_field_str) {
+ field = ZSTR_VAL(pv_field_str);
+ field_ind = -1;
} else {
- convert_to_long_ex(pv_field);
- field_ind = Z_LVAL_P(pv_field) - 1;
+ field = NULL;
+ field_ind = (int) pv_field_long - 1;
}
if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {