Skip to content

Commit

Permalink
Deprecate mysqli_ping
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-tekiela committed Aug 9, 2024
1 parent bd77462 commit 06a822c
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 13 deletions.
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 @@ -1525,6 +1526,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

0 comments on commit 06a822c

Please sign in to comment.