Commit f8629621 authored by catch's avatar catch

Issue #2514044 by dawehner, stefan.r, alexpott: Do not use SafeMarkup::format in exceptions

parent 158ca154
...@@ -174,7 +174,7 @@ function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) { ...@@ -174,7 +174,7 @@ function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) {
if (!empty($config_directories[$type])) { if (!empty($config_directories[$type])) {
return $config_directories[$type]; return $config_directories[$type];
} }
throw new \Exception(format_string('The configuration directory type %type does not exist.', array('%type' => $type))); throw new \Exception("The configuration directory type '$type' does not exist");
} }
/** /**
......
...@@ -244,7 +244,7 @@ public static function externalIsLocal($url, $base_url) { ...@@ -244,7 +244,7 @@ public static function externalIsLocal($url, $base_url) {
$base_parts = parse_url($base_url); $base_parts = parse_url($base_url);
if (empty($base_parts['host']) || empty($url_parts['host'])) { if (empty($base_parts['host']) || empty($url_parts['host'])) {
throw new \InvalidArgumentException(SafeMarkup::format('A path was passed when a fully qualified domain was expected.')); throw new \InvalidArgumentException('A path was passed when a fully qualified domain was expected.');
} }
if (!isset($url_parts['path']) || !isset($base_parts['path'])) { if (!isset($url_parts['path']) || !isset($base_parts['path'])) {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace Drupal\Core\Breadcrumb; namespace Drupal\Core\Breadcrumb;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
...@@ -95,7 +94,7 @@ public function build(RouteMatchInterface $route_match) { ...@@ -95,7 +94,7 @@ public function build(RouteMatchInterface $route_match) {
break; break;
} }
else { else {
throw new \UnexpectedValueException(SafeMarkup::format('Invalid breadcrumb returned by !class::build().', array('!class' => get_class($builder)))); throw new \UnexpectedValueException('Invalid breadcrumb returned by ' . get_class($builder) . '::build().');
} }
} }
// Allow modules to alter the breadcrumb. // Allow modules to alter the breadcrumb.
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\RefinableCacheableDependencyInterface; use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Cache\RefinableCacheableDependencyTrait; use Drupal\Core\Cache\RefinableCacheableDependencyTrait;
...@@ -99,24 +98,17 @@ public function setName($name) { ...@@ -99,24 +98,17 @@ public function setName($name) {
public static function validateName($name) { public static function validateName($name) {
// The name must be namespaced by owner. // The name must be namespaced by owner.
if (strpos($name, '.') === FALSE) { if (strpos($name, '.') === FALSE) {
throw new ConfigNameException(SafeMarkup::format('Missing namespace in Config object name @name.', array( throw new ConfigNameException("Missing namespace in Config object name $name.");
'@name' => $name,
)));
} }
// The name must be shorter than Config::MAX_NAME_LENGTH characters. // The name must be shorter than Config::MAX_NAME_LENGTH characters.
if (strlen($name) > self::MAX_NAME_LENGTH) { if (strlen($name) > self::MAX_NAME_LENGTH) {
throw new ConfigNameException(SafeMarkup::format('Config object name @name exceeds maximum allowed length of @length characters.', array( throw new ConfigNameException("Config object name $name exceeds maximum allowed length of " . static::MAX_NAME_LENGTH . " characters.");
'@name' => $name,
'@length' => self::MAX_NAME_LENGTH,
)));
} }
// The name must not contain any of the following characters: // The name must not contain any of the following characters:
// : ? * < > " ' / \ // : ? * < > " ' / \
if (preg_match('/[:?*<>"\'\/\\\\]/', $name)) { if (preg_match('/[:?*<>"\'\/\\\\]/', $name)) {
throw new ConfigNameException(SafeMarkup::format('Invalid character in Config object name @name.', array( throw new ConfigNameException("Invalid character in Config object name $name.");
'@name' => $name,
)));
} }
} }
...@@ -224,7 +216,7 @@ public function set($key, $value) { ...@@ -224,7 +216,7 @@ public function set($key, $value) {
protected function validateKeys(array $data) { protected function validateKeys(array $data) {
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if (strpos($key, '.') !== FALSE) { if (strpos($key, '.') !== FALSE) {
throw new ConfigValueException(SafeMarkup::format('@key key contains a dot which is not supported.', array('@key' => $key))); throw new ConfigValueException("$key key contains a dot which is not supported.");
} }
if (is_array($value)) { if (is_array($value)) {
$this->validateKeys($value); $this->validateKeys($value);
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Extension\ModuleInstallerInterface; use Drupal\Core\Extension\ModuleInstallerInterface;
use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Config\Entity\ImportableEntityStorageInterface; use Drupal\Core\Config\Entity\ImportableEntityStorageInterface;
use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityStorageException;
...@@ -763,7 +762,7 @@ protected function processConfiguration($collection, $op, $name) { ...@@ -763,7 +762,7 @@ protected function processConfiguration($collection, $op, $name) {
} }
} }
catch (\Exception $e) { catch (\Exception $e) {
$this->logError($this->t('Unexpected error during import with operation @op for @name: @message', array('@op' => $op, '@name' => $name, '@message' => $e->getMessage()))); $this->logError($this->t('Unexpected error during import with operation @op for @name: !message', array('@op' => $op, '@name' => $name, '!message' => $e->getMessage())));
// Error for that operation was logged, mark it as processed so that // Error for that operation was logged, mark it as processed so that
// the import can continue. // the import can continue.
$this->setProcessedConfiguration($collection, $op, $name); $this->setProcessedConfiguration($collection, $op, $name);
...@@ -972,7 +971,7 @@ protected function importInvokeOwner($collection, $op, $name) { ...@@ -972,7 +971,7 @@ protected function importInvokeOwner($collection, $op, $name) {
// Call to the configuration entity's storage to handle the configuration // Call to the configuration entity's storage to handle the configuration
// change. // change.
if (!($entity_storage instanceof ImportableEntityStorageInterface)) { if (!($entity_storage instanceof ImportableEntityStorageInterface)) {
throw new EntityStorageException(SafeMarkup::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type))); throw new EntityStorageException(sprintf('The entity storage "%s" for the "%s" entity type does not support imports', get_class($entity_storage), $entity_type));
} }
$entity_storage->$method($name, $new_config, $old_config); $entity_storage->$method($name, $new_config, $old_config);
$this->setProcessedConfiguration($collection, $op, $name); $this->setProcessedConfiguration($collection, $op, $name);
...@@ -1018,7 +1017,7 @@ protected function importInvokeRename($collection, $rename_name) { ...@@ -1018,7 +1017,7 @@ protected function importInvokeRename($collection, $rename_name) {
// Call to the configuration entity's storage to handle the configuration // Call to the configuration entity's storage to handle the configuration
// change. // change.
if (!($entity_storage instanceof ImportableEntityStorageInterface)) { if (!($entity_storage instanceof ImportableEntityStorageInterface)) {
throw new EntityStorageException(SafeMarkup::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type_id))); throw new EntityStorageException(sprintf("The entity storage '%s' for the '%s' entity type does not support imports", get_class($entity_storage), $entity_type_id));
} }
$entity_storage->importRename($names['old_name'], $new_config, $old_config); $entity_storage->importRename($names['old_name'], $new_config, $old_config);
$this->setProcessedConfiguration($collection, 'rename', $rename_name); $this->setProcessedConfiguration($collection, 'rename', $rename_name);
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace Drupal\Core\Config\Entity; namespace Drupal\Core\Config\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\ConfigException; use Drupal\Core\Config\ConfigException;
use Drupal\Core\Config\Schema\SchemaIncompleteException; use Drupal\Core\Config\Schema\SchemaIncompleteException;
...@@ -278,7 +277,7 @@ public function toArray() { ...@@ -278,7 +277,7 @@ public function toArray() {
$config_name = $entity_type->getConfigPrefix() . '.' . $this->id(); $config_name = $entity_type->getConfigPrefix() . '.' . $this->id();
$definition = $this->getTypedConfig()->getDefinition($config_name); $definition = $this->getTypedConfig()->getDefinition($config_name);
if (!isset($definition['mapping'])) { if (!isset($definition['mapping'])) {
throw new SchemaIncompleteException(SafeMarkup::format('Incomplete or missing schema for @config_name', array('@config_name' => $config_name))); throw new SchemaIncompleteException("Incomplete or missing schema for $config_name");
} }
$properties_to_export = array_combine(array_keys($definition['mapping']), array_keys($definition['mapping'])); $properties_to_export = array_combine(array_keys($definition['mapping']), array_keys($definition['mapping']));
} }
...@@ -331,7 +330,7 @@ public function preSave(EntityStorageInterface $storage) { ...@@ -331,7 +330,7 @@ public function preSave(EntityStorageInterface $storage) {
->execute(); ->execute();
$matched_entity = reset($matching_entities); $matched_entity = reset($matching_entities);
if (!empty($matched_entity) && ($matched_entity != $this->id()) && $matched_entity != $this->getOriginalId()) { if (!empty($matched_entity) && ($matched_entity != $this->id()) && $matched_entity != $this->getOriginalId()) {
throw new ConfigDuplicateUUIDException(SafeMarkup::format('Attempt to save a configuration entity %id with UUID %uuid when this UUID is already used for %matched', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%matched' => $matched_entity))); throw new ConfigDuplicateUUIDException("Attempt to save a configuration entity '{$this->id()}' with UUID '{$this->uuid()}' when this UUID is already used for '$matched_entity'");
} }
// If this entity is not new, load the original entity for comparison. // If this entity is not new, load the original entity for comparison.
...@@ -339,7 +338,7 @@ public function preSave(EntityStorageInterface $storage) { ...@@ -339,7 +338,7 @@ public function preSave(EntityStorageInterface $storage) {
$original = $storage->loadUnchanged($this->getOriginalId()); $original = $storage->loadUnchanged($this->getOriginalId());
// Ensure that the UUID cannot be changed for an existing entity. // Ensure that the UUID cannot be changed for an existing entity.
if ($original && ($original->uuid() != $this->uuid())) { if ($original && ($original->uuid() != $this->uuid())) {
throw new ConfigDuplicateUUIDException(SafeMarkup::format('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid()))); throw new ConfigDuplicateUUIDException("Attempt to save a configuration entity '{$this->id()}' with UUID '{$this->uuid()}' when this entity already exists with UUID '{$original->uuid()}'");
} }
} }
if (!$this->isSyncing() && !$this->trustedData) { if (!$this->isSyncing() && !$this->trustedData) {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace Drupal\Core\Config\Entity; namespace Drupal\Core\Config\Entity;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ConfigImporterException; use Drupal\Core\Config\ConfigImporterException;
...@@ -259,10 +258,7 @@ public function save(EntityInterface $entity) { ...@@ -259,10 +258,7 @@ public function save(EntityInterface $entity) {
// @todo Consider moving this to a protected method on the parent class, and // @todo Consider moving this to a protected method on the parent class, and
// abstracting it for all entity types. // abstracting it for all entity types.
if (strlen($entity->get($this->idKey)) > self::MAX_ID_LENGTH) { if (strlen($entity->get($this->idKey)) > self::MAX_ID_LENGTH) {
throw new ConfigEntityIdLengthException(SafeMarkup::format('Configuration entity ID @id exceeds maximum allowed length of @length characters.', array( throw new ConfigEntityIdLengthException("Configuration entity ID {$entity->get($this->idKey)} exceeds maximum allowed length of " . self::MAX_ID_LENGTH . " characters.");
'@id' => $entity->get($this->idKey),
'@length' => self::MAX_ID_LENGTH,
)));
} }
return parent::save($entity); return parent::save($entity);
...@@ -404,7 +400,7 @@ public function importUpdate($name, Config $new_config, Config $old_config) { ...@@ -404,7 +400,7 @@ public function importUpdate($name, Config $new_config, Config $old_config) {
$id = static::getIDFromConfigName($name, $this->entityType->getConfigPrefix()); $id = static::getIDFromConfigName($name, $this->entityType->getConfigPrefix());
$entity = $this->load($id); $entity = $this->load($id);
if (!$entity) { if (!$entity) {
throw new ConfigImporterException(SafeMarkup::format('Attempt to update non-existing entity "@id".', array('@id' => $id))); throw new ConfigImporterException("Attempt to update non-existing entity '$id'.");
} }
$entity->setSyncing(TRUE); $entity->setSyncing(TRUE);
$entity = $this->updateFromStorageRecord($entity, $new_config->get()); $entity = $this->updateFromStorageRecord($entity, $new_config->get());
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
use Drupal\Core\Config\Entity\Exception\ConfigEntityStorageClassException; use Drupal\Core\Config\Entity\Exception\ConfigEntityStorageClassException;
use Drupal\Core\Entity\EntityType; use Drupal\Core\Entity\EntityType;
use Drupal\Core\Config\ConfigPrefixLengthException; use Drupal\Core\Config\ConfigPrefixLengthException;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Provides an implementation of a configuration entity type and its metadata. * Provides an implementation of a configuration entity type and its metadata.
...@@ -93,10 +92,7 @@ public function getConfigPrefix() { ...@@ -93,10 +92,7 @@ public function getConfigPrefix() {
} }
if (strlen($config_prefix) > static::PREFIX_LENGTH) { if (strlen($config_prefix) > static::PREFIX_LENGTH) {
throw new ConfigPrefixLengthException(SafeMarkup::format('The configuration file name prefix @config_prefix exceeds the maximum character limit of @max_char.', array( throw new ConfigPrefixLengthException("The configuration file name prefix $config_prefix exceeds the maximum character limit of " . static::PREFIX_LENGTH);
'@config_prefix' => $config_prefix,
'@max_char' => static::PREFIX_LENGTH,
)));
} }
return $config_prefix; return $config_prefix;
} }
...@@ -158,7 +154,7 @@ public function setStorageClass($class) { ...@@ -158,7 +154,7 @@ public function setStorageClass($class) {
*/ */
protected function checkStorageClass($class) { protected function checkStorageClass($class) {
if (!is_a($class, 'Drupal\Core\Config\Entity\ConfigEntityStorage', TRUE)) { if (!is_a($class, 'Drupal\Core\Config\Entity\ConfigEntityStorage', TRUE)) {
throw new ConfigEntityStorageClassException(SafeMarkup::format('@class is not \Drupal\Core\Config\Entity\ConfigEntityStorage or it does not extend it', ['@class' => $class])); throw new ConfigEntityStorageClassException("$class is not \\Drupal\\Core\\Config\\Entity\\ConfigEntityStorage or it does not extend it");
} }
} }
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
use Drupal\Component\Serialization\Yaml; use Drupal\Component\Serialization\Yaml;
use Drupal\Component\Serialization\Exception\InvalidDataTypeException; use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Defines the file storage. * Defines the file storage.
...@@ -101,10 +100,7 @@ public function read($name) { ...@@ -101,10 +100,7 @@ public function read($name) {
$data = $this->decode($data); $data = $this->decode($data);
} }
catch (InvalidDataTypeException $e) { catch (InvalidDataTypeException $e) {
throw new UnsupportedDataTypeConfigException(SafeMarkup::format('Invalid data type in config @name: !message', array( throw new UnsupportedDataTypeConfigException("Invalid data type in config $name: {$e->getMessage()}");
'@name' => $name,
'!message' => $e->getMessage(),
)));
} }
return $data; return $data;
} }
...@@ -130,10 +126,7 @@ public function write($name, array $data) { ...@@ -130,10 +126,7 @@ public function write($name, array $data) {
$data = $this->encode($data); $data = $this->encode($data);
} }
catch (InvalidDataTypeException $e) { catch (InvalidDataTypeException $e) {
throw new StorageException(SafeMarkup::format('Invalid data type in config @name: !message', array( throw new StorageException("Invalid data type in config $name: {$e->getMessage()}");
'@name' => $name,
'!message' => $e->getMessage(),
)));
} }
$target = $this->getFilePath($name); $target = $this->getFilePath($name);
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Component\Utility\SafeMarkup;
/** /**
* Defines the immutable configuration object. * Defines the immutable configuration object.
* *
...@@ -31,21 +29,21 @@ class ImmutableConfig extends Config { ...@@ -31,21 +29,21 @@ class ImmutableConfig extends Config {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function set($key, $value) { public function set($key, $value) {
throw new ImmutableConfigException(SafeMarkup::format('Can not set values on immutable configuration !name:!key. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName(), '!key' => $key])); throw new ImmutableConfigException("Can not set values on immutable configuration {$this->getName()}:$key. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function clear($key) { public function clear($key) {
throw new ImmutableConfigException(SafeMarkup::format('Can not clear !key key in immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName(), '!key' => $key])); throw new ImmutableConfigException("Can not clear $key key in immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function save($has_trusted_data = FALSE) { public function save($has_trusted_data = FALSE) {
throw new ImmutableConfigException(SafeMarkup::format('Can not save immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName()])); throw new ImmutableConfigException("Can not save immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
} }
/** /**
...@@ -55,7 +53,7 @@ public function save($has_trusted_data = FALSE) { ...@@ -55,7 +53,7 @@ public function save($has_trusted_data = FALSE) {
* The configuration object. * The configuration object.
*/ */
public function delete() { public function delete() {
throw new ImmutableConfigException(SafeMarkup::format('Can not delete immutable configuration !name. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object', ['!name' => $this->getName()])); throw new ImmutableConfigException("Can not delete immutable configuration {$this->getName()}. Use \\Drupal\\Core\\Config\\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object");
} }
} }
...@@ -91,9 +91,7 @@ public function getFilePath($name) { ...@@ -91,9 +91,7 @@ public function getFilePath($name) {
} }
// If any code in the early installer requests a configuration object that // If any code in the early installer requests a configuration object that
// does not exist anywhere as default config, then that must be mistake. // does not exist anywhere as default config, then that must be mistake.
throw new StorageException(format_string('Missing configuration file: @name', array( throw new StorageException("Missing configuration file: $name");
'@name' => $name,
)));
} }
/** /**
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace Drupal\Core\Config\Schema; namespace Drupal\Core\Config\Schema;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\TypedData\TypedData; use Drupal\Core\TypedData\TypedData;
...@@ -94,7 +93,7 @@ public function get($name) { ...@@ -94,7 +93,7 @@ public function get($name) {
return $element; return $element;
} }
else { else {
throw new \InvalidArgumentException(SafeMarkup::format("The configuration property @key doesn't exist.", array('@key' => $name))); throw new \InvalidArgumentException("The configuration property $name doesn't exist.");
} }
} }
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Config\Schema\Ignore; use Drupal\Core\Config\Schema\Ignore;
use Drupal\Core\TypedData\PrimitiveInterface; use Drupal\Core\TypedData\PrimitiveInterface;
use Drupal\Core\TypedData\Type\FloatInterface; use Drupal\Core\TypedData\Type\FloatInterface;
...@@ -163,10 +162,7 @@ protected function validateValue($key, $value) { ...@@ -163,10 +162,7 @@ protected function validateValue($key, $value) {
} }
} }
elseif ($value !== NULL && !is_scalar($value)) { elseif ($value !== NULL && !is_scalar($value)) {
throw new UnsupportedDataTypeConfigException(SafeMarkup::format('Invalid data type for config element @name:@key', array( throw new UnsupportedDataTypeConfigException("Invalid data type for config element {$this->getName()}:$key");
'@name' => $this->getName(),
'@key' => $key,
)));
} }
} }
...@@ -213,10 +209,7 @@ protected function castValue($key, $value) { ...@@ -213,10 +209,7 @@ protected function castValue($key, $value) {
else { else {
// Throw exception on any non-scalar or non-array value. // Throw exception on any non-scalar or non-array value.
if (!is_array($value)) { if (!is_array($value)) {
throw new UnsupportedDataTypeConfigException(SafeMarkup::format('Invalid data type for config element @name:@key', array( throw new UnsupportedDataTypeConfigException("Invalid data type for config element {$this->getName()}:$key");
'@name' => $this->getName(),
'@key' => $key,
)));
} }
// Recurse into any nested keys. // Recurse into any nested keys.
foreach ($value as $nested_value_key => $nested_value) { foreach ($value as $nested_value_key => $nested_value) {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\MemoryBackend; use Drupal\Core\Cache\MemoryBackend;
use Drupal\Core\Config\Entity\ConfigDependencyManager; use Drupal\Core\Config\Entity\ConfigDependencyManager;
use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\DependencyInjection\DependencySerializationTrait;
...@@ -196,7 +195,7 @@ protected function addChangeList($collection, $op, array $changes, array $sort_o ...@@ -196,7 +195,7 @@ protected function addChangeList($collection, $op, array $changes, array $sort_o
// ensure the array is keyed from 0. // ensure the array is keyed from 0.
$this->changelist[$collection][$op] = array_values(array_intersect($sort_order, $this->changelist[$collection][$op])); $this->changelist[$collection][$op] = array_values(array_intersect($sort_order, $this->changelist[$collection][$op]));
if ($count != count($this->changelist[$collection][$op])) { if ($count != count($this->changelist[$collection][$op])) {
throw new \InvalidArgumentException(SafeMarkup::format('Sorting the @op changelist should not change its length.', array('@op' => $op))); throw new \InvalidArgumentException("Sorting the $op changelist should not change its length.");
} }
} }
} }
......
...@@ -88,14 +88,14 @@ public function onConfigSave(ConfigCrudEvent $event) { ...@@ -88,14 +88,14 @@ public function onConfigSave(ConfigCrudEvent $event) {
$this->checked[$name . ':' . $checksum] = TRUE; $this->checked[$name . ':' . $checksum] = TRUE;
$errors = $this->checkConfigSchema($this->typedManager, $name, $data); $errors = $this->checkConfigSchema($this->typedManager, $name, $data);
if ($errors === FALSE) { if ($errors === FALSE) {
throw new SchemaIncompleteException(SafeMarkup::format('No schema for @config_name', array('@config_name' => $name))); throw new SchemaIncompleteException("No schema for $name");
} }
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', array('@key' => $key, '@error' => $error)); $text_errors[] = SafeMarkup::format('@key @error', array('@key' => $key, '@error' => $error));
} }
throw new SchemaIncompleteException(SafeMarkup::format('Schema errors for @config_name with the following errors: @errors', array('@config_name' => $name, '@errors' => implode(', ', $text_errors)))); throw new SchemaIncompleteException("Schema errors for $name with the following errors: " . implode(', ', $text_errors));
} }
} }
} }
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\Schema\ArrayElement; use Drupal\Core\Config\Schema\ArrayElement;
use Drupal\Core\Config\Schema\ConfigSchemaAlterException; use Drupal\Core\Config\Schema\ConfigSchemaAlterException;
...@@ -324,18 +323,18 @@ protected function alterDefinitions(&$definitions) { ...@@ -324,18 +323,18 @@ protected function alterDefinitions(&$definitions) {
parent::alterDefinitions($definitions); parent::alterDefinitions($definitions);
$altered_schema = array_keys($definitions); $altered_schema = array_keys($definitions);
if ($discovered_schema != $altered_schema) { if ($discovered_schema != $altered_schema) {
$added_keys = array_diff($altered_schema, $discovered_schema); $added_keys = implode(',', array_diff($altered_schema, $discovered_schema));
$removed_keys = array_diff($discovered_schema, $altered_schema); $removed_keys = implode(',', array_diff($discovered_schema, $altered_schema));
if (!empty($added_keys) && !empty($removed_keys)) { if (!empty($added_keys) && !empty($removed_keys)) {
$message = 'Invoking hook_config_schema_info_alter() has added (@added) and removed (@removed) schema definitions'; $message = "Invoking hook_config_schema_info_alter() has added ($added_keys) and removed ($removed_keys) schema definitions";
} }
elseif (!empty($added_keys)) { elseif (!empty($added_keys)) {
$message = 'Invoking hook_config_schema_info_alter() has added (@added) schema definitions'; $message = "Invoking hook_config_schema_info_alter() has added ($added_keys) schema definitions";
} }
else { else {
$message = 'Invoking hook_config_schema_info_alter() has removed (@removed) schema definitions'; $message = "Invoking hook_config_schema_info_alter() has removed ($removed_keys) schema definitions";