Skip to content

Deprecate mysqli_ping #11945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2024
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
2 changes: 2 additions & 0 deletions ext/mysqli/mysqli.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ public function next_result(): bool {}
* @tentative-return-type
* @alias mysqli_ping
*/
#[\Deprecated(since: '8.4', message: 'because the reconnect feature has been removed in PHP 8.2 and this method is now redundant')]
public function ping(): bool {}

/**
Expand Down Expand Up @@ -1526,6 +1527,7 @@ function mysqli_options(mysqli $mysql, int $option, $value): bool {}
*/
function mysqli_set_opt(mysqli $mysql, int $option, $value): bool {}

#[\Deprecated(since: '8.4', message: 'because the reconnect feature has been removed in PHP 8.2 and this function is now redundant')]
function mysqli_ping(mysqli $mysql): bool {}

function mysqli_poll(?array &$read, ?array &$error, array &$reject, int $seconds, int $microseconds = 0): int|false {}
Expand Down
30 changes: 27 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.

4 changes: 3 additions & 1 deletion ext/mysqli/tests/070.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ require_once 'skipifconnectfailure.inc';
$mysql->close();
print "done!";
?>
--EXPECT--
--EXPECTF--

Deprecated: Method mysqli::ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this method is now redundant in %s
bool(true)
done!
8 changes: 4 additions & 4 deletions ext/mysqli/tests/071.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ require_once 'skipifconnectfailure.inc';
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$version = $mysql->server_version;

var_dump($mysql->ping());
var_dump($mysql->query('DO 1'));

$ret = $mysql->kill($mysql->thread_id);
if ($ret !== true){
printf("[001] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true));
}

var_dump($mysql->ping());
var_dump($mysql->query('DO 1'));

$mysql->close();

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

var_dump(mysqli_ping($mysql));
var_dump($mysql->query('DO 1'));

$ret = $mysql->kill($mysql->thread_id);
if ($ret !== true){
printf("[002] Expecting boolean/true got %s/%s\n", gettype($ret), var_export($ret, true));
}

var_dump(mysqli_ping($mysql));
var_dump($mysql->query('DO 1'));

$mysql->close();
print "done!";
Expand Down
3 changes: 2 additions & 1 deletion ext/mysqli/tests/mysqli_insert_id_variation.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,6 @@ if (!mysqli_query($link, "DROP TABLE IF EXISTS test_insert_id_var"))

mysqli_close($link);
?>
--EXPECT--
--EXPECTF--
Deprecated: Method mysqli::ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this method is now redundant in %s
DONE
2 changes: 1 addition & 1 deletion ext/mysqli/tests/mysqli_max_links.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mysqli.max_links=1
require_once 'table.inc';

// to make sure we have at least one working connection...
var_dump(mysqli_ping($link));
var_dump($link->query('DO 1'));
// to make sure that max_links is really set to one
var_dump((int)ini_get('mysqli.max_links'));

Expand Down
8 changes: 7 additions & 1 deletion ext/mysqli/tests/mysqli_ping.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ require_once 'skipifconnectfailure.inc';

print "done!";
?>
--EXPECT--
--EXPECTF--

Deprecated: Function mysqli_ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this function is now redundant in %s
bool(true)

Deprecated: Function mysqli_ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this function is now redundant in %s
bool(true)

Deprecated: Function mysqli_ping() is deprecated since 8.4, because the reconnect feature has been removed in PHP 8.2 and this function is now redundant in %s
mysqli object is already closed
done!
1 change: 0 additions & 1 deletion ext/mysqli/tests/mysqli_report.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ require_once 'skipifconnectfailure.inc';
echo $e->getMessage() . \PHP_EOL;
}

// mysqli_ping() cannot be tested, because one would need to cause an error inside the C function to test it
mysqli_prepare($link, "FOO");
mysqli_real_query($link, "FOO");
if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name"))
Expand Down
1 change: 0 additions & 1 deletion ext/mysqli/tests/mysqli_report_wo_ps.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ if (mysqli_get_server_version($link) >= 50600)
echo $e->getMessage() . \PHP_EOL;
}

// mysqli_ping() cannot be tested, because one would need to cause an error inside the C function to test it
mysqli_real_query($link, "FOO");
if (@mysqli_select_db($link, "Oh lord, let this be an unknown database name"))
printf("[009] select_db should have failed\n");
Expand Down
Loading