Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…failed

    connect
  • Loading branch information...
commit 74cfc5f3d7b99d2a0e30a4f0ad3f375f2f6c480d 1 parent 68ecbd7
@johannes johannes authored
View
2  NEWS
@@ -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
8 ext/mysqli/mysqli.c
@@ -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
12 ext/mysqli/mysqli_prop.c
@@ -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
4 ext/mysqli/tests/mysqli_fetch_lengths_oo.phpt
@@ -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
12 ext/mysqli/tests/mysqli_result_references.phpt
@@ -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){
Please sign in to comment.
Something went wrong with that request. Please try again.