diff -u b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php --- b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php @@ -57,7 +57,7 @@ class Term extends ContentEntityBase implements TermInterface { /** - * Implements Drupal\Core\Entity\EntityInterface::id(). + * {@inheritdoc} */ public function id() { return $this->get('tid')->value; diff -u b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php --- b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/entity_reference/selection/TermSelection.php @@ -12,6 +12,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\entity_reference\Annotation\EntityReferenceSelection; use Drupal\entity_reference\Plugin\entity_reference\selection\SelectionBase; +use Drupal\Component\Utility\String; /** * Provides specific access control for the taxonomy_term entity type. @@ -67,7 +68,7 @@ if ($vocabulary = entity_load('taxonomy_vocabulary', $bundle)) { if ($terms = taxonomy_get_tree($vocabulary->id(), 0)) { foreach ($terms as $term) { - $options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . check_plain($term->getName()); + $options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . String::checkPlain($term->getName()); } } } diff -u b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTid.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTid.php --- b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTid.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTid.php @@ -9,6 +9,7 @@ use Drupal\Component\Annotation\PluginID; use Drupal\views\Plugin\views\argument\ManyToOne; +use Drupal\Component\Utility\String; /** * Allow taxonomy term ID(s) as argument. @@ -50,7 +51,7 @@ ->condition('td.tid', $this->value) ->execute(); foreach ($result as $term_record) { - $titles[] = check_plain($term_record->name); + $titles[] = String::checkPlain($term_record->name); } return $titles; } diff -u b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_validator/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_validator/Term.php --- b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_validator/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_validator/Term.php @@ -12,6 +12,7 @@ use Drupal\views\Annotation\ViewsArgumentValidator; use Drupal\Core\Annotation\Translation; use Drupal\views\Plugin\views\argument_validator\ArgumentValidatorPluginBase; +use Drupal\Component\Utility\String; /** * Validate whether an argument is an acceptable node. @@ -108,7 +109,7 @@ if (!$term) { return FALSE; } - $this->argument->validated_title = check_plain($term->label()); + $this->argument->validated_title = String::checkPlain($term->label()); return empty($vocabularies) || !empty($vocabularies[$term->bundle()]); case 'tids': @@ -150,7 +151,7 @@ return FALSE; } - $titles[] = $validated_cache[$term->id()] = check_plain($term->label()); + $titles[] = $validated_cache[$term->id()] = String::checkPlain($term->label()); unset($test[$term->id()]); } } @@ -174,7 +175,7 @@ if ($type == 'convert') { $this->argument->argument = $term->id(); } - $this->argument->validated_title = check_plain($term->label()); + $this->argument->validated_title = String::checkPlain($term->label()); return TRUE; } return FALSE; diff -u b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/TaxonomyIndexTid.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/TaxonomyIndexTid.php --- b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/TaxonomyIndexTid.php @@ -11,6 +11,7 @@ use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\field\PrerenderList; use Drupal\Component\Annotation\PluginID; +use Drupal\Component\Utility\String; /** * Field handler to display all taxonomy terms of a node. @@ -117,10 +118,10 @@ $result = $query->execute(); foreach ($result as $term_record) { - $this->items[$term_record->node_nid][$term_record->tid]['name'] = check_plain($term_record->name); + $this->items[$term_record->node_nid][$term_record->tid]['name'] = String::checkPlain($term_record->name); $this->items[$term_record->node_nid][$term_record->tid]['tid'] = $term_record->tid; $this->items[$term_record->node_nid][$term_record->tid]['vocabulary_vid'] = $term_record->vid; - $this->items[$term_record->node_nid][$term_record->tid]['vocabulary'] = check_plain($vocabularies[$term_record->vid]->label()); + $this->items[$term_record->node_nid][$term_record->tid]['vocabulary'] = String::checkPlain($vocabularies[$term_record->vid]->label()); if (!empty($this->options['link_to_taxonomy'])) { $this->items[$term_record->node_nid][$term_record->tid]['make_link'] = TRUE; diff -u b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php --- b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -8,6 +8,7 @@ namespace Drupal\taxonomy\Tests; use Drupal\Core\Field\FieldDefinitionInterface; +use Drupal\Component\Utility\String; /** * Tests for taxonomy term functions. @@ -261,15 +262,15 @@ // The result order is not guaranteed, so check each term separately. $result = $this->drupalGet($path, array('query' => array('q' => $input))); $data = drupal_json_decode($result); - $this->assertEqual($data[$first_term->label()], check_plain($first_term->label()), 'Autocomplete returned the first matching term'); - $this->assertEqual($data[$second_term->label()], check_plain($second_term->label()), 'Autocomplete returned the second matching term'); + $this->assertEqual($data[$first_term->label()], String::checkPlain($first_term->label()), 'Autocomplete returned the first matching term'); + $this->assertEqual($data[$second_term->label()], String::checkPlain($second_term->label()), 'Autocomplete returned the second matching term'); // Try to autocomplete a term name that matches first term. // We should only get the first term in a json encoded string. $input = '10/16'; $path = 'taxonomy/autocomplete/node/taxonomy_' . $this->vocabulary->id(); $this->drupalGet($path, array('query' => array('q' => $input))); - $target = array($first_term->label() => check_plain($first_term->label())); + $target = array($first_term->label() => String::checkPlain($first_term->label())); $this->assertRaw(drupal_json_encode($target), 'Autocomplete returns only the expected matching term.'); // Try to autocomplete a term name with both a comma and a slash. @@ -281,7 +282,7 @@ if (strpos($third_term->label(), ',') !== FALSE || strpos($third_term->label(), '"') !== FALSE) { $n = '"' . str_replace('"', '""', $third_term->label()) . '"'; } - $target = array($n => check_plain($third_term->label())); + $target = array($n => String::checkPlain($third_term->label())); $this->assertRaw(drupal_json_encode($target), 'Autocomplete returns a term containing a comma and a slash.'); } diff -u b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php --- b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Language\Language; +use Drupal\Component\Utility\String; /** * Test taxonomy token replacement in strings. @@ -87,12 +88,12 @@ // Generate and test sanitized tokens for term1. $tests = array(); $tests['[term:tid]'] = $term1->id(); - $tests['[term:name]'] = check_plain($term1->getName()); + $tests['[term:name]'] = String::checkPlain($term1->getName()); $tests['[term:description]'] = check_markup($term1->getDescription(), $term1->getFormat()); $tests['[term:url]'] = url('taxonomy/term/' . $term1->id(), array('absolute' => TRUE)); $tests['[term:node-count]'] = 0; $tests['[term:parent:name]'] = '[term:parent:name]'; - $tests['[term:vocabulary:name]'] = check_plain($this->vocabulary->name); + $tests['[term:vocabulary:name]'] = String::checkPlain($this->vocabulary->name); foreach ($tests as $input => $expected) { $output = $token_service->replace($input, array('term' => $term1), array('langcode' => $language_interface->id)); @@ -102,14 +103,14 @@ // Generate and test sanitized tokens for term2. $tests = array(); $tests['[term:tid]'] = $term2->id(); - $tests['[term:name]'] = check_plain($term2->getName()); + $tests['[term:name]'] = String::checkPlain($term2->getName()); $tests['[term:description]'] = check_markup($term2->getDescription(), $term2->getFormat()); $tests['[term:url]'] = url('taxonomy/term/' . $term2->id(), array('absolute' => TRUE)); $tests['[term:node-count]'] = 1; - $tests['[term:parent:name]'] = check_plain($term1->getName()); + $tests['[term:parent:name]'] = String::checkPlain($term1->getName()); $tests['[term:parent:url]'] = url('taxonomy/term/' . $term1->id(), array('absolute' => TRUE)); $tests['[term:parent:parent:name]'] = '[term:parent:parent:name]'; - $tests['[term:vocabulary:name]'] = check_plain($this->vocabulary->name); + $tests['[term:vocabulary:name]'] = String::checkPlain($this->vocabulary->name); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); @@ -133,7 +134,7 @@ // Generate and test sanitized tokens. $tests = array(); $tests['[vocabulary:vid]'] = $this->vocabulary->id(); - $tests['[vocabulary:name]'] = check_plain($this->vocabulary->name); + $tests['[vocabulary:name]'] = String::checkPlain($this->vocabulary->name); $tests['[vocabulary:description]'] = filter_xss($this->vocabulary->description); $tests['[vocabulary:node-count]'] = 1; $tests['[vocabulary:term-count]'] = 2; diff -u b/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc --- b/core/modules/taxonomy/taxonomy.tokens.inc +++ b/core/modules/taxonomy/taxonomy.tokens.inc @@ -5,6 +5,8 @@ * Builds placeholder replacement tokens for taxonomy terms and vocabularies. */ +use Drupal\Component\Utility\String; + /** * Implements hook_token_info(). */ @@ -104,7 +106,7 @@ break; case 'name': - $replacements[$original] = $sanitize ? check_plain($term->getName()) : $term->getName(); + $replacements[$original] = $sanitize ? String::checkPlain($term->getName()) : $term->getName(); break; case 'description': @@ -126,13 +128,13 @@ case 'vocabulary': $vocabulary = entity_load('taxonomy_vocabulary', $term->bundle()); - $replacements[$original] = check_plain($vocabulary->name); + $replacements[$original] = String::checkPlain($vocabulary->name); break; case 'parent': if ($parents = taxonomy_term_load_parents($term->id())) { $parent = array_pop($parents); - $replacements[$original] = check_plain($parent->getName()); + $replacements[$original] = String::checkPlain($parent->getName()); } break; } @@ -159,7 +161,7 @@ break; case 'name': - $replacements[$original] = $sanitize ? check_plain($vocabulary->name) : $vocabulary->name; + $replacements[$original] = $sanitize ? String::checkPlain($vocabulary->name) : $vocabulary->name; break; case 'description': only in patch2: unchanged: --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldFormatter/LinkFormatter.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldFormatter/LinkFormatter.php @@ -8,6 +8,7 @@ namespace Drupal\taxonomy\Plugin\Field\FieldFormatter; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Component\Utility\String; /** * Plugin implementation of the 'taxonomy_term_reference_link' formatter. @@ -27,13 +28,12 @@ class LinkFormatter extends TaxonomyFormatterBase { */ public function viewElements(FieldItemListInterface $items) { $elements = array(); - // Terms without target_id do not exist yet, theme such terms as just their // name. foreach ($items as $delta => $item) { if (!$item->target_id) { $elements[$delta] = array( - '#markup' => check_plain($item->entity->label()), + '#markup' => String::checkPlain($item->entity->label()), ); } else { only in patch2: unchanged: --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldFormatter/PlainFormatter.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldFormatter/PlainFormatter.php @@ -8,6 +8,7 @@ namespace Drupal\taxonomy\Plugin\Field\FieldFormatter; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Component\Utility\String; /** * Plugin implementation of the 'taxonomy_term_reference_plain' formatter. @@ -30,7 +31,7 @@ public function viewElements(FieldItemListInterface $items) { foreach ($items as $delta => $item) { $elements[$delta] = array( - '#markup' => check_plain($item->entity->label()), + '#markup' => String::checkPlain($item->entity->label()), ); } only in patch2: unchanged: --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php @@ -9,6 +9,7 @@ use Drupal\views\Plugin\views\argument\ArgumentPluginBase; use Drupal\Component\Annotation\PluginID; +use Drupal\Component\Utility\String; /** * Argument handler for taxonomy terms with depth. @@ -149,7 +150,7 @@ public function query($group_by = FALSE) { function title() { $term = entity_load('taxonomy_term', $this->argument); if (!empty($term)) { - return check_plain($term->label()); + return String::checkPlain($term->label()); } // TODO review text return t('No name'); only in patch2: unchanged: --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/Taxonomy.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/Taxonomy.php @@ -9,6 +9,7 @@ use Drupal\views\Plugin\views\argument\Numeric; use Drupal\Component\Annotation\PluginID; +use Drupal\Component\Utility\String; /** * Argument handler for basic taxonomy tid. @@ -27,7 +28,7 @@ function title() { if ($this->argument) { $term = entity_load('taxonomy_term', $this->argument); if (!empty($term)) { - return check_plain($term->label()); + return String::checkPlain($term->label()); } } // TODO review text only in patch2: unchanged: --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/VocabularyVid.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/VocabularyVid.php @@ -9,6 +9,7 @@ use Drupal\Component\Annotation\PluginID; use Drupal\views\Plugin\views\argument\Numeric; +use Drupal\Component\Utility\String; /** * Argument handler to accept a vocabulary id. @@ -25,7 +26,7 @@ class VocabularyVid extends Numeric { function title() { $vocabulary = entity_load('taxonomy_vocabulary', $this->argument); if ($vocabulary) { - return check_plain($vocabulary->label()); + return String::checkPlain($vocabulary->label()); } return t('No vocabulary'); only in patch2: unchanged: --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -15,6 +15,7 @@ use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\Entity\Vocabulary; use Drupal\taxonomy\VocabularyInterface; +use Drupal\Component\Utility\String; /** * Denotes that no term in the vocabulary has a parent. @@ -438,7 +439,7 @@ function template_preprocess_taxonomy_term(&$variables) { $uri = $term->uri(); $variables['url'] = url($uri['path'], $uri['options']); // We use name here because that is what appears in the UI. - $variables['name'] = check_plain($term->label()); + $variables['name'] = String::checkPlain($term->label()); $variables['page'] = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term); // Helpful $content variable for templates. only in patch2: unchanged: --- a/core/modules/taxonomy/taxonomy.views.inc +++ b/core/modules/taxonomy/taxonomy.views.inc @@ -9,6 +9,7 @@ use Drupal\Core\Entity\FieldableDatabaseStorageController; use Drupal\field\FieldInterface; +use Drupal\Component\Utility\String; /** * Implements hook_views_data(). @@ -488,6 +489,6 @@ function views_taxonomy_set_breadcrumb(&$breadcrumb, &$argument) { $args[$argument->position] = $parent->id(); $path = $argument->view->getUrl($args); } - $breadcrumb[$path] = check_plain($parent->label()); + $breadcrumb[$path] = String::checkPlain($parent->label()); } }