MFH Fix #45940 MySQLI OO does not populate connect_error property on failed

connect
This commit is contained in:
Johannes Schlüter 2009-01-12 12:56:01 +00:00
parent 68ecbd73d3
commit 74cfc5f3d7
5 changed files with 23 additions and 15 deletions

2
NEWS
View File

@ -51,6 +51,8 @@ PHP NEWS
(Scott)
- Fixed bug #45989 (json_decode() doesn't return NULL on certain invalid
strings). (magicaltux, Scott)
- Fixed bug #45940 (MySQLI OO does not populate connect_error property on
failed connect). (Johannes)
- Fixed bug #45820 (Allow empty keys in ArrayObject). (Etienne)
- Fixed bug #45791 (json_decode() doesn't convert 0e0 to a double). (Scott)

View File

@ -355,14 +355,6 @@ zval *mysqli_read_property(zval *object, zval *member, int type TSRMLS_DC)
}
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 */

View File

@ -30,7 +30,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; \
@ -134,7 +134,6 @@ static int link_client_info_read(mysqli_object *obj, zval **retval TSRMLS_DC)
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;
}
@ -144,8 +143,11 @@ static int link_connect_errno_read(mysqli_object *obj, zval **retval TSRMLS_DC)
static int link_connect_error_read(mysqli_object *obj, zval **retval TSRMLS_DC)
{
MAKE_STD_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;
}
/* }}} */
@ -158,6 +160,8 @@ static int link_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC)
MAKE_STD_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
if (!mysql) {

View File

@ -38,6 +38,6 @@ array(2) {
}
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!
done!

View File

@ -125,7 +125,17 @@ array(7) refcount(2){
&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){