Commit 45bc0552 authored by catch's avatar catch

Issue #2958429 by alexpott: Properly deprecate SafeMarkup::format()

parent 2e8be78f
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\BootstrapConfigStorageFactory; use Drupal\Core\Config\BootstrapConfigStorageFactory;
use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Logger\RfcLogLevel;
...@@ -273,7 +273,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { ...@@ -273,7 +273,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
} }
} }
// If the filename is still unknown, create a user-level error message. // If the filename is still unknown, create a user-level error message.
trigger_error(SafeMarkup::format('The following @type is missing from the file system: @name', ['@type' => $type, '@name' => $name]), E_USER_WARNING); trigger_error(new FormattableMarkup('The following @type is missing from the file system: @name', ['@type' => $type, '@name' => $name]), E_USER_WARNING);
} }
/** /**
...@@ -349,7 +349,7 @@ function t($string, array $args = [], array $options = []) { ...@@ -349,7 +349,7 @@ function t($string, array $args = [], array $options = []) {
* @see https://www.drupal.org/node/2302363 * @see https://www.drupal.org/node/2302363
*/ */
function format_string($string, array $args) { function format_string($string, array $args) {
return SafeMarkup::format($string, $args); return new FormattableMarkup($string, $args);
} }
/** /**
...@@ -981,10 +981,10 @@ function drupal_static_reset($name = NULL) { ...@@ -981,10 +981,10 @@ function drupal_static_reset($name = NULL) {
* Formats text for emphasized display in a placeholder inside a sentence. * Formats text for emphasized display in a placeholder inside a sentence.
* *
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. Use * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. Use
* \Drupal\Component\Utility\SafeMarkup::format() or Twig's "placeholder" * \Drupal\Component\Render\FormattableMarkup or Twig's "placeholder" filter
* filter instead. Note this method should not be used to simply emphasize a * instead. Note this method should not be used to simply emphasize a string
* string and therefore has few valid use-cases. Note also, that this method * and therefore has few valid use-cases. Note also, that this method does not
* does not mark the string as safe. * mark the string as safe.
* *
* @see https://www.drupal.org/node/2302363 * @see https://www.drupal.org/node/2302363
*/ */
......
...@@ -215,7 +215,7 @@ function valid_email_address($mail) { ...@@ -215,7 +215,7 @@ function valid_email_address($mail) {
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
* Use UrlHelper::stripDangerousProtocols() or UrlHelper::filterBadProtocol() * Use UrlHelper::stripDangerousProtocols() or UrlHelper::filterBadProtocol()
* instead. UrlHelper::stripDangerousProtocols() can be used in conjunction * instead. UrlHelper::stripDangerousProtocols() can be used in conjunction
* with \Drupal\Component\Utility\SafeMarkup::format() and an @variable * with \Drupal\Component\Render\FormattableMarkup and an @variable
* placeholder which will perform the necessary escaping. * placeholder which will perform the necessary escaping.
* UrlHelper::filterBadProtocol() is functionality equivalent to check_url() * UrlHelper::filterBadProtocol() is functionality equivalent to check_url()
* apart from the fact it is protected from double escaping bugs. Note that * apart from the fact it is protected from double escaping bugs. Note that
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Functions for error handling. * Functions for error handling.
*/ */
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Xss; use Drupal\Component\Utility\Xss;
use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Logger\RfcLogLevel;
use Drupal\Core\Render\Markup; use Drupal\Core\Render\Markup;
...@@ -178,7 +178,7 @@ function _drupal_log_error($error, $fatal = FALSE) { ...@@ -178,7 +178,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
if ($fatal) { if ($fatal) {
// When called from CLI, simply output a plain text message. // When called from CLI, simply output a plain text message.
// Should not translate the string to avoid errors producing more errors. // Should not translate the string to avoid errors producing more errors.
$response->setContent(html_entity_decode(strip_tags(SafeMarkup::format('%type: @message in %function (line %line of %file).', $error))) . "\n"); $response->setContent(html_entity_decode(strip_tags(new FormattableMarkup('%type: @message in %function (line %line of %file).', $error))) . "\n");
$response->send(); $response->send();
exit; exit;
} }
...@@ -189,7 +189,7 @@ function _drupal_log_error($error, $fatal = FALSE) { ...@@ -189,7 +189,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
if (error_displayable($error)) { if (error_displayable($error)) {
// When called from JavaScript, simply output the error message. // When called from JavaScript, simply output the error message.
// Should not translate the string to avoid errors producing more errors. // Should not translate the string to avoid errors producing more errors.
$response->setContent(SafeMarkup::format('%type: @message in %function (line %line of %file).', $error)); $response->setContent(new FormattableMarkup('%type: @message in %function (line %line of %file).', $error));
$response->send(); $response->send();
} }
exit; exit;
...@@ -226,10 +226,10 @@ function _drupal_log_error($error, $fatal = FALSE) { ...@@ -226,10 +226,10 @@ function _drupal_log_error($error, $fatal = FALSE) {
if ($error_level != ERROR_REPORTING_DISPLAY_VERBOSE) { if ($error_level != ERROR_REPORTING_DISPLAY_VERBOSE) {
// Without verbose logging, use a simple message. // Without verbose logging, use a simple message.
// We call SafeMarkup::format() directly here, rather than use t() since // We use \Drupal\Component\Render\FormattableMarkup directly here,
// we are in the middle of error handling, and we don't want t() to // rather than use t() since we are in the middle of error handling, and
// cause further errors. // we don't want t() to cause further errors.
$message = SafeMarkup::format('%type: @message in %function (line %line of %file).', $error); $message = new FormattableMarkup('%type: @message in %function (line %line of %file).', $error);
} }
else { else {
// With verbose logging, we will also include a backtrace. // With verbose logging, we will also include a backtrace.
...@@ -241,7 +241,7 @@ function _drupal_log_error($error, $fatal = FALSE) { ...@@ -241,7 +241,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
array_shift($backtrace); array_shift($backtrace);
// Generate a backtrace containing only scalar argument values. // Generate a backtrace containing only scalar argument values.
$error['@backtrace'] = Error::formatBacktrace($backtrace); $error['@backtrace'] = Error::formatBacktrace($backtrace);
$message = SafeMarkup::format('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $error); $message = new FormattableMarkup('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $error);
} }
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* @{ * @{
*/ */
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Render\Element; use Drupal\Core\Render\Element;
/** /**
...@@ -36,7 +36,7 @@ function template_preprocess_menu_local_task(&$variables) { ...@@ -36,7 +36,7 @@ function template_preprocess_menu_local_task(&$variables) {
$variables['is_active'] = TRUE; $variables['is_active'] = TRUE;
// Add text to indicate active tab for non-visual users. // Add text to indicate active tab for non-visual users.
$active = SafeMarkup::format('<span class="visually-hidden">@label</span>', ['@label' => t('(active tab)')]); $active = new FormattableMarkup('<span class="visually-hidden">@label</span>', ['@label' => t('(active tab)')]);
$link_text = t('@local-task-title@active', ['@local-task-title' => $link_text, '@active' => $active]); $link_text = t('@local-task-title@active', ['@local-task-title' => $link_text, '@active' => $active]);
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* column. * column.
*/ */
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\UrlHelper;
...@@ -60,7 +60,7 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header ...@@ -60,7 +60,7 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header
$ts['sort'] = 'asc'; $ts['sort'] = 'asc';
$image = ''; $image = '';
} }
$cell_content = \Drupal::l(SafeMarkup::format('@cell_content@image', ['@cell_content' => $cell_content, '@image' => $image]), new Url('<current>', [], [ $cell_content = \Drupal::l(new FormattableMarkup('@cell_content@image', ['@cell_content' => $cell_content, '@image' => $image]), new Url('<current>', [], [
'attributes' => ['title' => $title], 'attributes' => ['title' => $title],
'query' => array_merge($ts['query'], [ 'query' => array_merge($ts['query'], [
'sort' => $ts['sort'], 'sort' => $ts['sort'],
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Drupal\Component\Gettext; namespace Drupal\Component\Gettext;
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Render\FormattableMarkup;
/** /**
* Implements Gettext PO stream reader. * Implements Gettext PO stream reader.
...@@ -290,7 +290,7 @@ private function readLine() { ...@@ -290,7 +290,7 @@ private function readLine() {
} }
else { else {
// A comment following any other context is a syntax error. // A comment following any other context is a syntax error.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgstr" was expected but not found on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgstr" was expected but not found on line %line.', $log_vars);
return FALSE; return FALSE;
} }
return; return;
...@@ -300,7 +300,7 @@ private function readLine() { ...@@ -300,7 +300,7 @@ private function readLine() {
if ($this->context != 'MSGID') { if ($this->context != 'MSGID') {
// A plural form can only be added to an msgid directly. // A plural form can only be added to an msgid directly.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgid_plural" was expected but not found on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgid_plural" was expected but not found on line %line.', $log_vars);
return FALSE; return FALSE;
} }
...@@ -311,7 +311,7 @@ private function readLine() { ...@@ -311,7 +311,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line); $quoted = $this->parseQuoted($line);
if ($quoted === FALSE) { if ($quoted === FALSE) {
// The plural form must be wrapped in quotes. // The plural form must be wrapped in quotes.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains a syntax error on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains a syntax error on line %line.', $log_vars);
return FALSE; return FALSE;
} }
...@@ -338,7 +338,7 @@ private function readLine() { ...@@ -338,7 +338,7 @@ private function readLine() {
} }
elseif ($this->context == 'MSGID') { elseif ($this->context == 'MSGID') {
// We are currently already in the context, meaning we passed an id with no data. // We are currently already in the context, meaning we passed an id with no data.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgid" is unexpected on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgid" is unexpected on line %line.', $log_vars);
return FALSE; return FALSE;
} }
...@@ -349,7 +349,7 @@ private function readLine() { ...@@ -349,7 +349,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line); $quoted = $this->parseQuoted($line);
if ($quoted === FALSE) { if ($quoted === FALSE) {
// The message id must be wrapped in quotes. // The message id must be wrapped in quotes.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgid" on line %line.', $log_vars, $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgid" on line %line.', $log_vars, $log_vars);
return FALSE; return FALSE;
} }
...@@ -367,7 +367,7 @@ private function readLine() { ...@@ -367,7 +367,7 @@ private function readLine() {
} }
elseif (!empty($this->currentItem['msgctxt'])) { elseif (!empty($this->currentItem['msgctxt'])) {
// A context cannot apply to another context. // A context cannot apply to another context.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgctxt" is unexpected on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgctxt" is unexpected on line %line.', $log_vars);
return FALSE; return FALSE;
} }
...@@ -378,7 +378,7 @@ private function readLine() { ...@@ -378,7 +378,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line); $quoted = $this->parseQuoted($line);
if ($quoted === FALSE) { if ($quoted === FALSE) {
// The context string must be quoted. // The context string must be quoted.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgctxt" on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgctxt" on line %line.', $log_vars);
return FALSE; return FALSE;
} }
...@@ -396,13 +396,13 @@ private function readLine() { ...@@ -396,13 +396,13 @@ private function readLine() {
($this->context != 'MSGSTR_ARR')) { ($this->context != 'MSGSTR_ARR')) {
// Plural message strings must come after msgid, msgxtxt, // Plural message strings must come after msgid, msgxtxt,
// msgid_plural, or other msgstr[] entries. // msgid_plural, or other msgstr[] entries.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgstr[]" is unexpected on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgstr[]" is unexpected on line %line.', $log_vars);
return FALSE; return FALSE;
} }
// Ensure the plurality is terminated. // Ensure the plurality is terminated.
if (strpos($line, ']') === FALSE) { if (strpos($line, ']') === FALSE) {
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
return FALSE; return FALSE;
} }
...@@ -417,7 +417,7 @@ private function readLine() { ...@@ -417,7 +417,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line); $quoted = $this->parseQuoted($line);
if ($quoted === FALSE) { if ($quoted === FALSE) {
// The string must be quoted. // The string must be quoted.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgstr[]" on line %line.', $log_vars);
return FALSE; return FALSE;
} }
if (!isset($this->currentItem['msgstr']) || !is_array($this->currentItem['msgstr'])) { if (!isset($this->currentItem['msgstr']) || !is_array($this->currentItem['msgstr'])) {
...@@ -434,7 +434,7 @@ private function readLine() { ...@@ -434,7 +434,7 @@ private function readLine() {
if (($this->context != 'MSGID') && ($this->context != 'MSGCTXT')) { if (($this->context != 'MSGID') && ($this->context != 'MSGCTXT')) {
// Strings are only valid within an id or context scope. // Strings are only valid within an id or context scope.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: "msgstr" is unexpected on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: "msgstr" is unexpected on line %line.', $log_vars);
return FALSE; return FALSE;
} }
...@@ -445,7 +445,7 @@ private function readLine() { ...@@ -445,7 +445,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line); $quoted = $this->parseQuoted($line);
if ($quoted === FALSE) { if ($quoted === FALSE) {
// The string must be quoted. // The string must be quoted.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: invalid format for "msgstr" on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: invalid format for "msgstr" on line %line.', $log_vars);
return FALSE; return FALSE;
} }
...@@ -460,7 +460,7 @@ private function readLine() { ...@@ -460,7 +460,7 @@ private function readLine() {
$quoted = $this->parseQuoted($line); $quoted = $this->parseQuoted($line);
if ($quoted === FALSE) { if ($quoted === FALSE) {
// This string must be quoted. // This string must be quoted.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: string continuation expected on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: string continuation expected on line %line.', $log_vars);
return FALSE; return FALSE;
} }
...@@ -490,7 +490,7 @@ private function readLine() { ...@@ -490,7 +490,7 @@ private function readLine() {
} }
else { else {
// No valid context to append to. // No valid context to append to.
$this->errors[] = SafeMarkup::format('The translation stream %uri contains an error: unexpected string on line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri contains an error: unexpected string on line %line.', $log_vars);
return FALSE; return FALSE;
} }
return; return;
...@@ -503,7 +503,7 @@ private function readLine() { ...@@ -503,7 +503,7 @@ private function readLine() {
$this->currentItem = []; $this->currentItem = [];
} }
elseif ($this->context != 'COMMENT') { elseif ($this->context != 'COMMENT') {
$this->errors[] = SafeMarkup::format('The translation stream %uri ended unexpectedly at line %line.', $log_vars); $this->errors[] = new FormattableMarkup('The translation stream %uri ended unexpectedly at line %line.', $log_vars);
return FALSE; return FALSE;
} }
......
...@@ -95,6 +95,7 @@ public static function checkPlain($text) { ...@@ -95,6 +95,7 @@ public static function checkPlain($text) {
* @see https://www.drupal.org/node/2549395 * @see https://www.drupal.org/node/2549395
*/ */
public static function format($string, array $args) { public static function format($string, array $args) {
@trigger_error('SafeMarkup::format() is scheduled for removal in Drupal 9.0.0. Use \Drupal\Component\Render\FormattableMarkup. See https://www.drupal.org/node/2549395.', E_USER_DEPRECATED);
return new FormattableMarkup($string, $args); return new FormattableMarkup($string, $args);
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Drupal\Core\Config\Development; namespace Drupal\Core\Config\Development;
use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Config\ConfigCrudEvent; use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents; use Drupal\Core\Config\ConfigEvents;
use Drupal\Core\Config\Schema\SchemaCheckTrait; use Drupal\Core\Config\Schema\SchemaCheckTrait;
...@@ -90,7 +90,7 @@ public function onConfigSave(ConfigCrudEvent $event) { ...@@ -90,7 +90,7 @@ public function onConfigSave(ConfigCrudEvent $event) {
elseif (is_array($errors)) { elseif (is_array($errors)) {
$text_errors = []; $text_errors = [];
foreach ($errors as $key => $error) { foreach ($errors as $key => $error) {
$text_errors[] = SafeMarkup::format('@key @error', ['@key' => $key, '@error' => $error]); $text_errors[] = new FormattableMarkup('@key @error', ['@key' => $key, '@error' => $error]);
} }
throw new SchemaIncompleteException("Schema errors for $name with the following errors: " . implode(', ', $text_errors)); throw new SchemaIncompleteException("Schema errors for $name with the following errors: " . implode(', ', $text_errors));
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Render\FormattableMarkup;
/** /**
* An exception thrown if configuration with the same name already exists. * An exception thrown if configuration with the same name already exists.
...@@ -56,7 +56,7 @@ public function getExtension() { ...@@ -56,7 +56,7 @@ public function getExtension() {
* @return \Drupal\Core\Config\PreExistingConfigException * @return \Drupal\Core\Config\PreExistingConfigException
*/ */
public static function create($extension, array $config_objects) { public static function create($extension, array $config_objects) {
$message = SafeMarkup::format('Configuration objects (@config_names) provided by @extension already exist in active configuration', $message = new FormattableMarkup('Configuration objects (@config_names) provided by @extension already exist in active configuration',
[ [
'@config_names' => implode(', ', static::flattenConfigObjects($config_objects)), '@config_names' => implode(', ', static::flattenConfigObjects($config_objects)),
'@extension' => $extension '@extension' => $extension
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Drupal\Core\Entity; namespace Drupal\Core\Entity;
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Entity\Plugin\DataType\EntityReference; use Drupal\Core\Entity\Plugin\DataType\EntityReference;
use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\ChangedFieldItemList; use Drupal\Core\Field\ChangedFieldItemList;
...@@ -799,7 +799,7 @@ public function onChange($name) { ...@@ -799,7 +799,7 @@ public function onChange($name) {
// Update the default internal language cache. // Update the default internal language cache.
$this->setDefaultLangcode(); $this->setDefaultLangcode();
if (isset($this->translations[$this->defaultLangcode])) { if (isset($this->translations[$this->defaultLangcode])) {
$message = SafeMarkup::format('A translation already exists for the specified language (@langcode).', ['@langcode' => $this->defaultLangcode]); $message = new FormattableMarkup('A translation already exists for the specified language (@langcode).', ['@langcode' => $this->defaultLangcode]);
throw new \InvalidArgumentException($message); throw new \InvalidArgumentException($message);
} }
$this->updateFieldLangcodes($this->defaultLangcode); $this->updateFieldLangcodes($this->defaultLangcode);
...@@ -810,7 +810,7 @@ public function onChange($name) { ...@@ -810,7 +810,7 @@ public function onChange($name) {
$items = $this->get($this->langcodeKey); $items = $this->get($this->langcodeKey);
if ($items->value != $this->activeLangcode) { if ($items->value != $this->activeLangcode) {
$items->setValue($this->activeLangcode, FALSE); $items->setValue($this->activeLangcode, FALSE);
$message = SafeMarkup::format('The translation language cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]); $message = new FormattableMarkup('The translation language cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]);
throw new \LogicException($message); throw new \LogicException($message);
} }
} }
...@@ -821,7 +821,7 @@ public function onChange($name) { ...@@ -821,7 +821,7 @@ public function onChange($name) {
// read-only. See https://www.drupal.org/node/2443991. // read-only. See https://www.drupal.org/node/2443991.
if (isset($this->values[$this->defaultLangcodeKey]) && $this->get($this->defaultLangcodeKey)->value != $this->isDefaultTranslation()) { if (isset($this->values[$this->defaultLangcodeKey]) && $this->get($this->defaultLangcodeKey)->value != $this->isDefaultTranslation()) {
$this->get($this->defaultLangcodeKey)->setValue($this->isDefaultTranslation(), FALSE); $this->get($this->defaultLangcodeKey)->setValue($this->isDefaultTranslation(), FALSE);
$message = SafeMarkup::format('The default translation flag cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]); $message = new FormattableMarkup('The default translation flag cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]);
throw new \LogicException($message); throw new \LogicException($message);
} }
break; break;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Drupal\Core\EventSubscriber; namespace Drupal\Core\EventSubscriber;
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Utility\Error; use Drupal\Core\Utility\Error;
...@@ -98,10 +98,10 @@ public function onException(GetResponseForExceptionEvent $event) { ...@@ -98,10 +98,10 @@ public function onException(GetResponseForExceptionEvent $event) {
if (!$this->isErrorLevelVerbose()) { if (!$this->isErrorLevelVerbose()) {
// Without verbose logging, use a simple message. // Without verbose logging, use a simple message.
// We call SafeMarkup::format directly here, rather than use t() since // We use \Drupal\Component\Render\FormattableMarkup directly here,
// we are in the middle of error handling, and we don't want t() to // rather than use t() since we are in the middle of error handling, and
// cause further errors. // we don't want t() to cause further errors.
$message = SafeMarkup::format('%type: @message in %function (line %line of %file).', $error); $message = new FormattableMarkup('%type: @message in %function (line %line of %file).', $error);
} }
else { else {
// With verbose logging, we will also include a backtrace. // With verbose logging, we will also include a backtrace.
...@@ -119,7 +119,7 @@ public function onException(GetResponseForExceptionEvent $event) { ...@@ -119,