]> granicus.if.org Git - php/commitdiff
Return only debug props in PDORow
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 10 Jan 2019 11:36:08 +0000 (12:36 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 10 Jan 2019 11:37:28 +0000 (12:37 +0100)
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.

ext/pdo/pdo_stmt.c

index 55d3f53fbeccccdc447af5de69185a543972d4e5..0b6fc902538a3ab558fd4e54d9f4442b1a487c90 100644 (file)
@@ -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;