Skip to content
Open
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
4 changes: 4 additions & 0 deletions ext/mysqli/mysqli_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,10 @@ PHP_FUNCTION(mysqli_options)
convert_to_long(mysql_value);
break;
default:
if (MyG(report_mode) & MYSQLI_REPORT_ERROR) {
zend_value_error("mysqli_options(): Invalid option %d", (int)mysql_option);
}
ret = 1;
break;
}
}
Expand Down
36 changes: 36 additions & 0 deletions ext/mysqli/tests/gh20968.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
Bug #20968 mysqli_options() with invalid option triggers ValueError
--EXTENSIONS--
mysqli
--CONFLICTS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';

$driver = new mysqli_driver();

$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);

$driver->report_mode = MYSQLI_REPORT_OFF;
$value = $mysqli->options(10, 'invalid_option');

var_dump($value);

$driver->report_mode = MYSQLI_REPORT_ALL;
$value = $mysqli->options(10, 'invalid_option');
var_dump($value);

?>
--EXPECTF--
bool(false)

Fatal error: Uncaught ValueError: mysqli_options(): Invalid option %d in %s:%d
Stack trace:
#0 %s(%d): mysqli->options(%d, 'invalid_option')
#1 {main}
thrown in %s on line %d
2 changes: 0 additions & 2 deletions ext/mysqli/tests/mysqli_options.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ try {
echo $e->getMessage() . "\n";
}

// invalid options do not generate errors
mysqli_options($link, -1, "Invalid option");

print "done!";
?>
Expand Down
Loading