Skip to content

Commit 3bb6b03

Browse files
committed
Address code review comments
1 parent 1bc86de commit 3bb6b03

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ 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+
207211
return FAILURE;
208212
}
209213

@@ -220,6 +224,10 @@ static int mysqli_warning_sqlstate(mysqli_object *obj, zval *retval, zend_bool q
220224
MYSQLI_WARNING *w;
221225

222226
if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) {
227+
if (!quiet) {
228+
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));
229+
}
230+
223231
return FAILURE;
224232
}
225233

@@ -236,6 +244,10 @@ static int mysqli_warning_errno(mysqli_object *obj, zval *retval, zend_bool quie
236244
MYSQLI_WARNING *w;
237245

238246
if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) {
247+
if (!quiet) {
248+
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));
249+
}
250+
239251
return FAILURE;
240252
}
241253

ext/mysqli/tests/bug54221.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ mysqli.reconnect = Off
4141

4242
print "done!";
4343
?>
44-
--EXPECT--
44+
--EXPECTF--
45+
Warning: main(): Couldn't fetch mysqli_warning in %s on line %d
46+
47+
Warning: main(): Couldn't fetch mysqli_warning in %s on line %d
4548
Warning: :
4649
Warning: 1050: Table 't54221' already exists
4750
done!

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)