Skip to content

Commit a0d0cb8

Browse files
committed
Return only debug props in PDORow
Previously this returned properties of a different object, including INDIRECTs directly, which violates our invariants. Switch this to only return properties for debugging purposes, without INDIRECTs. If someone complains we can extend this to other purposes, as needed.
1 parent 5f7b934 commit a0d0cb8

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,27 +2562,28 @@ static void row_dim_delete(zval *object, zval *offset)
25622562
php_error_docref(NULL, E_WARNING, "Cannot delete properties from a PDORow");
25632563
}
25642564

2565-
static HashTable *row_get_properties(zval *object)
2565+
static HashTable *row_get_properties_for(zval *object, zend_prop_purpose purpose)
25662566
{
25672567
pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object);
25682568
pdo_stmt_t *stmt = row->stmt;
2569+
HashTable *props;
25692570
int i;
25702571

2571-
if (stmt == NULL) {
2572-
return NULL;
2572+
if (purpose != ZEND_PROP_PURPOSE_DEBUG || stmt == NULL) {
2573+
return zend_std_get_properties_for(object, purpose);
25732574
}
25742575

25752576
if (!stmt->std.properties) {
25762577
rebuild_object_properties(&stmt->std);
25772578
}
2579+
props = zend_array_dup(stmt->std.properties);
25782580
for (i = 0; i < stmt->column_count; i++) {
25792581
zval val;
25802582
fetch_value(stmt, &val, i, NULL);
25812583

2582-
zend_hash_update(stmt->std.properties, stmt->columns[i].name, &val);
2584+
zend_hash_update(props, stmt->columns[i].name, &val);
25832585
}
2584-
2585-
return stmt->std.properties;
2586+
return props;
25862587
}
25872588

25882589
static zend_function *row_method_get(
@@ -2685,7 +2686,7 @@ void pdo_stmt_init(void)
26852686
pdo_row_object_handlers.write_dimension = row_dim_write;
26862687
pdo_row_object_handlers.has_dimension = row_dim_exists;
26872688
pdo_row_object_handlers.unset_dimension = row_dim_delete;
2688-
pdo_row_object_handlers.get_properties = row_get_properties;
2689+
pdo_row_object_handlers.get_properties_for = row_get_properties_for;
26892690
pdo_row_object_handlers.get_method = row_method_get;
26902691
pdo_row_object_handlers.call_method = row_call_method;
26912692
pdo_row_object_handlers.get_constructor = row_get_ctor;

0 commit comments

Comments
 (0)