Skip to content

Commit 0ef6b2b

Browse files
committed
Address code review comments
1 parent 70cb8f9 commit 0ef6b2b

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

ext/mysqli/mysqli.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ static void mysqli_warning_free_storage(zend_object *object)
283283
/* {{{ mysqli_read_na */
284284
static int mysqli_read_na(mysqli_object *obj, zval *retval, zend_bool quiet)
285285
{
286-
zend_throw_error(NULL, "Cannot read property");
286+
if (!quiet) {
287+
zend_throw_error(NULL, "Cannot read property");
288+
}
287289

288290
return FAILURE;
289291
}
@@ -322,14 +324,10 @@ zval *mysqli_read_property(zval *object, zval *member, int type, void **cache_sl
322324
}
323325

324326
if (hnd) {
325-
if (hnd->read_func(obj, rv, type == BP_VAR_IS) == SUCCESS && rv != NULL) {
327+
if (hnd->read_func(obj, rv, type == BP_VAR_IS) == SUCCESS || type != BP_VAR_IS) {
326328
retval = rv;
327329
} else {
328-
if (type == BP_VAR_IS || rv == NULL) {
329-
retval = &EG(uninitialized_zval);
330-
} else {
331-
retval = rv;
332-
}
330+
retval = &EG(uninitialized_zval);
333331
}
334332
} else {
335333
retval = zend_std_read_property(object, member, type, cache_slot, rv);

ext/mysqli/mysqli_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static int name(mysqli_object *obj, zval *value) \
6161
static int name(mysqli_object *obj, zval *retval, zend_bool quiet) \
6262
{ \
6363
ZVAL_STRING(retval, MyG(value)); \
64-
return SUCESS; \
64+
return SUCCESS; \
6565
} \
6666

6767
#define MAP_PROPERTY_MYG_STRING_WRITE(name, value) \

ext/mysqli/mysqli_warning.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ static int mysqli_warning_message(mysqli_object *obj, zval *retval, zend_bool qu
204204
MYSQLI_WARNING *w;
205205

206206
if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) {
207+
if (!quiet) {
208+
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));
209+
}
210+
ZVAL_NULL(retval);
211+
207212
return FAILURE;
208213
}
209214

@@ -220,6 +225,11 @@ static int mysqli_warning_sqlstate(mysqli_object *obj, zval *retval, zend_bool q
220225
MYSQLI_WARNING *w;
221226

222227
if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) {
228+
if (!quiet) {
229+
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));
230+
}
231+
ZVAL_NULL(retval);
232+
223233
return FAILURE;
224234
}
225235

@@ -236,6 +246,11 @@ static int mysqli_warning_errno(mysqli_object *obj, zval *retval, zend_bool quie
236246
MYSQLI_WARNING *w;
237247

238248
if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) {
249+
if (!quiet) {
250+
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));
251+
}
252+
ZVAL_NULL(retval);
253+
239254
return FAILURE;
240255
}
241256

ext/mysqli/tests/mysqli_result_references.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ require_once('skipifconnectfailure.inc');
5959

6060
$references[$idx++] = &$res;
6161
mysqli_free_result($res);
62-
@debug_zval_dump($references);
62+
debug_zval_dump($references);
6363

6464
if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) ||
6565
!($res = mysqli_use_result($link)))

0 commit comments

Comments
 (0)