diff -u b/core/modules/filter/filter.module b/core/modules/filter/filter.module --- b/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -105,6 +105,7 @@ ); $type['processed_text'] = array( '#text' => '', + '#format' => NULL, '#filter_types_to_skip' => array(), '#langcode' => '', '#pre_render' => array( @@ -278,13 +279,13 @@ * * @param string $text * The text to be filtered. - * @param string|null $format_id - * (optional) The machine name of the filter format to be used to filter the - * text. Defaults to the fallback format. See filter_fallback_format(). + * @param string $format_id + * The machine name of the filter format to be used to filter the text. * @param string $langcode * (optional) The language code of the text to be filtered, e.g. 'en' for - * English. This allows filters to be language-aware so language-specific - * text replacement can be implemented. Defaults to an empty string. + * English. This allows filters to be language-aware so language-specific text + * replacement can be implemented. Defaults to + * Drupal\Core\Language\LanguageInterface::LANGCODE_NOT_SPECIFIED. * @param array $filter_types_to_skip * (optional) An array of filter types to skip, or an empty array (default) * to skip no filter types. All of the format's filters will be applied, @@ -299,20 +300,20 @@ * * @ingroup sanitization */ -function check_markup($text, $format_id = NULL, $langcode = '', $filter_types_to_skip = array()) { +function check_markup($text, $format_id, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $filter_types_to_skip = array()) { $build = array( '#type' => 'processed_text', '#text' => $text, * * @param string $text * The text to be filtered. - * @param string $format_id - * The machine name of the filter format to be used to filter the text. + * @param string|null $format_id + * (optional) The machine name of the filter format to be used to filter the + * text. Defaults to the fallback format. See filter_fallback_format(). * @param string $langcode * (optional) The language code of the text to be filtered, e.g. 'en' for - * English. This allows filters to be language-aware so language-specific text - * replacement can be implemented. Defaults to - * Drupal\Core\Language\LanguageInterface::LANGCODE_NOT_SPECIFIED. + * English. This allows filters to be language-aware so language-specific + * text replacement can be implemented. Defaults to an empty string. * @param array $filter_types_to_skip * (optional) An array of filter types to skip, or an empty array (default) * to skip no filter types. All of the format's filters will be applied, @@ -327,7 +328,7 @@ * * @ingroup sanitization */ -function check_markup($text, $format_id, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $filter_types_to_skip = array()) { +function check_markup($text, $format_id = NULL, $langcode = '', $filter_types_to_skip = array()) { $build = array( '#type' => 'processed_text', '#text' => $text, diff -u b/core/modules/filter/src/Element/ProcessedText.php b/core/modules/filter/src/Element/ProcessedText.php --- b/core/modules/filter/src/Element/ProcessedText.php +++ b/core/modules/filter/src/Element/ProcessedText.php @@ -27,7 +27,6 @@ $class = get_class($this); return array( '#text' => '', - '#format' => NULL, '#filter_types_to_skip' => array(), '#langcode' => '', '#pre_render' => array( @@ -65,7 +64,7 @@ * The passed-in element with the filtered text in '#markup'. * * @throws |InvalidArgumentException - * When no $format_id is specified. + * When $element['#format'] is NULL. * * @ingroup sanitization */ @@ -76,7 +75,7 @@ $langcode = $element['#langcode']; if (!isset($format_id)) { - throw new \InvalidArgumentException('Format ID is not set'); + throw new \InvalidArgumentException('$element[\'#format\'] must not be NULL.'); } // If the requested text format does not exist, the text cannot be filtered. /** @var \Drupal\filter\Entity\FilterFormat $format **/ only in patch2: unchanged: --- a/core/modules/comment/src/CommentViewBuilder.php +++ b/core/modules/comment/src/CommentViewBuilder.php @@ -157,7 +157,7 @@ public function buildComponents(array &$build, array $entities, array $displays, $build[$id]['signature'] = array( '#type' => 'processed_text', '#text' => $account->getSignature(), - '#format' => $account->getSignatureFormat(), + '#format' => $account->getSignatureFormat() ? $account->getSignatureFormat() : filter_fallback_format(), '#langcode' => $entity->language()->getId(), ); } only in patch2: unchanged: --- a/core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php +++ b/core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php @@ -38,7 +38,7 @@ public function viewElements(FieldItemListInterface $items) { $elements[$delta] = array( '#type' => 'processed_text', '#text' => $item->value, - '#format' => $item->format, + '#format' => isset($item->format) ? $item->format : filter_fallback_format(), '#langcode' => $item->getLangcode(), ); } only in patch2: unchanged: --- a/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php +++ b/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php @@ -85,7 +85,7 @@ public function viewElements(FieldItemListInterface $items) { $elements[$delta] = array( '#type' => 'processed_text', '#text' => NULL, - '#format' => $item->format, + '#format' => isset($item->format) ? $item->format : filter_fallback_format(), '#langcode' => $item->getLangcode(), ); only in patch2: unchanged: --- a/core/modules/views/src/Plugin/views/area/Text.php +++ b/core/modules/views/src/Plugin/views/area/Text.php @@ -63,7 +63,7 @@ public function render($empty = FALSE) { return array( '#type' => 'processed_text', '#text' => $this->tokenizeValue($this->options['content']), - '#format' => $format, + '#format' => isset($format) ? $format : filter_fallback_format(), ); }