johannes                Tue Feb 17 10:40:18 2009 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/mysqli/tests   bug45940.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/mysqli mysqli.c mysqli_prop.c 
  Log:
  MFH: Fix #45940 MySQLI OO does not populate connect_error property on failed 
connect
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1421&r2=1.2027.2.547.2.1422&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1421 php-src/NEWS:1.2027.2.547.2.1422
--- php-src/NEWS:1.2027.2.547.2.1421    Mon Feb 16 01:58:16 2009
+++ php-src/NEWS        Tue Feb 17 10:40:18 2009
@@ -3,6 +3,8 @@
 ?? Feb 2009, PHP 5.2.9
 - Fixed bug #47399 (mb_check_encoding() returns true for some illegal SJIS
   characters). (for-bugs at hnw dot jp, Moriyoshi)
+- Fixed bug #45940 (MySQLI OO does not populate connect_error property on
+  failed connect). (Johannes)
 - Fixed bug #45923 (mb_st[r]ripos() offset not handled correctly). (Moriyoshi)
 - Fixed bug #43841 (mb_strrpos() offset is byte count for negative values).
   (Moriyoshi)
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/mysqli.c?r1=1.72.2.16.2.27&r2=1.72.2.16.2.28&diff_format=u
Index: php-src/ext/mysqli/mysqli.c
diff -u php-src/ext/mysqli/mysqli.c:1.72.2.16.2.27 
php-src/ext/mysqli/mysqli.c:1.72.2.16.2.28
--- php-src/ext/mysqli/mysqli.c:1.72.2.16.2.27  Wed Dec 31 11:17:40 2008
+++ php-src/ext/mysqli/mysqli.c Tue Feb 17 10:40:18 2009
@@ -15,7 +15,7 @@
   | Author: Georg Richter <ge...@php.net>                                |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli.c,v 1.72.2.16.2.27 2008/12/31 11:17:40 sebastian Exp $ 
+  $Id: mysqli.c,v 1.72.2.16.2.28 2009/02/17 10:40:18 johannes Exp $ 
 */
 
 #ifdef HAVE_CONFIG_H
@@ -254,13 +254,6 @@
        }
 
        if (ret == SUCCESS) {
-               if (strcmp(obj->zo.ce->name, "mysqli_driver") &&
-            (!obj->ptr || ((MYSQLI_RESOURCE *)(obj->ptr))->status < 
MYSQLI_STATUS_INITIALIZED)) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't 
fetch %s", obj->zo.ce->name );
-                       retval = EG(uninitialized_zval_ptr);
-                       return(retval);
-               }
-
                ret = hnd->read_func(obj, &retval TSRMLS_CC);
                if (ret == SUCCESS) {
                        /* ensure we're creating a temporary variable */
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/mysqli_prop.c?r1=1.23.2.5.2.5&r2=1.23.2.5.2.6&diff_format=u
Index: php-src/ext/mysqli/mysqli_prop.c
diff -u php-src/ext/mysqli/mysqli_prop.c:1.23.2.5.2.5 
php-src/ext/mysqli/mysqli_prop.c:1.23.2.5.2.6
--- php-src/ext/mysqli/mysqli_prop.c:1.23.2.5.2.5       Wed Dec 31 11:17:40 2008
+++ php-src/ext/mysqli/mysqli_prop.c    Tue Feb 17 10:40:18 2009
@@ -15,7 +15,7 @@
   | Author: Georg Richter <ge...@php.net>                                |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_prop.c,v 1.23.2.5.2.5 2008/12/31 11:17:40 sebastian Exp $ 
+  $Id: mysqli_prop.c,v 1.23.2.5.2.6 2009/02/17 10:40:18 johannes Exp $ 
 */
 
 #ifdef HAVE_CONFIG_H
@@ -30,7 +30,7 @@
 #include "php_mysqli.h"
 
 #define CHECK_STATUS(value) \
-       if (((MYSQLI_RESOURCE *)obj->ptr)->status < value ) { \
+       if (!obj->ptr || ((MYSQLI_RESOURCE *)obj->ptr)->status < value ) { \
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property access is 
not allowed yet"); \
                ZVAL_NULL(*retval); \
                return SUCCESS; \
@@ -134,7 +134,6 @@
 static int link_connect_errno_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
        ALLOC_ZVAL(*retval);
-       CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
        ZVAL_LONG(*retval, (long)MyG(error_no));
        return SUCCESS;
 }
@@ -144,8 +143,11 @@
 static int link_connect_error_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
        ALLOC_ZVAL(*retval);
-       CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
-       ZVAL_STRING(*retval, MyG(error_msg), 1);
+       if (MyG(error_msg)) {
+               ZVAL_STRING(*retval, MyG(error_msg), 1);
+       } else {
+               ZVAL_NULL(*retval);
+       }
        return SUCCESS;
 }
 /* }}} */

http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/bug45940.phpt?view=markup&rev=1.1
Index: php-src/ext/mysqli/tests/bug45940.phpt
+++ php-src/ext/mysqli/tests/bug45940.phpt



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to