Commit 7a69e5b4 authored by catch's avatar catch
Browse files

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

(cherry picked from commit 3b671f7f)
parent 493d4497
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
@@ -452,9 +452,13 @@ public function testConfigSaveWithSchema(): void {

    // Save config which has a schema that enforces types.
    $this->expectDeprecation("The definition for the 'config_schema_test.schema_data_types.sequence_bc' sequence declares the type of its items in a way that is deprecated in drupal:8.0.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/2442603");
    $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.