diff -u b/core/modules/node/src/Tests/NodeAccessPagerTest.php b/core/modules/node/src/Tests/NodeAccessPagerTest.php --- b/core/modules/node/src/Tests/NodeAccessPagerTest.php +++ b/core/modules/node/src/Tests/NodeAccessPagerTest.php @@ -80,8 +80,9 @@ // Look up the general discussion term. $tree = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree($vid, 0, 1); $tid = reset($tree)->tid; - unset($tree); // Save memory. $this->assertTrue($tid, 'General discussion term is found in the forum vocabulary.'); + // Unset $tree to save memory as it is not used anymore. + unset($tree); // Create 30 nodes. for ($i = 0; $i < 30; $i++) { diff -u b/core/modules/taxonomy/src/Form/OverviewTerms.php b/core/modules/taxonomy/src/Form/OverviewTerms.php --- b/core/modules/taxonomy/src/Form/OverviewTerms.php +++ b/core/modules/taxonomy/src/Form/OverviewTerms.php @@ -173,7 +173,7 @@ $current_page[$key] = $term; } while (isset($tree[++$tree_index])); - // Free memory now we don't need $tree anymore. + // Unset $tree to save memory as it is not used anymore. $tree_count = count($tree); unset($tree); diff -u b/core/modules/taxonomy/src/Tests/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php --- b/core/modules/taxonomy/src/Tests/TermTest.php +++ b/core/modules/taxonomy/src/Tests/TermTest.php @@ -239,7 +239,8 @@ } $tree = $this->container->get('entity.manager')->getStorage('taxonomy_term')->loadTree($this->vocabulary->id()); $this->assertTrue(empty($tree), 'The terms are not created on preview.'); - unset($tree); // Save memory. + // Unset $tree to save memory as it is not used anymore. + unset($tree); // taxonomy.module does not maintain its static caches. taxonomy_terms_static_reset(); @@ -421,6 +422,8 @@ $this->assertEqual($terms[1]->id(), $term2->id(), 'Term 2 was moved to back below term 1.'); $this->assertEqual($terms[2]->id(), $term3->id(), 'Term 3 is still below term 2.'); $this->assertEqual($terms[2]->parents, array($term2->id()), 'Term 3 is still a child of term 2.'); + // Unset $terms to save memory as it is not used anymore. + unset($terms); } /** only in patch2: unchanged: --- a/core/modules/forum/src/ForumManager.php +++ b/core/modules/forum/src/ForumManager.php @@ -421,6 +421,8 @@ public function getChildren($vid, $tid) { $forum->last_post = $this->getLastPost($forum->id()); $forums[$forum->id()] = $forum; } + // Unset $_forums to save memory as it is not used anymore. + unset($_forums); $this->forumChildren[$tid] = $forums; return $forums; only in patch2: unchanged: --- a/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php +++ b/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php @@ -75,6 +75,8 @@ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTA foreach ($terms as $term) { $options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . SafeMarkup::checkPlain($term->getName()); } + // Unset $terms to save memory as it is not used anymore. + unset($terms); } } } only in patch2: unchanged: --- a/core/modules/taxonomy/src/Tests/TermKernelTest.php +++ b/core/modules/taxonomy/src/Tests/TermKernelTest.php @@ -118,6 +118,8 @@ public function testTaxonomyVocabularyTree() { // Count $term[1] parents with $max_depth = 1. $tree = $taxonomy_storage->loadTree($vocabulary->id(), $term[1]->id(), 1); $this->assertEqual(1, count($tree), 'We have one parent with depth 1.'); + // Unset $tree to save memory as it is not used anymore. + unset($tree); // Count all vocabulary tree elements. $tree = $taxonomy_storage->loadTree($vocabulary->id()); @@ -130,6 +132,8 @@ public function testTaxonomyVocabularyTree() { } $depth_count[$element->depth]++; } + // Unset $tree to save memory as it is not used anymore. + unset($tree); $this->assertEqual(3, $depth_count[0], 'Three elements in taxonomy tree depth 0.'); $this->assertEqual(2, $depth_count[1], 'Two elements in taxonomy tree depth 1.'); $this->assertEqual(2, $depth_count[2], 'Two elements in taxonomy tree depth 2.'); only in patch2: unchanged: --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -165,6 +165,9 @@ function taxonomy_check_vocabulary_hierarchy(VocabularyInterface $vocabulary, $c $hierarchy = TAXONOMY_HIERARCHY_SINGLE; } } + // Unset $tree to save memory as it is not used anymore. + unset($tree); + if ($hierarchy != $vocabulary->getHierarchy()) { $vocabulary->setHierarchy($hierarchy); $vocabulary->save();