Change record status: 
Project: 
Introduced in branch: 
9.3.x
Introduced in version: 
9.3.0
Description: 

Some taxonomy.module functions are deprecated. Also, using drupal_static_reset() with taxonomy_vocabulary_get_names() as parameter is deprecated.

Deprecated Taxonomy module functions

  • taxonomy_vocabulary_get_names()
  • taxonomy_term_uri()
  • taxonomy_term_load_multiple_by_name()
  • taxonomy_terms_static_reset()
  • taxonomy_vocabulary_static_reset()
  • taxonomy_implode_tags()
  • taxonomy_term_title()
  • Using drupal_static_reset() with taxonomy_vocabulary_get_names() as parameter is deprecated.

Replacements

Before After
$vids = taxonomy_vocabulary_get_names();
$vids = \Drupal::entityQuery('taxonomy_vocabulary')
  ->execute();
$terms = taxonomy_term_load_multiple_by_name(
  'Foo',
  'topics'
);
$storage = \Drupal::entityTypeManager()
  ->getStorage('taxonomy_term');
$terms = $storage->loadByProperties([ 
  'name' => 'Foo',
  'vid' => 'topics',
]);
$url = taxonomy_term_uri($term); $url = $term->toUrl();
taxonomy_terms_static_reset()
$storage = \Drupal::entityTypeManager()
  ->getStorage('taxonomy_term');
$storage->resetCache();
taxonomy_vocabulary_static_reset($vids);
$storage = \Drupal::entityTypeManager()
  ->getStorage('taxonomy_vocabulary');
$storage->resetCache($vids);
taxonomy_implode_tags(); \Drupal\Core\Entity\Element\EntityAutocomplete::getEntityLabels()
$name = taxonomy_term_title($term); $name = $term->label();
drupal_static_reset(
  'taxonomy_vocabulary_get_names'
);
$storage = \Drupal::entityTypeManager()
  ->getStorage('taxonomy_vocabulary');
$storage->resetCache()
Impacts: 
Module developers
Site templates, recipes and distribution developers

Comments

mxr576’s picture

... so maybe the suggested replacement for taxonomy_term_load_multiple_by_name() should be adjusted accordingly... Although a truly BC code can be achieved by using loadByProperties()... :rolling-face:

https://mglaman.dev/blog/avoid-using-loadbyproperties-load-entities