]> granicus.if.org Git - php/commitdiff
Fixed bug #67348: Reading $dbc->stat modifies $dbc->affected_rows
authorDerick Rethans <github@derickrethans.nl>
Fri, 21 Jun 2019 15:50:40 +0000 (16:50 +0100)
committerDerick Rethans <github@derickrethans.nl>
Fri, 21 Jun 2019 15:51:52 +0000 (16:51 +0100)
NEWS
ext/mysqli/mysqli.c
ext/mysqli/mysqli_prop.c
ext/mysqli/tests/bug34810.phpt
ext/mysqli/tests/bug55859.phpt [deleted file]
ext/mysqli/tests/connect.inc
ext/mysqli/tests/mysqli_class_mysqli_interface.phpt
ext/mysqli/tests/mysqli_class_mysqli_properties_no_conn.phpt
ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt
ext/mysqli/tests/mysqli_kill.phpt
ext/mysqli/tests/mysqli_real_connect.phpt

diff --git a/NEWS b/NEWS
index ef7507d08815d2b8cc3020a220fae9d3ced56b97..cfc7259cd94f2b9249a37a76f4a116f2584bbc30 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,10 @@ PHP                                                                        NEWS
 - GD:
   . Added TGA read support. (cmb)
 
+- MySQLi:
+  . Fixed bug #67348 (Reading $dbc->stat modifies $dbc->affected_rows).
+    (Derick)
+
 - Opcache:
   . Fixed bug #78106 (Path resolution fails if opcache disabled during request).
     (Nikita)
index 1d56c1ab60b6897d67d3bd1729dc74212c112e74..612239527e3c7a582d05867612adbd8a7fad9a0f 100644 (file)
@@ -634,7 +634,6 @@ PHP_MINIT_FUNCTION(mysqli)
        zend_declare_property_null(ce, "insert_id",                     sizeof("insert_id") - 1, ZEND_ACC_PUBLIC);
        zend_declare_property_null(ce, "server_info",           sizeof("server_info") - 1, ZEND_ACC_PUBLIC);
        zend_declare_property_null(ce, "server_version",        sizeof("server_version") - 1, ZEND_ACC_PUBLIC);
-       zend_declare_property_null(ce, "stat",                          sizeof("stat") - 1, ZEND_ACC_PUBLIC);
        zend_declare_property_null(ce, "sqlstate",                      sizeof("sqlstate") - 1, ZEND_ACC_PUBLIC);
        zend_declare_property_null(ce, "protocol_version",      sizeof("protocol_version") - 1,  ZEND_ACC_PUBLIC);
        zend_declare_property_null(ce, "thread_id",                     sizeof("thread_id") - 1, ZEND_ACC_PUBLIC);
index 25985927dc1ccb7b90bcde6ec7fc65bd64a10c24..eab1a0676c9a47af5682ddb4885139516e64b643 100644 (file)
@@ -234,38 +234,6 @@ MYSQLI_MAP_PROPERTY_FUNC_STRING(link_sqlstate_read, mysql_sqlstate, MYSQLI_GET_M
 MYSQLI_MAP_PROPERTY_FUNC_LONG(link_thread_id_read, mysql_thread_id, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
 MYSQLI_MAP_PROPERTY_FUNC_LONG(link_warning_count_read, mysql_warning_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), zend_ulong, ZEND_ULONG_FMT)
 
-/* {{{ property link_stat_read */
-static zval *link_stat_read(mysqli_object *obj, zval *retval)
-{
-       MY_MYSQL *mysql;
-
-       ZVAL_NULL(retval);
-
-#if defined(MYSQLI_USE_MYSQLND)
-       CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
-#else
-       CHECK_STATUS(MYSQLI_STATUS_VALID);
-#endif
-
-       mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
-
-       if (mysql) {
-#if defined(MYSQLI_USE_MYSQLND)
-               zend_string * stat_msg;
-               if (mysqlnd_stat(mysql->mysql, &stat_msg) == PASS) {
-                       ZVAL_STR(retval, stat_msg);
-               }
-#else
-               char * stat_msg;
-               if ((stat_msg = (char *)mysql_stat(mysql->mysql))) {
-                       ZVAL_STRING(retval, stat_msg);
-               }
-#endif
-       }
-       return retval;
-}
-/* }}} */
-
 /* result properties */
 
 /* {{{ property result_type_read */
@@ -435,7 +403,6 @@ const mysqli_property_entry mysqli_link_property_entries[] = {
        {"insert_id",           sizeof("insert_id") - 1,                link_insert_id_read, NULL},
        {"server_info",         sizeof("server_info") - 1,              link_server_info_read, NULL},
        {"server_version",      sizeof("server_version") - 1,   link_server_version_read, NULL},
-       {"stat",                        sizeof("stat") - 1,                             link_stat_read, NULL},
        {"sqlstate",            sizeof("sqlstate") - 1,                 link_sqlstate_read, NULL},
        {"protocol_version",sizeof("protocol_version") - 1,     link_protocol_version_read, NULL},
        {"thread_id",           sizeof("thread_id") - 1,                link_thread_id_read, NULL},
index 7c36d806bca2943687f8965bdcc194f4efb822e0..d9afc246eb6683538c7138dc15abca4a9413d89e 100644 (file)
@@ -92,8 +92,6 @@ object(mysqli)#%d (%d) {
   string(%d) "%s"
   ["server_version"]=>
   int(%d)
-  ["stat"]=>
-  string(%d) "Uptime: %d  Threads: %d  Questions: %d  Slow queries: %d  Opens: %d  Flush tables: %d  Open tables: %d  Queries per second avg: %d.%d"
   ["sqlstate"]=>
   string(5) "00000"
   ["protocol_version"]=>
@@ -132,8 +130,6 @@ object(mysqli)#%d (%d) {
   bool(false)
   ["server_version"]=>
   bool(false)
-  ["stat"]=>
-  NULL
   ["sqlstate"]=>
   bool(false)
   ["protocol_version"]=>
diff --git a/ext/mysqli/tests/bug55859.phpt b/ext/mysqli/tests/bug55859.phpt
deleted file mode 100644 (file)
index 04467bc..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
---TEST--
-Bug #55859 mysqli->stat property access gives error
---SKIPIF--
-<?php
-require_once('skipif.inc');
-require_once('skipifconnectfailure.inc');
-?>
---FILE--
-<?php
-       require_once("connect.inc");
-
-       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
-               printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
-       }
-       var_dump(soundex(mysqli_stat($link)) === soundex($link->stat));
-       echo "done!";
-?>
---EXPECT--
-bool(true)
-done!
index aa33f17f859dd737c8e28b34d3ec401dbf5960df..d795853e1f19bdef6e50ff4c76ba394696765f3e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
        /*
        Default values are "localhost", "root",
-       database "stest" and empty password.
+       database "test" and empty password.
        Change the MYSQL_TEST environment values
        if you want to use another configuration
        */
index 27d399be16bc1f13b8005e22ecc5d3123d3e3359..dfefb9098c1753de618eb2d9323d671775929cf8 100644 (file)
@@ -53,7 +53,7 @@ require_once('skipifconnectfailure.inc');
                'set_charset'                   => true,
                'set_opt'                               => true,
                'ssl_set'                               => true,
-               'stat'                                  => true,
+               'stat'                                  => true,
                'stmt_init'                             => true,
                'store_result'                  => true,
                'thread_safe'                   => true,
@@ -109,7 +109,6 @@ require_once('skipifconnectfailure.inc');
                "server_info"           => true,
                "server_version"        => true,
                "sqlstate"                      => true,
-               "stat"                          => true,
                "thread_id"                     => true,
                "warning_count"         => true,
        );
@@ -200,11 +199,6 @@ require_once('skipifconnectfailure.inc');
                $mysqli->sqlstate, gettype($mysqli->sqlstate),
                mysqli_sqlstate($link), gettype(mysqli_sqlstate($link)));
 
-       assert(soundex(mysqli_stat($link)) == soundex($mysqli->stat));
-       printf("mysqli->stat = '%s'/%s ('%s'/%s)\n",
-               $mysqli->stat, gettype($mysqli->stat),
-               mysqli_stat($link), gettype(mysqli_stat($link)));
-
        assert(mysqli_get_host_info($link) === $mysqli->host_info);
        printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n",
                $mysqli->host_info, gettype($mysqli->host_info),
@@ -288,7 +282,6 @@ mysqli->error = ''/string (''/string)
 mysqli->field_count = '0'/integer ('0'/integer)
 mysqli->insert_id = '0'/integer ('0'/integer)
 mysqli->sqlstate = '00000'/string ('00000'/string)
-mysqli->stat = 'Uptime: %d  Threads: %d  Questions: %d  Slow queries: %d  Opens: %d  Flush tables: %d  Open tables: %d  Queries per second avg: %d.%d'/string ('Uptime: %d  Threads: %d  Questions: %d  Slow queries: %d  Opens: %d  Flush tables: %d  Open tables: %d  Queries per second avg: %d.%d'/string)
 mysqli->host_info = '%s'/string ('%s'/string)
 mysqli->info = ''/NULL (''/NULL)
 mysqli->thread_id = '%d'/integer ('%d'/integer)
index fe6808e8c0dfb1e220cda377a6d13259fa25eadd..b7f227a7c2a885cb2a063415477409c1cc2642c8 100644 (file)
@@ -160,7 +160,6 @@ protocol_version = 'false'
 server_info = 'false'
 server_version = 'false'
 sqlstate = 'false'
-stat = 'false'
 thread_id = 'false'
 warning_count = 'false'
 
@@ -179,7 +178,6 @@ info = 'false'
 insert_id = 'false'
 server_info = 'false'
 server_version = 'false'
-stat = 'false'
 sqlstate = 'false'
 protocol_version = 'false'
 thread_id = 'false'
@@ -233,7 +231,6 @@ protocol_version = 'false'
 server_info = 'false'
 server_version = 'false'
 sqlstate = 'false'
-stat = 'false'
 thread_id = 'false'
 warning_count = 'false'
 
@@ -252,7 +249,6 @@ info = 'false'
 insert_id = 'false'
 server_info = 'false'
 server_version = 'false'
-stat = 'false'
 sqlstate = 'false'
 protocol_version = 'false'
 thread_id = 'false'
index ad69e3a334589958cd82ed61ef85a5c4cef3ca6b..061d03feac88a28b7278cd181bb76d1829f7ad52 100644 (file)
@@ -1317,14 +1317,6 @@ isStatic: no
 isDefault: yes
 Modifiers: 1
 
-Inspecting property 'stat'
-isPublic: yes
-isPrivate: no
-isProtected: no
-isStatic: no
-isDefault: yes
-Modifiers: 1
-
 Inspecting property 'thread_id'
 isPublic: yes
 isPrivate: no
@@ -1356,7 +1348,6 @@ Default property 'protocol_version'
 Default property 'server_info'
 Default property 'server_version'
 Default property 'sqlstate'
-Default property 'stat'
 Default property 'thread_id'
 Default property 'warning_count'
 done!
index 85eb90e65ac76bd7032fc45130e19bf07528d548..8b4e36afd47a77e92964834a144a5f255bdd5857 100644 (file)
@@ -44,9 +44,6 @@ require_once('skipifconnectfailure.inc');
                if ($link->info != 'Records: 6  Duplicates: 0  Warnings: 0') {
                        printf("[008] mysqlnd used to be more verbose and used to support SELECT\n");
                }
-               if ($link->stat != NULL) {
-                       printf("[009] NULL expected because of error.\n");
-               }
        } else {
                if ($link->info != NULL) {
                        printf("[008] Time for wonders - libmysql has started to support SELECT, change test\n");
@@ -123,8 +120,6 @@ object(mysqli)#%d (%d) {
   string(%d) "%s"
   ["server_version"]=>
   int(%d)
-  ["stat"]=>
-  %s
   ["sqlstate"]=>
   string(5) "HY000"
   ["protocol_version"]=>
index 5e4b56173b51bfb7b2ccd984c0f8cc3a14281242..1316d1a98194876f753ff8e178142a056d9bcb67 100644 (file)
@@ -207,8 +207,6 @@ object(mysqli)#%d (%d) {
   bool(false)
   ["server_version"]=>
   bool(false)
-  ["stat"]=>
-  bool(false)
   ["sqlstate"]=>
   bool(false)
   ["protocol_version"]=>