Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 3 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ PHP NEWS
. Passing objects to mb_convert_variables() is now deprecated. (Girgias)

- MySQLi:
. The mysqli_get_charset() function is now deprecated. (Kamil Tekiela)
. The mysqli_get_charset() function and mysqli::get_charset() method is now deprecated. (Kamil Tekiela)
Comment thread
kamil-tekiela marked this conversation as resolved.
Outdated
. The mysqli_stmt_init() function and mysqli::stmt_init() method are now deprecated. (Kamil Tekiela)
. Instantiation of mysqli_stmt without providing the $query parameter is now deprecated. (Kamil Tekiela)

- PDO:
. Fixed pdo_raise_impl_error() emitting a warning under ERRMODE_SILENT.
Expand Down
5 changes: 4 additions & 1 deletion UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,11 @@ PHP 8.6 UPGRADE NOTES
RFC: https://wiki.php.net/rfc/deprecations_php_8_6#passing_objects_for_vars_parameter_of_mb_convert_variables

- MySQLi:
. The mysqli_get_charset() function is now deprecated.
. The mysqli_get_charset() function and mysqli::get_charset() method are now deprecated.
RFC: https://wiki.php.net/rfc/deprecations_php_8_6#deprecate_mysqli_get_charset
. The mysqli_stmt_init() function, mysqli::stmt_init() method, and calling mysqli_stmt constructor
without providing the $query parameter are now deprecated.
RFC: https://wiki.php.net/rfc/deprecations_php_8_6#deprecate_mysqlistmt_init

- SPL:
. The spl_classes() function is now deprecated, use
Expand Down
2 changes: 2 additions & 0 deletions ext/mysqli/mysqli.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,8 @@ PHP_METHOD(mysqli_stmt, __construct)
RETURN_FALSE;
}
mysqli_resource->status = MYSQLI_STATUS_VALID;
} else {
zend_error(E_DEPRECATED, "Instantiation of mysqli_stmt without providing the $query parameter is deprecated");
}
}

Expand Down
2 changes: 2 additions & 0 deletions ext/mysqli/mysqli.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ public function stat(): string|false {}
* @tentative-return-type
* @alias mysqli_stmt_init
*/
#[\Deprecated(since: '8.6', message: 'use mysqli::prepare() instead')]
public function stmt_init(): mysqli_stmt|false {}

/**
Expand Down Expand Up @@ -1610,6 +1611,7 @@ function mysqli_stmt_get_result(mysqli_stmt $statement): mysqli_result|false {}
function mysqli_stmt_get_warnings(mysqli_stmt $statement): mysqli_warning|false {}

/** @refcount 1 */
#[\Deprecated(since: '8.6', message: 'use mysqli_prepare() instead')]
function mysqli_stmt_init(mysqli $mysql): mysqli_stmt|false {}

/** @refcount 1 */
Expand Down
20 changes: 17 additions & 3 deletions ext/mysqli/mysqli_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions ext/mysqli/tests/bug38710.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ require_once 'skipifconnectfailure.inc';
require_once 'connect.inc';

$db = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$qry=$db->stmt_init();
$qry->prepare("SELECT REPEAT('a',100000)");
$qry=$db->prepare("SELECT REPEAT('a',100000)");
$qry->execute();
$qry->bind_result($text);
$qry->fetch();
Expand Down
10 changes: 2 additions & 8 deletions ext/mysqli/tests/bug42378.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,17 @@ memory_limit=83886080

function test_format($link, $format, $from, $order_by, $expected, $offset) {

if (!$stmt = mysqli_stmt_init($link)) {
printf("[%03d] Cannot create PS, [%d] %s\n",
$offset,
mysqli_errno($link), mysqli_error($link));
return false;
}
print "$format\n";

if ($order_by)
$sql = sprintf('SELECT %s AS _format FROM %s ORDER BY %s', $format, $from, $order_by);
else
$sql = sprintf('SELECT %s AS _format FROM %s', $format, $from);

if (!mysqli_stmt_prepare($stmt, $sql)) {
if (!$stmt = mysqli_prepare($link, $sql)) {
printf("[%03d] Cannot prepare PS, [%d] %s\n",
$offset + 1,
mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
mysqli_errno($link), mysqli_error($link));
return false;
}

Expand Down
5 changes: 2 additions & 3 deletions ext/mysqli/tests/bug55653.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ require_once 'skipifconnectfailure.inc';

$in_and_out = "a";

if (!($stmt = $link->stmt_init()))
if (!($stmt = $link->prepare("SELECT ?")))
printf("[002] [%d] %s\n", $link->errno, $link->error);

if (!($stmt->prepare("SELECT ?")) ||
!($stmt->bind_param("s", $in_and_out)) ||
if (!($stmt->bind_param("s", $in_and_out)) ||
!($stmt->execute()) ||
!($stmt->bind_result($in_and_out)))
printf("[003] [%d] %s\n", $stmt->errno, $stmt->error);
Expand Down
33 changes: 4 additions & 29 deletions ext/mysqli/tests/bug66043.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Bug #66043 (Segfault calling bind_param() on mysqli)
Bug #66043 (Segfault calling bind_param() on mysqli) - Calling mysql_stmt::bind_result() without storing it's result value in a variable is causing a segfault.
--EXTENSIONS--
mysqli
--SKIPIF--
Expand All @@ -9,38 +9,13 @@ require_once 'skipifconnectfailure.inc';
--FILE--
<?php
require 'connect.inc';
if (!$db = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
}

if (!$db->query("DROP TABLE IF EXISTS test")) {
printf("[002] [%d] %s\n", mysqli_errno($db), mysqli_error($db));
die();
}

if (!$db->query("CREATE TABLE test(str TEXT)")) {
printf("[003] [%d] %s\n", mysqli_errno($db), mysqli_error($db));
die();
}

if (!$db->query("INSERT INTO test(str) VALUES ('Test')")) {
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
die();
}

$stmt = $db->stmt_init();
if (!$stmt->prepare("SELECT str FROM test")) {
printf("[004] [%d] %s\n", mysqli_errno($db), mysqli_error($db));
die();
}
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$db = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);

$stmt = $db->prepare("SELECT 'Test'");
$stmt->execute();
$stmt->bind_result($testArg);
echo "Okey";
?>
--CLEAN--
<?php
require_once 'clean_table.inc';
?>
--EXPECT--
Okey
1 change: 1 addition & 0 deletions ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ printf("stmt->unknown = '%s'\n", @$stmt->unknown);
print "done!";
?>
--EXPECTF--
Deprecated: Instantiation of mysqli_stmt without providing the $query parameter is deprecated in %s on line %d
Parent class:
bool(false)

Expand Down
5 changes: 2 additions & 3 deletions ext/mysqli/tests/mysqli_explain_metadata.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ require_once 'skipifconnectfailure.inc';

mysqli_free_result($res);

$stmt = mysqli_stmt_init($link);
/* Depending on your version, the MySQL server migit not support this */
if ($stmt->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2') && $stmt->execute()) {
/* Depending on your version, the MySQL server might not support this */
if (($stmt = $link->prepare('EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2')) && $stmt->execute()) {
if (!mysqli_stmt_store_result($stmt))
printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));

Expand Down
9 changes: 4 additions & 5 deletions ext/mysqli/tests/mysqli_get_client_stats.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,12 @@ mysqli.allow_local_infile=1
mysqli_get_client_stats_assert_eq('flushed_normal_sets', $info, $expected, $test_counter);

print "Testing buffered Prepared Statements...\n";
if (!$stmt = mysqli_stmt_init($link))
printf("[%03d] stmt_init() failed, [%d] %s\n",
if (!$stmt = mysqli_prepare($link, 'SELECT id, label FROM test'))
printf("[%03d] mysqli_prepare() failed, [%d] %s\n",
++$test_counter, mysqli_errno($link), mysqli_error($link));

if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
!mysqli_stmt_execute($stmt))
printf("[%03d] prepare/execute failed, [%d] %s\n",
if (!mysqli_stmt_execute($stmt))
printf("[%03d] mysqli_stmt_execute() failed, [%d] %s\n",
++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));

/* by default PS is unbuffered - no change */
Expand Down
5 changes: 2 additions & 3 deletions ext/mysqli/tests/mysqli_get_client_stats_ps.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ mysqlnd.collect_memory_statistics=1
printf("BEGINNING: rows_fetched_from_client_ps_buffered = %d\n", $stats['rows_fetched_from_client_ps_buffered']);
printf("BEGINNING: rows_fetched_from_client_ps_cursor = %d\n", $stats['rows_fetched_from_client_ps_cursor']);

if (!$stmt = mysqli_stmt_init($link))
if (!$stmt = mysqli_prepare($link, 'SELECT id FROM test'))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

$id = null;
if (!mysqli_stmt_prepare($stmt, 'SELECT id FROM test') ||
!mysqli_stmt_execute($stmt) ||
if (!mysqli_stmt_execute($stmt) ||
!mysqli_stmt_store_result($stmt) ||
!mysqli_stmt_bind_result($stmt, $id))
printf("[002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
Expand Down
33 changes: 14 additions & 19 deletions ext/mysqli/tests/mysqli_report.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ require_once 'skipifconnectfailure.inc';
*/
mysqli_report(MYSQLI_REPORT_ERROR);

$stmt = mysqli_prepare($link, "DO 1");
mysqli_multi_query($link, "BAR; FOO;");
mysqli_query($link, "FOO");
try {
Expand All @@ -51,7 +52,6 @@ require_once 'skipifconnectfailure.inc';
mysqli_autocommit($link, true);
mysqli_commit($link);
mysqli_rollback($link);
$stmt = mysqli_stmt_init($link);
mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
while(mysqli_more_results($link)) {
mysqli_next_result($link);
Expand All @@ -63,6 +63,7 @@ require_once 'skipifconnectfailure.inc';
// not have been set. If that would be the case, the test would be broken.
mysqli_report(MYSQLI_REPORT_OFF);

$stmt = mysqli_prepare($link, "DO 1");
mysqli_multi_query($link, "BAR; FOO;");
mysqli_query($link, "FOO");
try {
Expand All @@ -78,7 +79,6 @@ require_once 'skipifconnectfailure.inc';
mysqli_autocommit($link, true);
mysqli_commit($link);
mysqli_rollback($link);
$stmt = mysqli_stmt_init($link);
mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
while(mysqli_more_results($link)) {
mysqli_next_result($link);
Expand All @@ -92,11 +92,10 @@ require_once 'skipifconnectfailure.inc';

mysqli_report(MYSQLI_REPORT_ERROR);

$stmt = mysqli_stmt_init($link);
$stmt = mysqli_prepare($link, "DO 1");
mysqli_stmt_prepare($stmt, "FOO");

$stmt = mysqli_stmt_init($link);
mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
$stmt = mysqli_prepare($link, "SELECT id FROM test WHERE id > ?");
$id = 1;
mysqli_kill($link, mysqli_thread_id($link));
mysqli_stmt_bind_param($stmt, "i", $id);
Expand All @@ -106,11 +105,10 @@ require_once 'skipifconnectfailure.inc';
/* mysqli_stmt_execute() = mysql_stmt_execute cannot be tested from PHP */
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[008] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
$stmt = mysqli_stmt_init($link);
mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
$stmt = mysqli_prepare($link, "SELECT id FROM test WHERE id > ?");
$id = 1;
mysqli_stmt_bind_param($stmt, "i", $id);
// mysqli_kill($link, mysqli_thread_id($link));
mysqli_kill($link, mysqli_thread_id($link));
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
mysqli_close($link);
Expand All @@ -126,11 +124,10 @@ require_once 'skipifconnectfailure.inc';

if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[010] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
$stmt = mysqli_stmt_init($link);
$stmt = mysqli_prepare($link, "DO 1");
mysqli_stmt_prepare($stmt, "FOO");

$stmt = mysqli_stmt_init($link);
mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
$stmt = mysqli_prepare($link, "SELECT id FROM test WHERE id > ?");
$id = 1;
mysqli_kill($link, mysqli_thread_id($link));
mysqli_stmt_bind_param($stmt, "i", $id);
Expand All @@ -139,8 +136,7 @@ require_once 'skipifconnectfailure.inc';

if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[011] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
$stmt = mysqli_stmt_init($link);
mysqli_stmt_prepare($stmt, "SELECT id FROM test WHERE id > ?");
$stmt = mysqli_prepare($link, "SELECT id FROM test WHERE id > ?");
$id = 1;
mysqli_stmt_bind_param($stmt, "i", $id);
mysqli_kill($link, mysqli_thread_id($link));
Expand Down Expand Up @@ -257,7 +253,7 @@ require_once 'skipifconnectfailure.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[024] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());

if (!$stmt = mysqli_stmt_init($link))
if (!$stmt = mysqli_prepare($link, 'SELECT id * 3 FROM test'))
printf("[025] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test'))
Expand All @@ -284,11 +280,6 @@ require_once 'skipifconnectfailure.inc';

mysqli_free_result($res);

if (!$stmt = mysqli_prepare($link, 'SELECT id * 3 FROM test'))
printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
else
mysqli_stmt_close($stmt);

if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'z')", MYSQLI_USE_RESULT) ||
!mysqli_query($link, 'DELETE FROM test WHERE id > 50', MYSQLI_USE_RESULT))
printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
Expand Down Expand Up @@ -333,6 +324,10 @@ Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/

Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s

Warning: mysqli_stmt_execute(): (HY000/2006): MySQL server has gone away in %s on line %d

Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s

Deprecated: Function mysqli_kill() is deprecated since 8.4, use KILL CONNECTION/QUERY SQL statement instead in %s
[013] Access denied for user '%s'@'%s'%r( \(using password: \w+\)){0,1}%r
[016] Access denied for user '%s'@'%s'%r( \(using password: \w+\)){0,1}%r
Expand Down
Loading
Loading