Skip to content

Commit 05fb089

Browse files
committed
ext/mysqli: Deprecate passing the parameter to mysqli_store_result()
And deprecate the MYSQLI_STORE_RESULT_COPY_DATA constant. RFC: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_the_second_parameter_to_mysqli_store_result
1 parent 46ee0fb commit 05fb089

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

ext/mysqli/mysqli.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
/**
139139
* @var int
140140
* @cvalue MYSQLI_STORE_RESULT_COPY_DATA
141+
* @deprecated
141142
*/
142143
const MYSQLI_STORE_RESULT_COPY_DATA = UNKNOWN;
143144

ext/mysqli/mysqli_api.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,14 @@ PHP_FUNCTION(mysqli_store_result)
19571957
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|l", &mysql_link, mysqli_link_class_entry, &flags) == FAILURE) {
19581958
RETURN_THROWS();
19591959
}
1960+
1961+
if (hasThis() && ZEND_NUM_ARGS() == 1 || ZEND_NUM_ARGS() == 2) {
1962+
zend_error(E_DEPRECATED, "Passing the $mode parameter is deprecated since 8.4, as it has been ignored since 8.1");
1963+
if (UNEXPECTED(EG(exception))) {
1964+
RETURN_THROWS();
1965+
}
1966+
}
1967+
19601968
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
19611969
result = mysql_store_result(mysql->mysql);
19621970
if (!result) {

ext/mysqli/tests/mysqli_store_result_buffered_c.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require_once 'skipifconnectfailure.inc';
1313
if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
1414
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
1515

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

ext/mysqli/tests/mysqli_store_result_copy.phpt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mysqlnd.fetch_data_copy=0
1818
if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
1919
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
2020

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

@@ -48,7 +48,7 @@ mysqlnd.fetch_data_copy=0
4848
if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
4949
printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
5050

51-
if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
51+
if (!is_object($res = mysqli_store_result($link)))
5252
printf("[009] Expecting object, got %s/%s. [%d] %s\n",
5353
gettype($res), $res, mysqli_errno($link), mysqli_error($link));
5454

@@ -86,7 +86,7 @@ mysqlnd.fetch_data_copy=0
8686
if (!$res = mysqli_real_query($link, "SELECT CONCAT(id, id) AS _c, label FROM test ORDER BY id DESC LIMIT 2"))
8787
printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
8888

89-
if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
89+
if (!is_object($res = mysqli_store_result($link)))
9090
printf("[013] Expecting object, got %s/%s. [%d] %s\n",
9191
gettype($res), $res, mysqli_errno($link), mysqli_error($link));
9292

@@ -113,7 +113,7 @@ mysqlnd.fetch_data_copy=0
113113
if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2"))
114114
printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
115115

116-
if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
116+
if (!is_object($res = mysqli_store_result($link)))
117117
printf("[016] Expecting object, got %s/%s. [%d] %s\n",
118118
gettype($res), $res, mysqli_errno($link), mysqli_error($link));
119119

@@ -124,7 +124,7 @@ mysqlnd.fetch_data_copy=0
124124
if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id DESC LIMIT 2"))
125125
printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
126126

127-
if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
127+
if (!is_object($res = mysqli_store_result($link)))
128128
printf("[018] Expecting object, got %s/%s. [%d] %s\n",
129129
gettype($res), $res, mysqli_errno($link), mysqli_error($link));
130130

@@ -137,7 +137,7 @@ mysqlnd.fetch_data_copy=0
137137
if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 2"))
138138
printf("[020] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
139139

140-
if (!is_object($res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA)))
140+
if (!is_object($res = mysqli_store_result($link)))
141141
printf("[021] Expecting object, got %s/%s. [%d] %s\n",
142142
gettype($res), $res, mysqli_errno($link), mysqli_error($link));
143143

@@ -154,7 +154,7 @@ mysqlnd.fetch_data_copy=0
154154
if (!$res = mysqli_real_query($link, "INSERT INTO test(id, label) VALUES (100, 'z')"))
155155
printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
156156

157-
mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA);
157+
mysqli_store_result($link);
158158

159159
if (mysqli_get_server_version($link) > 50000) {
160160
// let's try to play with stored procedures
@@ -163,7 +163,7 @@ mysqlnd.fetch_data_copy=0
163163
END;')) {
164164
mysqli_multi_query($link, "CALL p(@version)");
165165
do {
166-
if ($res = $link->store_result(MYSQLI_STORE_RESULT_COPY_DATA)) {
166+
if ($res = $link->store_result()) {
167167
printf("---\n");
168168
var_dump($res->fetch_all());
169169
$res->free();
@@ -174,7 +174,7 @@ END;')) {
174174
}
175175
} while ($link->more_results() && $link->next_result());
176176
mysqli_real_query($link, 'SELECT @version AS p_version');
177-
$res = mysqli_store_result($link, MYSQLI_STORE_RESULT_COPY_DATA);
177+
$res = mysqli_store_result($link);
178178

179179
$tmp = mysqli_fetch_assoc($res);
180180
if (!is_array($tmp) || empty($tmp) || !isset($tmp['p_version']) || ('' == $tmp['p_version'])) {

0 commit comments

Comments
 (0)