From dc254723dbce37631b1844e671adcaeb3262dff1 Mon Sep 17 00:00:00 2001
From: Mac_Weber <Mac_Weber@789986.no-reply.drupal.org>
Date: Thu, 10 Dec 2015 20:55:31 -0200
Subject: [PATCH] Issue #2055851 by dawehner, Mac_Weber: Remove translation of
 exception messages

---
 core/includes/common.inc                                    |  3 ++-
 core/includes/install.core.inc                              |  4 ++--
 core/includes/install.inc                                   |  5 +++--
 core/includes/update.inc                                    |  2 +-
 core/lib/Drupal/Core/Archiver/Zip.php                       |  4 +++-
 core/lib/Drupal/Core/Database/Query/Merge.php               |  2 +-
 core/lib/Drupal/Core/Database/Schema.php                    |  3 ++-
 core/lib/Drupal/Core/Updater/Updater.php                    | 13 +++++++------
 core/modules/contextual/src/ContextualController.php        |  2 +-
 .../dblog/src/Plugin/rest/resource/DBLogResource.php        |  5 +++--
 core/modules/field/field.api.php                            |  2 +-
 core/modules/field/field.purge.inc                          |  3 ++-
 core/modules/node/node.module                               |  2 +-
 core/modules/options/options.module                         |  3 ++-
 core/modules/rdf/rdf.module                                 |  3 ++-
 .../system/tests/modules/common_test/common_test.module     |  2 +-
 core/modules/update/update.manager.inc                      |  3 ++-
 17 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/core/includes/common.inc b/core/includes/common.inc
index 5d62aad..51505cd 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -8,6 +8,7 @@
  * a cached page are instead located in bootstrap.inc.
  */
 
+use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Component\Serialization\Json;
 use Drupal\Component\Utility\Bytes;
 use Drupal\Component\Utility\Html;
@@ -1247,7 +1248,7 @@ function archiver_get_archiver($file) {
   // Archivers can only work on local paths
   $filepath = drupal_realpath($file);
   if (!is_file($filepath)) {
-    throw new Exception(t('Archivers can only operate on local files: %file not supported', array('%file' => $file)));
+    throw new Exception(new FormattableMarkup('Archivers can only operate on local files: %file not supported', array('%file' => $file)));
   }
   return \Drupal::service('plugin.manager.archiver')->getInstance(array('filepath' => $filepath));
 }
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 7b66911..eca5453 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -1180,7 +1180,7 @@ function install_select_profile(&$install_state) {
     else {
       // The non-interactive installer requires a profile parameter.
       if (!$install_state['interactive']) {
-        throw new InstallerException(t('Missing profile parameter.'));
+        throw new InstallerException('Missing profile parameter.');
       }
       // Otherwise, display a form to select a profile.
       return install_get_form('Drupal\Core\Installer\Form\SelectProfileForm', $install_state);
@@ -1316,7 +1316,7 @@ function install_select_language(&$install_state) {
         return;
       }
       else {
-        throw new InstallerException(t('You must select a language to continue the installation.'));
+        throw new InstallerException('You must select a language to continue the installation.');
       }
     }
   }
diff --git a/core/includes/install.inc b/core/includes/install.inc
index c9fd75d..6a53e0e 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -7,6 +7,7 @@
 
 use Drupal\Component\Utility\Unicode;
 use Symfony\Component\HttpFoundation\RedirectResponse;
+use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Component\Utility\Crypt;
 use Drupal\Component\Utility\OpCodeCache;
 use Drupal\Component\Utility\UrlHelper;
@@ -335,7 +336,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
 
     // Write the new settings file.
     if (file_put_contents($settings_file, $buffer) === FALSE) {
-      throw new Exception(t('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file)));
+      throw new Exception(new FormattableMarkup('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file)));
     }
     else {
       // In case any $settings variables were written, import them into the
@@ -352,7 +353,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
     }
   }
   else {
-    throw new Exception(t('Failed to open %settings. Verify the file permissions.', array('%settings' => $settings_file)));
+    throw new Exception(new FormattableMarkup('Failed to open %settings. Verify the file permissions.', array('%settings' => $settings_file)));
   }
 }
 
diff --git a/core/includes/update.inc b/core/includes/update.inc
index 68401a9..dc1df80 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -137,7 +137,7 @@ function update_set_schema($module, $schema_version) {
  * example:
  * @code
  * use Drupal\Core\Utility\UpdateException;
- * throw new UpdateException(t('Description of what went wrong'));
+ * throw new UpdateException('Description of what went wrong');
  * @endcode
  *
  * If an exception is thrown, the current update and all updates that depend on
diff --git a/core/lib/Drupal/Core/Archiver/Zip.php b/core/lib/Drupal/Core/Archiver/Zip.php
index 15500f7..599adda 100644
--- a/core/lib/Drupal/Core/Archiver/Zip.php
+++ b/core/lib/Drupal/Core/Archiver/Zip.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\Core\Archiver;
 
+use Drupal\Component\Render\FormattableMarkup;
+
 /**
  * Defines a archiver implementation for .zip files.
  *
@@ -34,7 +36,7 @@ class Zip implements ArchiverInterface {
   public function __construct($file_path) {
     $this->zip = new \ZipArchive();
     if ($this->zip->open($file_path) !== TRUE) {
-      throw new ArchiverException(t('Cannot open %file_path', array('%file_path' => $file_path)));
+      throw new ArchiverException(new FormattableMarkup('Cannot open %file_path', array('%file_path' => $file_path)));
     }
   }
 
diff --git a/core/lib/Drupal/Core/Database/Query/Merge.php b/core/lib/Drupal/Core/Database/Query/Merge.php
index c292894..8946bda 100644
--- a/core/lib/Drupal/Core/Database/Query/Merge.php
+++ b/core/lib/Drupal/Core/Database/Query/Merge.php
@@ -362,7 +362,7 @@ public function execute() {
 
     try {
       if (!count($this->condition)) {
-        throw new InvalidMergeQueryException(t('Invalid merge query: no conditions'));
+        throw new InvalidMergeQueryException('Invalid merge query: no conditions');
       }
       $select = $this->connection->select($this->conditionTable)
         ->condition($this->condition);
diff --git a/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php
index c3ef301..9221664 100644
--- a/core/lib/Drupal/Core/Database/Schema.php
+++ b/core/lib/Drupal/Core/Database/Schema.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Database;
 
+use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Database\Query\Condition;
 use Drupal\Core\Database\Query\PlaceholderInterface;
 
@@ -594,7 +595,7 @@ public function fieldExists($table, $column) {
    */
   public function createTable($name, $table) {
     if ($this->tableExists($name)) {
-      throw new SchemaObjectExistsException(t('Table @name already exists.', array('@name' => $name)));
+      throw new SchemaObjectExistsException(new FormattableMarkup('Table @name already exists.', array('@name' => $name)));
     }
     $statements = $this->createTableSql($name, $table);
     foreach ($statements as $statement) {
diff --git a/core/lib/Drupal/Core/Updater/Updater.php b/core/lib/Drupal/Core/Updater/Updater.php
index 4bd6172..3e42e5c 100644
--- a/core/lib/Drupal/Core/Updater/Updater.php
+++ b/core/lib/Drupal/Core/Updater/Updater.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Updater;
 
+use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\FileTransfer\FileTransferException;
 use Drupal\Core\FileTransfer\FileTransfer;
@@ -70,7 +71,7 @@ public static function factory($source, $root) {
       $updater = self::getUpdaterFromDirectory($source);
     }
     else {
-      throw new UpdaterException(t('Unable to determine the type of the source directory.'));
+      throw new UpdaterException('Unable to determine the type of the source directory.');
     }
     return new $updater($source, $root);
   }
@@ -95,7 +96,7 @@ public static function getUpdaterFromDirectory($directory) {
         return $class;
       }
     }
-    throw new UpdaterException(t('Cannot determine the type of project.'));
+    throw new UpdaterException('Cannot determine the type of project.');
   }
 
   /**
@@ -179,7 +180,7 @@ public static function getProjectTitle($directory) {
     $info_file = self::findInfoFile($directory);
     $info = \Drupal::service('info_parser')->parse($info_file);
     if (empty($info)) {
-      throw new UpdaterException(t('Unable to parse info file: %info_file.', array('%info_file' => $info_file)));
+      throw new UpdaterException(new FormattableMarkup('Unable to parse info file: %info_file.', array('%info_file' => $info_file)));
     }
     return $info['name'];
   }
@@ -229,7 +230,7 @@ public function update(&$filetransfer, $overrides = array()) {
 
       if (!$this->name) {
         // This is bad, don't want to delete the install directory.
-        throw new UpdaterException(t('Fatal error in update, cowardly refusing to wipe out the install directory.'));
+        throw new UpdaterException('Fatal error in update, cowardly refusing to wipe out the install directory.');
       }
 
       // Make sure the installation parent directory exists and is writable.
@@ -254,7 +255,7 @@ public function update(&$filetransfer, $overrides = array()) {
       return $this->postUpdateTasks();
     }
     catch (FileTransferException $e) {
-      throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', array('@reason' => strtr($e->getMessage(), $e->arguments))));
+      throw new UpdaterFileTransferException(new FormattableMarkup('File Transfer failed, reason: @reason', array('@reason' => strtr($e->getMessage(), $e->arguments))));
     }
   }
 
@@ -292,7 +293,7 @@ public function install(&$filetransfer, $overrides = array()) {
       return $this->postInstallTasks();
     }
     catch (FileTransferException $e) {
-      throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', array('@reason' => strtr($e->getMessage(), $e->arguments))));
+      throw new UpdaterFileTransferException(new FormattableMarkup('File Transfer failed, reason: @reason', array('@reason' => strtr($e->getMessage(), $e->arguments))));
     }
   }
 
diff --git a/core/modules/contextual/src/ContextualController.php b/core/modules/contextual/src/ContextualController.php
index 62ee55a..ba7cce1 100644
--- a/core/modules/contextual/src/ContextualController.php
+++ b/core/modules/contextual/src/ContextualController.php
@@ -34,7 +34,7 @@ class ContextualController implements ContainerAwareInterface {
   public function render(Request $request) {
     $ids = $request->request->get('ids');
     if (!isset($ids)) {
-      throw new BadRequestHttpException(t('No contextual ids specified.'));
+      throw new BadRequestHttpException('No contextual ids specified.');
     }
 
     $rendered = array();
diff --git a/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php b/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php
index 56740ca..7f2cb16 100644
--- a/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php
+++ b/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\dblog\Plugin\rest\resource;
 
+use Drupal\Component\Render\FormattableMarkup;
 use Drupal\rest\Plugin\ResourceBase;
 use Drupal\rest\ResourceResponse;
 use Symfony\Component\HttpKernel\Exception\HttpException;
@@ -46,9 +47,9 @@ public function get($id = NULL) {
         return new ResourceResponse($record);
       }
 
-      throw new NotFoundHttpException(t('Log entry with ID @id was not found', array('@id' => $id)));
+      throw new NotFoundHttpException(new FormattableMarkup('Log entry with ID @id was not found', array('@id' => $id)));
     }
 
-    throw new HttpException(t('No log entry ID was provided'));
+    throw new HttpException('No log entry ID was provided');
   }
 }
diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php
index a066e6a..3d67470 100644
--- a/core/modules/field/field.api.php
+++ b/core/modules/field/field.api.php
@@ -80,7 +80,7 @@ function hook_field_storage_config_update_forbid(\Drupal\field\FieldStorageConfi
     $prior_allowed_values = $prior_field_storage->getSetting('allowed_values');
     $lost_keys = array_keys(array_diff_key($prior_allowed_values,$allowed_values));
     if (_options_values_in_use($field_storage->getTargetEntityTypeId(), $field_storage->getName(), $lost_keys)) {
-      throw new \Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field_storage->getName())));
+      throw new \Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException(new \Drupal\Component\Render\FormattableMarkup('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field_storage->getName())));
     }
   }
 }
diff --git a/core/modules/field/field.purge.inc b/core/modules/field/field.purge.inc
index bd9203c..193e945 100644
--- a/core/modules/field/field.purge.inc
+++ b/core/modules/field/field.purge.inc
@@ -5,6 +5,7 @@
  * Provides support for field data purge after mass deletion.
  */
 
+use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Field\FieldException;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\field\FieldStorageConfigInterface;
@@ -161,7 +162,7 @@ function field_purge_field(FieldConfigInterface $field) {
 function field_purge_field_storage(FieldStorageConfigInterface $field_storage) {
   $fields = entity_load_multiple_by_properties('field_config', array('field_storage_uuid' => $field_storage->uuid(), 'include_deleted' => TRUE));
   if (count($fields) > 0) {
-    throw new FieldException(t('Attempt to purge a field storage @field_name that still has fields.', array('@field_name' => $field_storage->getName())));
+    throw new FieldException(new FormattableMarkup('Attempt to purge a field storage @field_name that still has fields.', array('@field_name' => $field_storage->getName())));
   }
 
   $state = \Drupal::state();
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index a54fc0a..05c72fc 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -1058,7 +1058,7 @@ function node_query_node_access_alter(AlterableInterface $query) {
     }
     // Bail out if the base table is missing.
     if (!$base_table) {
-      throw new Exception(t('Query tagged for node access but there is no node table, specify the base_table using meta data.'));
+      throw new Exception('Query tagged for node access but there is no node table, specify the base_table using meta data.');
     }
   }
 
diff --git a/core/modules/options/options.module b/core/modules/options/options.module
index 5d3d671..8bae412 100644
--- a/core/modules/options/options.module
+++ b/core/modules/options/options.module
@@ -5,6 +5,7 @@
  * Defines selection, check box and radio button widgets for text and numeric fields.
  */
 
+use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Entity\FieldableEntityInterface;
 use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
@@ -112,7 +113,7 @@ function options_field_storage_config_update_forbid(FieldStorageConfigInterface
     $prior_allowed_values = $prior_field_storage->getSetting('allowed_values');
     $lost_keys = array_keys(array_diff_key($prior_allowed_values, $allowed_values));
     if (_options_values_in_use($field_storage->getTargetEntityTypeId(), $field_storage->getName(), $lost_keys)) {
-      throw new FieldStorageDefinitionUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field_storage->getName())));
+      throw new FieldStorageDefinitionUpdateForbiddenException(new FormattableMarkup('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field_storage->getName())));
     }
   }
 }
diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module
index 33a3e92..825deb7 100644
--- a/core/modules/rdf/rdf.module
+++ b/core/modules/rdf/rdf.module
@@ -5,6 +5,7 @@
  * Enables semantically enriched output for Drupal sites in the form of RDFa.
  */
 
+use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Routing\RouteMatchInterface;
 use Drupal\Core\Template\Attribute;
 
@@ -114,7 +115,7 @@ function rdf_get_namespaces() {
     $function = $module . '_rdf_namespaces';
     foreach($function() as $prefix => $namespace) {
       if (array_key_exists($prefix, $namespaces) && $namespace !== $namespaces[$prefix]) {
-        throw new Exception(t('Tried to map @prefix to @namespace, but @prefix is already mapped to @orig_namespace.', array('@prefix' => $prefix, '@namespace' => $namespace, '@orig_namespace' => $namespaces[$prefix])));
+        throw new Exception(new FormattableMarkup('Tried to map @prefix to @namespace, but @prefix is already mapped to @orig_namespace.', array('@prefix' => $prefix, '@namespace' => $namespace, '@orig_namespace' => $namespaces[$prefix])));
       }
       else {
         $namespaces[$prefix] = $namespace;
diff --git a/core/modules/system/tests/modules/common_test/common_test.module b/core/modules/system/tests/modules/common_test/common_test.module
index a6f72a7..2415fac 100644
--- a/core/modules/system/tests/modules/common_test/common_test.module
+++ b/core/modules/system/tests/modules/common_test/common_test.module
@@ -213,7 +213,7 @@ function common_test_library_info_alter(&$libraries, $module) {
  *
  */
 function common_test_cron() {
-  throw new Exception(t('Uncaught exception'));
+  throw new Exception('Uncaught exception');
 }
 
 /**
diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc
index f9c7c5f..7bff525 100644
--- a/core/modules/update/update.manager.inc
+++ b/core/modules/update/update.manager.inc
@@ -36,6 +36,7 @@
  * root.
  */
 
+use Drupal\Component\Render\FormattableMarkup;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 
 /**
@@ -150,7 +151,7 @@ function _update_manager_check_backends(&$form, $operation) {
 function update_manager_archive_extract($file, $directory) {
   $archiver = archiver_get_archiver($file);
   if (!$archiver) {
-    throw new Exception(t('Cannot extract %file, not a valid archive.', array ('%file' => $file)));
+    throw new Exception(new FormattableMarkup('Cannot extract %file, not a valid archive.', array ('%file' => $file)));
   }
 
   // Remove the directory if it exists, otherwise it might contain a mixture of
-- 
2.1.4

