Commit 4ccf30aa authored by catch's avatar catch
Browse files

Issue #3535199 by alexpott, godotislate: Saving untrusted config results in memory leak

(cherry picked from commit 8e2ecba4)
parent b3e05b6f
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -209,6 +209,8 @@ public function save($has_trusted_data = FALSE) {
        // Ensure that the schema wrapper has the latest data.
        $this->schemaWrapper = NULL;
        $this->data = $this->castValue(NULL, $this->data);
        // Reclaim the memory used by the schema wrapper.
        $this->schemaWrapper = NULL;
      }
      else {
        foreach ($this->data as $key => $value) {
+5 −1
Original line number Diff line number Diff line
@@ -459,9 +459,13 @@ public function testConfigSaveWithSchema(): void {
    ];

    // Save config which has a schema that enforces types.
    $this->config('config_schema_test.schema_data_types')
    $config_object = $this->config('config_schema_test.schema_data_types');
    $config_object
      ->setData($untyped_to_typed)
      ->save();
    // Ensure the schemaWrapper property is reset after saving to prevent a
    // memory leak.
    $this->assertNull((new \ReflectionObject($config_object))->getProperty('schemaWrapper')->getValue($config_object));
    $this->assertSame($typed_values, $this->config('config_schema_test.schema_data_types')->get());

    // Save config which does not have a schema that enforces types.