diff --git a/core/modules/taxonomy/src/TermStorage.php b/core/modules/taxonomy/src/TermStorage.php index 5d1332a44777609b0c52c458e4bbf70c9a6e6fdf..c01ae66d3adbf1624f1b7f49d48ae80d3815795b 100644 --- a/core/modules/taxonomy/src/TermStorage.php +++ b/core/modules/taxonomy/src/TermStorage.php @@ -91,12 +91,16 @@ public function resetCache(array $ids = NULL) { /** * {@inheritdoc} */ - public function deleteTermHierarchy($tids) {} + public function deleteTermHierarchy($tids) { + @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. It is a no-op since 8.6.0. Parent references are automatically cleared when deleting a taxonomy term. See https://www.drupal.org/node/2936675', E_USER_DEPRECATED); + } /** * {@inheritdoc} */ - public function updateTermHierarchy(EntityInterface $term) {} + public function updateTermHierarchy(EntityInterface $term) { + @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. It is a no-op since 8.6.0. Parent references are automatically updated when updating a taxonomy term. See https://www.drupal.org/node/2936675', E_USER_DEPRECATED); + } /** * {@inheritdoc} diff --git a/core/modules/taxonomy/src/TermStorageInterface.php b/core/modules/taxonomy/src/TermStorageInterface.php index 29401868d782aa9dfbffe0e9a4681d710673aacc..41d521156aba0dd8fe9466d166725c09d9145513 100644 --- a/core/modules/taxonomy/src/TermStorageInterface.php +++ b/core/modules/taxonomy/src/TermStorageInterface.php @@ -16,9 +16,10 @@ interface TermStorageInterface extends ContentEntityStorageInterface { * @param array $tids * Array of terms that need to be removed from hierarchy. * - * @todo Remove this method in Drupal 9.0.x. Now the parent references are - * automatically cleared when deleting a taxonomy term. - * https://www.drupal.org/node/2785693 + * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Parent + * references are automatically cleared when deleting a taxonomy term. + * + * @see https://www.drupal.org/node/2936675 */ public function deleteTermHierarchy($tids); @@ -28,9 +29,10 @@ public function deleteTermHierarchy($tids); * @param \Drupal\Core\Entity\EntityInterface $term * Term entity that needs to be added to term hierarchy information. * - * @todo remove this method Drupal 9.0.x. Now the parent references are - * automatically updates when a taxonomy term is added/updated. - * https://www.drupal.org/node/2785693 + * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Parent + * references are automatically updated when updating a taxonomy term. + * + * @see https://www.drupal.org/node/2936675 */ public function updateTermHierarchy(EntityInterface $term); diff --git a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php index 29e43b72bf56f8ac7e3f0811748c0d08f0f96024..820924bfeb8435a37fe4c9056d12e013cd0a449c 100644 --- a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php @@ -168,4 +168,32 @@ public function testTermPreview() { $this->assertNotEmpty(trim($rendered), 'Term is able to be rendered.'); } + /** + * @covers \Drupal\taxonomy\TermStorage::deleteTermHierarchy + * @group legacy + */ + public function testDeleteTermHierarchyDeprecation(): void { + $vocabulary = $this->createVocabulary(); + $term = $this->createTerm($vocabulary); + + /** @var \Drupal\taxonomy\TermStorageInterface $storage */ + $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); + $this->expectDeprecation('Drupal\taxonomy\TermStorage::deleteTermHierarchy() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. It is a no-op since 8.6.0. Parent references are automatically cleared when deleting a taxonomy term. See https://www.drupal.org/node/2936675'); + $storage->deleteTermHierarchy([$term->tid]); + } + + /** + * @covers \Drupal\taxonomy\TermStorage::updateTermHierarchy + * @group legacy + */ + public function testUpdateTermHierarchyDeprecation(): void { + $vocabulary = $this->createVocabulary(); + $term = $this->createTerm($vocabulary); + + /** @var \Drupal\taxonomy\TermStorageInterface $storage */ + $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); + $this->expectDeprecation('Drupal\taxonomy\TermStorage::updateTermHierarchy() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. It is a no-op since 8.6.0. Parent references are automatically updated when updating a taxonomy term. See https://www.drupal.org/node/2936675'); + $storage->updateTermHierarchy($term); + } + }