diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-01-10 12:36:08 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-01-10 12:37:28 +0100 |
commit | a0d0cb847fb623f1f64abe7ff42f5a6e6c4bfb8c (patch) | |
tree | a9df3804e26880a8e39864c6a44fccb4aa757630 | |
parent | 5f7b934f8b80af499f459dbcb6fae76eab9a136d (diff) | |
download | php-git-a0d0cb847fb623f1f64abe7ff42f5a6e6c4bfb8c.tar.gz |
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.
-rw-r--r-- | ext/pdo/pdo_stmt.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 55d3f53fbe..0b6fc90253 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2562,27 +2562,28 @@ static void row_dim_delete(zval *object, zval *offset) php_error_docref(NULL, E_WARNING, "Cannot delete properties from a PDORow"); } -static HashTable *row_get_properties(zval *object) +static HashTable *row_get_properties_for(zval *object, zend_prop_purpose purpose) { pdo_row_t *row = (pdo_row_t *)Z_OBJ_P(object); pdo_stmt_t *stmt = row->stmt; + HashTable *props; int i; - if (stmt == NULL) { - return NULL; + if (purpose != ZEND_PROP_PURPOSE_DEBUG || stmt == NULL) { + return zend_std_get_properties_for(object, purpose); } if (!stmt->std.properties) { rebuild_object_properties(&stmt->std); } + props = zend_array_dup(stmt->std.properties); for (i = 0; i < stmt->column_count; i++) { zval val; fetch_value(stmt, &val, i, NULL); - zend_hash_update(stmt->std.properties, stmt->columns[i].name, &val); + zend_hash_update(props, stmt->columns[i].name, &val); } - - return stmt->std.properties; + return props; } static zend_function *row_method_get( @@ -2685,7 +2686,7 @@ void pdo_stmt_init(void) pdo_row_object_handlers.write_dimension = row_dim_write; pdo_row_object_handlers.has_dimension = row_dim_exists; pdo_row_object_handlers.unset_dimension = row_dim_delete; - pdo_row_object_handlers.get_properties = row_get_properties; + pdo_row_object_handlers.get_properties_for = row_get_properties_for; pdo_row_object_handlers.get_method = row_method_get; pdo_row_object_handlers.call_method = row_call_method; pdo_row_object_handlers.get_constructor = row_get_ctor; |