Skip to content

Commit 3b5495e

Browse files
committed
Maybe it's attr_get() messing stuff
1 parent 2f6ce47 commit 3b5495e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ext/mysqli/mysqli_api.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,20 +2319,18 @@ PHP_FUNCTION(mysqli_stmt_attr_get)
23192319
zval *mysql_stmt;
23202320
unsigned long value = 0;
23212321
zend_long attr;
2322+
int rc;
23222323

23232324
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &mysql_stmt, mysqli_stmt_class_entry, &attr) == FAILURE) {
23242325
RETURN_THROWS();
23252326
}
23262327
MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
23272328

2328-
switch (attr) {
2329+
if (attr != STMT_ATTR_CURSOR_TYPE && attr != STMT_ATTR_PREFETCH_ROWS
23292330
#if MYSQL_VERSION_ID >= 50107
2330-
case STMT_ATTR_UPDATE_MAX_LENGTH:
2331+
&& attr != STMT_ATTR_UPDATE_MAX_LENGTH
23312332
#endif
2332-
case STMT_ATTR_CURSOR_TYPE:
2333-
case STMT_ATTR_PREFETCH_ROWS:
2334-
break;
2335-
default:
2333+
) {
23362334
zend_argument_value_error(ERROR_ARG_POS(2), "must be one of "
23372335
#if MYSQL_VERSION_ID >= 50107
23382336
"MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, "
@@ -2341,9 +2339,12 @@ PHP_FUNCTION(mysqli_stmt_attr_get)
23412339
RETURN_THROWS();
23422340
}
23432341

2344-
/* Success corresponds to 0 return value and a non-zero value
2345-
* should only happen if the attr/option is unknown */
2346-
ZEND_ASSERT(mysql_stmt_attr_get(stmt->stmt, attr, &value) == 0);
2342+
if ((rc = mysql_stmt_attr_get(stmt->stmt, attr, &value))) {
2343+
/* Success corresponds to 0 return value and a non-zero value
2344+
* should only happen if the attr/option is unknown */
2345+
ZEND_UNREACHABLE();
2346+
}
2347+
23472348

23482349
#if MYSQL_VERSION_ID >= 50107
23492350
if (attr == STMT_ATTR_UPDATE_MAX_LENGTH)

0 commit comments

Comments
 (0)