Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions ext/odbc/php_odbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1342,12 +1342,11 @@ static void php_odbc_fetch(INTERNAL_FUNCTION_PARAMETERS, bool return_array, php_
result = Z_ODBC_RESULT_P(pv_res);
CHECK_ODBC_RESULT(result);

/* TODO deprecate $row argument values less than 1 after PHP 8.4
* for functions other than odbc_fetch_row (see GH-13910)
*/
if (!result_type && !pv_row_is_null && pv_row < 1) {
php_error_docref(NULL, E_WARNING, "Argument #3 ($row) must be greater than or equal to 1");
RETURN_FALSE;
if (!pv_row_is_null && pv_row < 1) {
/* row arg no differs between callers */
zend_argument_value_error(pv_res_arr == return_value ? 2 : 3,
"must be greater than or equal to 1");
RETURN_THROWS();
}

if (result->numcols == 0) {
Expand Down
2 changes: 1 addition & 1 deletion ext/odbc/tests/odbc_fetch_array_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ odbc_exec($conn, 'INSERT INTO fetch_array VALUES (1), (2)');
$res = odbc_exec($conn, 'SELECT * FROM fetch_array');

var_dump(odbc_fetch_array($res));
var_dump(odbc_fetch_array($res, 0));
var_dump(odbc_fetch_array($res, null));
var_dump(odbc_fetch_array($res, 2));
var_dump(odbc_fetch_array($res, 4));

Expand Down
2 changes: 1 addition & 1 deletion ext/odbc/tests/odbc_fetch_into_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $arr = [];
var_dump(odbc_fetch_into($res, $arr));
var_dump($arr);
$arr = [];
var_dump(odbc_fetch_into($res, $arr, 0));
var_dump(odbc_fetch_into($res, $arr, null));
var_dump($arr);
$arr = [];
var_dump(odbc_fetch_into($res, $arr, 2));
Expand Down
2 changes: 1 addition & 1 deletion ext/odbc/tests/odbc_fetch_object_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ odbc_exec($conn, 'INSERT INTO fetch_object VALUES (1), (2)');
$res = odbc_exec($conn, 'SELECT * FROM fetch_object');

var_dump(odbc_fetch_object($res));
var_dump(odbc_fetch_object($res, 0));
var_dump(odbc_fetch_object($res, null));
var_dump(odbc_fetch_object($res, 2));
var_dump(odbc_fetch_object($res, 4));

Expand Down
11 changes: 7 additions & 4 deletions ext/odbc/tests/odbc_fetch_row_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ odbc_exec($conn, 'INSERT INTO fetch_row VALUES (1), (2)');

$res = odbc_exec($conn, 'SELECT * FROM fetch_row');

var_dump(odbc_fetch_row($res, 0));
try {
var_dump(odbc_fetch_row($res, 0));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}

var_dump(odbc_fetch_row($res, null));
var_dump(odbc_result($res, 'test'));
Expand All @@ -39,9 +43,8 @@ require 'config.inc';
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, 'DROP TABLE fetch_row');
?>
--EXPECTF--
Warning: odbc_fetch_row(): Argument #3 ($row) must be greater than or equal to 1 in %s on line %d
bool(false)
--EXPECT--
odbc_fetch_row(): Argument #2 ($row) must be greater than or equal to 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice it also fixes the argument number :)

bool(true)
string(1) "1"
bool(true)
Expand Down
Loading