Skip to content

ext/mysqli: Deprecate passing the parameter to mysqli_store_result() #15311

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 4 commits into from
Aug 11, 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
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ PHP NEWS
. The mysqli_refresh() function and mysqli::refresh() method are now deprecated.
If this functionality is needed a SQL "FLUSH" command can be used instead.
(Kamil Tekiela)
. Passing explicitly the $mode parameter to mysqli_store_result() has been
deprecated. As the MYSQLI_STORE_RESULT_COPY_DATA constant was only used in
conjunction with this function it has also been deprecated. (Girgias)

- PHPDBG:
. array out of bounds, stack overflow handled for segfault handler on windows.
Expand Down
4 changes: 4 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ PHP 8.4 UPGRADE NOTES
. The mysqli_refresh() function and mysqli::refresh() method are now deprecated.
If this functionality is needed a SQL "FLUSH" command can be used instead.
RFC: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_mysqli_refresh
. Passing explicitly the $mode parameter to mysqli_store_result() has been
deprecated. As the MYSQLI_STORE_RESULT_COPY_DATA constant was only used in
conjunction with this function it has also been deprecated.
RFC: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_the_second_parameter_to_mysqli_store_result

- PDO_PGSQL:
. Using escaped question marks (??) inside dollar-quoted strings is deprecated.
Expand Down
1 change: 1 addition & 0 deletions ext/mysqli/mysqli.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
/**
* @var int
* @cvalue MYSQLI_STORE_RESULT_COPY_DATA
* @deprecated
*/
const MYSQLI_STORE_RESULT_COPY_DATA = UNKNOWN;

Expand Down
8 changes: 8 additions & 0 deletions ext/mysqli/mysqli_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1957,6 +1957,14 @@ PHP_FUNCTION(mysqli_store_result)
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|l", &mysql_link, mysqli_link_class_entry, &flags) == FAILURE) {
RETURN_THROWS();
}

if ((hasThis() && ZEND_NUM_ARGS() == 1) || ZEND_NUM_ARGS() == 2) {
zend_error(E_DEPRECATED, "Passing the $mode parameter is deprecated since 8.4, as it has been ignored since 8.1");
if (UNEXPECTED(EG(exception))) {
RETURN_THROWS();
}
}

MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
result = mysql_store_result(mysql->mysql);
if (!result) {
Expand Down
2 changes: 1 addition & 1 deletion ext/mysqli/tests/bug77597.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $mysqli->query('INSERT INTO test VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9)');

$mysqli->real_query("SELECT * FROM test");

$result = $mysqli->store_result(MYSQLI_STORE_RESULT_COPY_DATA);
$result = $mysqli->store_result();

$field = $result->fetch_field();
var_dump($field->name);
Expand Down
2 changes: 1 addition & 1 deletion ext/mysqli/tests/mysqli_store_result_buffered_c.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require_once 'skipifconnectfailure.inc';
if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
if (!is_object($res = mysqli_store_result($link)))
printf("[004] Expecting object, got %s/%s. [%d] %s\n",
gettype($res), $res, mysqli_errno($link), mysqli_error($link));

Expand Down
281 changes: 0 additions & 281 deletions ext/mysqli/tests/mysqli_store_result_copy.phpt

This file was deleted.

Loading