johannes                Mon Jan 12 12:54:17 2009 UTC

  Modified files:              
    /php-src/ext/mysqli mysqli.c mysqli_prop.c 
    /php-src/ext/mysqli/tests   mysqli_fetch_lengths_oo.phpt 
                                mysqli_result_references.phpt 
  Log:
  - Fix #45940 MySQLI OO does not populate connect_error property on failed
    connect
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/mysqli.c?r1=1.141&r2=1.142&diff_format=u
Index: php-src/ext/mysqli/mysqli.c
diff -u php-src/ext/mysqli/mysqli.c:1.141 php-src/ext/mysqli/mysqli.c:1.142
--- php-src/ext/mysqli/mysqli.c:1.141   Wed Jan  7 16:29:42 2009
+++ php-src/ext/mysqli/mysqli.c Mon Jan 12 12:54:17 2009
@@ -17,7 +17,7 @@
   |          Ulf Wendel <u...@php.net>                                     |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli.c,v 1.141 2009/01/07 16:29:42 johannes Exp $ 
+  $Id: mysqli.c,v 1.142 2009/01/12 12:54:17 johannes Exp $ 
 */
 
 #ifdef HAVE_CONFIG_H
@@ -347,13 +347,6 @@
        }
 
        if (ret == SUCCESS) {
-               if ((!obj->ptr || ((MYSQLI_RESOURCE *)(obj->ptr))->status < 
MYSQLI_STATUS_INITIALIZED))
-               {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't 
fetch %v", 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.41&r2=1.42&diff_format=u
Index: php-src/ext/mysqli/mysqli_prop.c
diff -u php-src/ext/mysqli/mysqli_prop.c:1.41 
php-src/ext/mysqli/mysqli_prop.c:1.42
--- php-src/ext/mysqli/mysqli_prop.c:1.41       Wed Dec 31 11:12:33 2008
+++ php-src/ext/mysqli/mysqli_prop.c    Mon Jan 12 12:54:17 2009
@@ -17,7 +17,7 @@
   |          Ulf Wendel <u...@php.net>                                     |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_prop.c,v 1.41 2008/12/31 11:12:33 sebastian Exp $ 
+  $Id: mysqli_prop.c,v 1.42 2009/01/12 12:54:17 johannes Exp $ 
 */
 
 #ifdef HAVE_CONFIG_H
@@ -32,7 +32,7 @@
 #include "php_mysqli_structs.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; \
@@ -136,7 +136,6 @@
 static int link_connect_errno_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
        MAKE_STD_ZVAL(*retval);
-       CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
        ZVAL_LONG(*retval, (long)MyG(error_no));
        return SUCCESS;
 }
@@ -146,8 +145,11 @@
 static int link_connect_error_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
        MAKE_STD_ZVAL(*retval);
-       CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
-       ZVAL_UTF8_STRING(*retval, MyG(error_msg), ZSTR_DUPLICATE)
+       if (MyG(error_msg)) {
+               ZVAL_UTF8_STRING(*retval, MyG(error_msg), ZSTR_DUPLICATE);
+       } else {
+               ZVAL_NULL(*retval);
+       }
        return SUCCESS;
 }
 /* }}} */
@@ -160,6 +162,8 @@
 
        MAKE_STD_ZVAL(*retval); 
 
+       CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
+
        mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
        
        if (!mysql) {
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt
diff -u php-src/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt:1.2 
php-src/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt:1.3
--- php-src/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt:1.2   Thu Aug  9 
10:01:19 2007
+++ php-src/ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt       Mon Jan 12 
12:54:17 2009
@@ -38,6 +38,6 @@
 }
 NULL
 
-Warning: main(): Couldn't fetch mysqli_result in %s on line %d
+Warning: main(): Property access is not allowed yet in %s on line %d
 NULL
-done!
\ No newline at end of file
+done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/mysqli_result_references.phpt?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/mysqli/tests/mysqli_result_references.phpt
diff -u php-src/ext/mysqli/tests/mysqli_result_references.phpt:1.4 
php-src/ext/mysqli/tests/mysqli_result_references.phpt:1.5
--- php-src/ext/mysqli/tests/mysqli_result_references.phpt:1.4  Tue Jan  6 
00:56:04 2009
+++ php-src/ext/mysqli/tests/mysqli_result_references.phpt      Mon Jan 12 
12:54:17 2009
@@ -125,7 +125,17 @@
     &long(4) refcount(2)
   }
   [6]=>
-  &object(mysqli_result)#2 (0) refcount(2){
+  &object(mysqli_result)#2 (5) refcount(2){
+    ["current_field"]=>
+    NULL refcount(1)
+    ["field_count"]=>
+    NULL refcount(1)
+    ["lengths"]=>
+    NULL refcount(1)
+    ["num_rows"]=>
+    NULL refcount(1)
+    ["type"]=>
+    NULL refcount(1)
   }
 }
 array(1) refcount(2){



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

Reply via email to