ext/pdo_sqlite: PDO::sqliteCreateCollection return type strenghtening.

Is supposed to be Pdo_Sqlite::createCollation but behavior differs in
regard of return type checks.

close GH-18799
This commit is contained in:
David Carlier 2025-06-07 16:35:30 +01:00
parent eac91d0453
commit e3cfa4bcae
No known key found for this signature in database
GPG key ID: 8486F847B4B94EF1
5 changed files with 23 additions and 6 deletions

View file

@ -483,9 +483,16 @@ static int php_sqlite3_collation_callback(void *context, int string1_len, const
zend_call_known_fcc(&collation->callback, &retval, /* argc */ 2, zargs, /* named_params */ NULL);
zval_ptr_dtor(&zargs[0]);
zval_ptr_dtor(&zargs[1]);
if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
convert_to_long(&retval);
zend_string *func_name = get_active_function_or_method_name();
zend_type_error("%s(): Return value of the collation callback must be of type int, %s returned",
ZSTR_VAL(func_name), zend_zval_value_name(&retval));
zend_string_release(func_name);
ret = FAILURE;
}
if (Z_LVAL(retval) > 0) {
ret = 1;
@ -495,9 +502,6 @@ static int php_sqlite3_collation_callback(void *context, int string1_len, const
zval_ptr_dtor(&retval);
}
zval_ptr_dtor(&zargs[0]);
zval_ptr_dtor(&zargs[1]);
return ret;
}