]> granicus.if.org Git - php/commitdiff
Deprecate OO style mysqli::get_client_info method
authorDharman <tekiela246@gmail.com>
Sat, 13 Mar 2021 17:34:33 +0000 (17:34 +0000)
committerDharman <tekiela246@gmail.com>
Wed, 17 Mar 2021 20:10:18 +0000 (20:10 +0000)
Deprecate passing connection object to mysqli_get_client_info()

Closes GH-6777.

UPGRADING
ext/mysqli/mysqli.stub.php
ext/mysqli/mysqli_api.c
ext/mysqli/mysqli_arginfo.h
ext/mysqli/tests/bug36802.phpt
ext/mysqli/tests/mysqli_get_info_deprecations.phpt [new file with mode: 0644]

index 02635f615a8d390f02e64ea38d244a990c5719bc..286735a4e8248fc89a42c7282ee836fa171a29c9 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -223,6 +223,10 @@ PHP 8.1 UPGRADE NOTES
   . The mysqli_driver::$driver_version property has been deprecated. The driver
     version is meaningless as it hasn't been updated in more than a decade. Use
     PHP_VERSION_ID instead.
+  . Calling mysqli::get_client_info in OO style or passing $mysqli argument to
+    mysqli_get_client_info() function has been deprecated. Use
+    mysqli_get_client_info() without any arguments to obtain the client
+    library version information.
 
 ========================================
 5. Changed Functions
index 9956778c6ea6f47db3075325b8b68a02ee8ebaca..5152e7f91142ea01b66eafdacb86001249cc004f 100644 (file)
@@ -136,6 +136,7 @@ class mysqli
     /**
      * @return string|null
      * @alias mysqli_get_client_info
+     * @deprecated 8.1.0
      */
     public function get_client_info() {}
 
index e1abd07135c68e17c842fe1ab63df4d9fac1e1c4..728e785478a01ec0f78b606c8669a11c1ff30354 100644 (file)
@@ -1327,6 +1327,10 @@ PHP_FUNCTION(mysqli_get_client_info)
                if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &mysql_link, mysqli_link_class_entry) == FAILURE) {
                        RETURN_THROWS();
                }
+
+               if (ZEND_NUM_ARGS()) {
+                       php_error_docref(NULL, E_DEPRECATED, "Passing connection object as an argument is deprecated");
+               }
        }
 
        RETURN_STRING(mysql_get_client_info());
index 9c55a6bfc89d9f10b5998df9db5bc907d61abcd1..b607b5ae36fddec531008cd2a9d31c0281cdf76e 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 56499df713b79c1e9efc19cf8be45aa98028172c */
+ * Stub hash: e65b3497e7783d55f3dfd4cd89be65094c59b1d3 */
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_affected_rows, 0, 1, MAY_BE_LONG|MAY_BE_STRING)
        ZEND_ARG_OBJ_INFO(0, mysql, mysqli, 0)
@@ -938,7 +938,7 @@ static const zend_function_entry class_mysqli_methods[] = {
        ZEND_ME_MAPPING(dump_debug_info, mysqli_dump_debug_info, arginfo_class_mysqli_dump_debug_info, ZEND_ACC_PUBLIC)
        ZEND_ME_MAPPING(debug, mysqli_debug, arginfo_class_mysqli_debug, ZEND_ACC_PUBLIC)
        ZEND_ME_MAPPING(get_charset, mysqli_get_charset, arginfo_class_mysqli_get_charset, ZEND_ACC_PUBLIC)
-       ZEND_ME_MAPPING(get_client_info, mysqli_get_client_info, arginfo_class_mysqli_get_client_info, ZEND_ACC_PUBLIC)
+       ZEND_ME_MAPPING(get_client_info, mysqli_get_client_info, arginfo_class_mysqli_get_client_info, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
 #if defined(MYSQLI_USE_MYSQLND)
        ZEND_ME_MAPPING(get_connection_stats, mysqli_get_connection_stats, arginfo_class_mysqli_get_connection_stats, ZEND_ACC_PUBLIC)
 #endif
index 11891158379e539086d7c8f2c2104a3fe1c5f2df..c0bace8aaf6d7e353a337bf29167d9ffc8b1e3e8 100644 (file)
@@ -31,7 +31,7 @@ Bug #36802 (crashes with with mysqli_set_charset())
     }
 
     /* following operations should work */
-    $x[1] = ($mysql->client_version > 0);
+    $x[1] = ($mysql->error);
     $x[2] = $mysql->errno;
 
     $mysql->close();
@@ -43,7 +43,7 @@ mysqli object is not fully initialized
 mysqli object is not fully initialized
 array(2) {
   [1]=>
-  bool(true)
+  string(0) ""
   [2]=>
   int(0)
 }
diff --git a/ext/mysqli/tests/mysqli_get_info_deprecations.phpt b/ext/mysqli/tests/mysqli_get_info_deprecations.phpt
new file mode 100644 (file)
index 0000000..2dbbce0
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+Deprecated messages for mysqli::get_client_info() method
+--SKIPIF--
+<?php
+require_once 'skipif.inc';
+require_once 'skipifconnectfailure.inc';
+?>
+--FILE--
+<?php
+require 'connect.inc';
+
+if (!$mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+    printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+        $host, $user, $db, $port, $socket);
+    exit(1);
+}
+
+printf("client_info = '%s'\n", $mysqli->get_client_info());
+
+printf("client_info = '%s'\n", mysqli_get_client_info($mysqli));
+
+print "done!";
+?>
+--EXPECTF--
+
+Deprecated: Method mysqli::get_client_info() is deprecated in %s
+client_info = '%s'
+
+Deprecated: mysqli_get_client_info(): Passing connection object as an argument is deprecated in %s
+client_info = '%s'
+done!