From 2436298a173a7df668db5a9b2493722f9d988c38 Mon Sep 17 00:00:00 2001 From: xjm Date: Mon, 18 May 2020 19:21:21 -0500 Subject: [PATCH] =?UTF-8?q?Issue=20#2055851=20by=20andypost,=20jungle,=20d?= =?UTF-8?q?awehner,=20Mac=5FWeber,=20sja112,=20borisson=5F,=20fietserwin,?= =?UTF-8?q?=20init90,=20G=C3=A1bor=20Hojtsy,=20xjm,=20effulgentsia,=20tim.?= =?UTF-8?q?plunkett:=20Remove=20translation=20of=20exception=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/includes/install.core.inc | 4 ++-- core/includes/install.inc | 4 ++-- core/includes/update.inc | 2 +- core/lib/Drupal/Core/Archiver/Zip.php | 2 +- .../Core/Database/Driver/mysql/Schema.php | 24 +++++++++---------- .../Core/Database/Driver/pgsql/Schema.php | 24 +++++++++---------- .../Core/Database/Driver/sqlite/Schema.php | 24 +++++++++---------- core/lib/Drupal/Core/Database/Query/Merge.php | 2 +- core/lib/Drupal/Core/Database/Schema.php | 2 +- .../Form/FileTransferAuthorizeForm.php | 2 +- core/lib/Drupal/Core/Updater/Updater.php | 14 +++++------ .../contextual/src/ContextualController.php | 4 ++-- .../Plugin/rest/resource/DBLogResource.php | 4 ++-- .../src/Functional/DbLogResourceTest.php | 2 +- core/modules/field/field.api.php | 2 +- core/modules/field/field.purge.inc | 2 +- .../ImageStyleDownloadController.php | 2 +- core/modules/node/node.module | 2 +- core/modules/options/options.module | 2 +- core/modules/rdf/rdf.module | 2 +- core/modules/system/system.install | 2 +- .../modules/common_test/common_test.module | 2 +- core/modules/update/update.manager.inc | 2 +- core/phpcs.xml.dist | 1 + 24 files changed, 67 insertions(+), 66 deletions(-) diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index c8103369b6..45d520d39a 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1240,7 +1240,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); @@ -1385,7 +1385,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 e806a09a41..95897c38b1 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -375,7 +375,7 @@ function drupal_rewrite_settings($settings = [], $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.', ['%settings' => $settings_file])); + throw new Exception("Failed to modify '$settings_file'. Verify the file permissions."); } else { // In case any $settings variables were written, import them into the @@ -392,7 +392,7 @@ function drupal_rewrite_settings($settings = [], $settings_file = NULL) { } } else { - throw new Exception(t('Failed to open %settings. Verify the file permissions.', ['%settings' => $settings_file])); + throw new Exception("Failed to open '$settings_file'. Verify the file permissions."); } } diff --git a/core/includes/update.inc b/core/includes/update.inc index 123ad46830..6f9b336a04 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -174,7 +174,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 fd769c13cf..74f6105929 100644 --- a/core/lib/Drupal/Core/Archiver/Zip.php +++ b/core/lib/Drupal/Core/Archiver/Zip.php @@ -29,7 +29,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', ['%file_path' => $file_path])); + throw new ArchiverException("Cannot open '$file_path'"); } } diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php index d909f7c50b..794ef02df1 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php @@ -377,10 +377,10 @@ protected function createKeySql($fields) { */ public function renameTable($table, $new_name) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", ['@table' => $table, '@table_new' => $new_name])); + throw new SchemaObjectDoesNotExistException("Cannot rename '$table' to '$new_name': table '$table' doesn't exist."); } if ($this->tableExists($new_name)) { - throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", ['@table' => $table, '@table_new' => $new_name])); + throw new SchemaObjectExistsException("Cannot rename '$table' to '$new_name': table '$new_name' already exists."); } $info = $this->getPrefixInfo($new_name); @@ -404,10 +404,10 @@ public function dropTable($table) { */ public function addField($table, $field, $spec, $keys_new = []) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table])); + throw new SchemaObjectDoesNotExistException("Cannot add field '$table.$field': table doesn't exist."); } if ($this->fieldExists($table, $field)) { - throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", ['@field' => $field, '@table' => $table])); + throw new SchemaObjectExistsException("Cannot add field '$table.$field': field already exists."); } // Fields that are part of a PRIMARY KEY must be added as NOT NULL. @@ -497,10 +497,10 @@ public function indexExists($table, $name) { */ public function addPrimaryKey($table, $fields) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", ['@table' => $table])); + throw new SchemaObjectDoesNotExistException("Cannot add primary key to table '$table': table doesn't exist."); } if ($this->indexExists($table, 'PRIMARY')) { - throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", ['@table' => $table])); + throw new SchemaObjectExistsException("Cannot add primary key to table '$table': primary key already exists."); } $this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')'); @@ -534,10 +534,10 @@ protected function findPrimaryKeyColumns($table) { */ public function addUniqueKey($table, $name, $fields) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name])); + throw new SchemaObjectDoesNotExistException("Cannot add unique key '$name' to table '$table': table doesn't exist."); } if ($this->indexExists($table, $name)) { - throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", ['@table' => $table, '@name' => $name])); + throw new SchemaObjectExistsException("Cannot add unique key '$name' to table '$table': unique key already exists."); } $this->connection->query('ALTER TABLE {' . $table . '} ADD UNIQUE KEY `' . $name . '` (' . $this->createKeySql($fields) . ')'); @@ -560,10 +560,10 @@ public function dropUniqueKey($table, $name) { */ public function addIndex($table, $name, $fields, array $spec) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name])); + throw new SchemaObjectDoesNotExistException("Cannot add index '$name' to table '$table': table doesn't exist."); } if ($this->indexExists($table, $name)) { - throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", ['@table' => $table, '@name' => $name])); + throw new SchemaObjectExistsException("Cannot add index '$name' to table '$table': index already exists."); } $spec['indexes'][$name] = $fields; @@ -619,10 +619,10 @@ protected function introspectIndexSchema($table) { */ public function changeField($table, $field, $field_new, $spec, $keys_new = []) { if (!$this->fieldExists($table, $field)) { - throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", ['@table' => $table, '@name' => $field])); + throw new SchemaObjectDoesNotExistException("Cannot change the definition of field '$table.$field': field doesn't exist."); } if (($field != $field_new) && $this->fieldExists($table, $field_new)) { - throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", ['@table' => $table, '@name' => $field, '@name_new' => $field_new])); + throw new SchemaObjectExistsException("Cannot rename field '$table.$field' to '$field_new': target field already exists."); } if (isset($keys_new['primary key']) && in_array($field_new, $keys_new['primary key'], TRUE)) { $this->ensureNotNullPrimaryKey($keys_new['primary key'], [$field_new => $spec]); diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php index cb4ac71626..4bddd1d66f 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php @@ -543,10 +543,10 @@ public function findTables($table_expression) { */ public function renameTable($table, $new_name) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", ['@table' => $table, '@table_new' => $new_name])); + throw new SchemaObjectDoesNotExistException("Cannot rename '$table' to '$new_name': table '$table' doesn't exist."); } if ($this->tableExists($new_name)) { - throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", ['@table' => $table, '@table_new' => $new_name])); + throw new SchemaObjectExistsException("Cannot rename '$table' to '$new_name': table '$new_name' already exists."); } // Get the schema and tablename for the old table. @@ -623,10 +623,10 @@ public function dropTable($table) { */ public function addField($table, $field, $spec, $new_keys = []) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table])); + throw new SchemaObjectDoesNotExistException("Cannot add field '$table.$field': table doesn't exist."); } if ($this->fieldExists($table, $field)) { - throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", ['@field' => $field, '@table' => $table])); + throw new SchemaObjectExistsException("Cannot add field '$table.$field': field already exists."); } // Fields that are part of a PRIMARY KEY must be added as NOT NULL. @@ -750,10 +750,10 @@ public function constraintExists($table, $name) { */ public function addPrimaryKey($table, $fields) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", ['@table' => $table])); + throw new SchemaObjectDoesNotExistException("Cannot add primary key to table '$table': table doesn't exist."); } if ($this->constraintExists($table, 'pkey')) { - throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", ['@table' => $table])); + throw new SchemaObjectExistsException("Cannot add primary key to table '$table': primary key already exists."); } $this->connection->query('ALTER TABLE {' . $table . '} ADD CONSTRAINT ' . $this->ensureIdentifiersLength($table, '', 'pkey') . ' PRIMARY KEY (' . $this->createPrimaryKeySql($fields) . ')'); @@ -788,10 +788,10 @@ protected function findPrimaryKeyColumns($table) { */ public function addUniqueKey($table, $name, $fields) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name])); + throw new SchemaObjectDoesNotExistException("Cannot add unique key '$name' to table '$table': table doesn't exist."); } if ($this->constraintExists($table, $name . '__key')) { - throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", ['@table' => $table, '@name' => $name])); + throw new SchemaObjectExistsException("Cannot add unique key '$name' to table '$table': unique key already exists."); } $this->connection->query('ALTER TABLE {' . $table . '} ADD CONSTRAINT ' . $this->ensureIdentifiersLength($table, $name, 'key') . ' UNIQUE (' . implode(',', $fields) . ')'); @@ -816,10 +816,10 @@ public function dropUniqueKey($table, $name) { */ public function addIndex($table, $name, $fields, array $spec) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name])); + throw new SchemaObjectDoesNotExistException("Cannot add index '$name' to table '$table': table doesn't exist."); } if ($this->indexExists($table, $name)) { - throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", ['@table' => $table, '@name' => $name])); + throw new SchemaObjectExistsException("Cannot add index '$name' to table '$table': index already exists."); } $this->connection->query($this->_createIndexSql($table, $name, $fields)); @@ -878,10 +878,10 @@ protected function introspectIndexSchema($table) { */ public function changeField($table, $field, $field_new, $spec, $new_keys = []) { if (!$this->fieldExists($table, $field)) { - throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", ['@table' => $table, '@name' => $field])); + throw new SchemaObjectDoesNotExistException("Cannot change the definition of field '$table.$field': field doesn't exist."); } if (($field != $field_new) && $this->fieldExists($table, $field_new)) { - throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", ['@table' => $table, '@name' => $field, '@name_new' => $field_new])); + throw new SchemaObjectExistsException("Cannot rename field '$table.$field' to '$field_new': target field already exists."); } if (isset($new_keys['primary key']) && in_array($field_new, $new_keys['primary key'], TRUE)) { $this->ensureNotNullPrimaryKey($new_keys['primary key'], [$field_new => $spec]); diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php index 2286aedbba..fcfeb78c60 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php @@ -263,10 +263,10 @@ public function getFieldTypeMap() { */ public function renameTable($table, $new_name) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", ['@table' => $table, '@table_new' => $new_name])); + throw new SchemaObjectDoesNotExistException("Cannot rename '$table' to '$new_name': table '$table' doesn't exist."); } if ($this->tableExists($new_name)) { - throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", ['@table' => $table, '@table_new' => $new_name])); + throw new SchemaObjectExistsException("Cannot rename '$table' to '$new_name': table '$new_name' already exists."); } $schema = $this->introspectSchema($table); @@ -315,10 +315,10 @@ public function dropTable($table) { */ public function addField($table, $field, $specification, $keys_new = []) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table])); + throw new SchemaObjectDoesNotExistException("Cannot add field '$table.$field': table doesn't exist."); } if ($this->fieldExists($table, $field)) { - throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", ['@field' => $field, '@table' => $table])); + throw new SchemaObjectExistsException("Cannot add field '$table.$field': field already exists."); } if (isset($keys_new['primary key']) && in_array($field, $keys_new['primary key'], TRUE)) { $this->ensureNotNullPrimaryKey($keys_new['primary key'], [$field => $specification]); @@ -587,10 +587,10 @@ public function dropField($table, $field) { */ public function changeField($table, $field, $field_new, $spec, $keys_new = []) { if (!$this->fieldExists($table, $field)) { - throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", ['@table' => $table, '@name' => $field])); + throw new SchemaObjectDoesNotExistException("Cannot change the definition of field '$table.$field': field doesn't exist."); } if (($field != $field_new) && $this->fieldExists($table, $field_new)) { - throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", ['@table' => $table, '@name' => $field, '@name_new' => $field_new])); + throw new SchemaObjectExistsException("Cannot rename field '$table.$field' to '$field_new': target field already exists."); } if (isset($keys_new['primary key']) && in_array($field_new, $keys_new['primary key'], TRUE)) { $this->ensureNotNullPrimaryKey($keys_new['primary key'], [$field_new => $spec]); @@ -660,10 +660,10 @@ protected function mapKeyDefinition(array $key_definition, array $mapping) { */ public function addIndex($table, $name, $fields, array $spec) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name])); + throw new SchemaObjectDoesNotExistException("Cannot add index '$name' to table '$table': table doesn't exist."); } if ($this->indexExists($table, $name)) { - throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", ['@table' => $table, '@name' => $name])); + throw new SchemaObjectExistsException("Cannot add index '$name' to table '$table': index already exists."); } $schema['indexes'][$name] = $fields; @@ -701,10 +701,10 @@ public function dropIndex($table, $name) { */ public function addUniqueKey($table, $name, $fields) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name])); + throw new SchemaObjectDoesNotExistException("Cannot add unique key '$name' to table '$table': table doesn't exist."); } if ($this->indexExists($table, $name)) { - throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", ['@table' => $table, '@name' => $name])); + throw new SchemaObjectExistsException("Cannot add unique key '$name' to table '$table': unique key already exists."); } $schema['unique keys'][$name] = $fields; @@ -733,14 +733,14 @@ public function dropUniqueKey($table, $name) { */ public function addPrimaryKey($table, $fields) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", ['@table' => $table])); + throw new SchemaObjectDoesNotExistException("Cannot add primary key to table '$table': table doesn't exist."); } $old_schema = $this->introspectSchema($table); $new_schema = $old_schema; if (!empty($new_schema['primary key'])) { - throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", ['@table' => $table])); + throw new SchemaObjectExistsException("Cannot add primary key to table '$table': primary key already exists."); } $new_schema['primary key'] = $fields; diff --git a/core/lib/Drupal/Core/Database/Query/Merge.php b/core/lib/Drupal/Core/Database/Query/Merge.php index 5a9bc3db89..92d9c572ca 100644 --- a/core/lib/Drupal/Core/Database/Query/Merge.php +++ b/core/lib/Drupal/Core/Database/Query/Merge.php @@ -359,7 +359,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 1987177a3e..a34b06e749 100644 --- a/core/lib/Drupal/Core/Database/Schema.php +++ b/core/lib/Drupal/Core/Database/Schema.php @@ -611,7 +611,7 @@ protected function introspectIndexSchema($table) { */ public function createTable($name, $table) { if ($this->tableExists($name)) { - throw new SchemaObjectExistsException(t('Table @name already exists.', ['@name' => $name])); + throw new SchemaObjectExistsException("Table '$name' already exists."); } $statements = $this->createTableSql($name, $table); foreach ($statements as $statement) { diff --git a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php index 563aff847e..499721d94a 100644 --- a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php +++ b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php @@ -168,7 +168,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $filetransfer = $this->getFiletransfer($backend, $form_connection_settings[$backend]); try { if (!$filetransfer) { - throw new \Exception($this->t('The connection protocol %backend does not exist.', ['%backend' => $backend])); + throw new \Exception("The connection protocol '$backend' does not exist."); } $filetransfer->connect(); } diff --git a/core/lib/Drupal/Core/Updater/Updater.php b/core/lib/Drupal/Core/Updater/Updater.php index 9f63291ca1..1d3fdb59a0 100644 --- a/core/lib/Drupal/Core/Updater/Updater.php +++ b/core/lib/Drupal/Core/Updater/Updater.php @@ -64,7 +64,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); } @@ -89,7 +89,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.'); } /** @@ -142,7 +142,7 @@ protected static function getExtensionInfo($directory) { $info_file = static::findInfoFile($directory); $info = \Drupal::service('info_parser')->parse($info_file); if (empty($info)) { - throw new UpdaterException(t('Unable to parse info file: %info_file.', ['%info_file' => $info_file])); + throw new UpdaterException("Unable to parse info file: '$info_file'."); } return $info; @@ -178,7 +178,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.', ['%info_file' => $info_file])); + throw new UpdaterException("Unable to parse info file: '$info_file'."); } return $info['name']; } @@ -228,7 +228,7 @@ public function update(&$filetransfer, $overrides = []) { 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. @@ -253,7 +253,7 @@ public function update(&$filetransfer, $overrides = []) { return $this->postUpdateTasks(); } catch (FileTransferException $e) { - throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', ['@reason' => strtr($e->getMessage(), $e->arguments)])); + throw new UpdaterFileTransferException("File Transfer failed, reason: '" . strtr($e->getMessage(), $e->arguments) . "'"); } } @@ -291,7 +291,7 @@ public function install(&$filetransfer, $overrides = []) { return $this->postInstallTasks(); } catch (FileTransferException $e) { - throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', ['@reason' => strtr($e->getMessage(), $e->arguments)])); + throw new UpdaterFileTransferException("File Transfer failed, reason: '" . strtr($e->getMessage(), $e->arguments)) . "'"; } } diff --git a/core/modules/contextual/src/ContextualController.php b/core/modules/contextual/src/ContextualController.php index 7189b0c2a1..cd6ddb40a8 100644 --- a/core/modules/contextual/src/ContextualController.php +++ b/core/modules/contextual/src/ContextualController.php @@ -62,12 +62,12 @@ public static function create(ContainerInterface $container) { 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.'); } $tokens = $request->request->get('tokens'); if (!isset($tokens)) { - throw new BadRequestHttpException(t('No contextual ID tokens specified.')); + throw new BadRequestHttpException('No contextual ID tokens specified.'); } $rendered = []; diff --git a/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php b/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php index e373c01f3d..706e248b12 100644 --- a/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php +++ b/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php @@ -45,10 +45,10 @@ public function get($id = NULL) { return new ResourceResponse($record); } - throw new NotFoundHttpException(t('Log entry with ID @id was not found', ['@id' => $id])); + throw new NotFoundHttpException("Log entry with ID '$id' was not found"); } - throw new BadRequestHttpException(t('No log entry ID was provided')); + throw new BadRequestHttpException('No log entry ID was provided'); } } diff --git a/core/modules/dblog/tests/src/Functional/DbLogResourceTest.php b/core/modules/dblog/tests/src/Functional/DbLogResourceTest.php index 5f82037500..5b64b3a718 100644 --- a/core/modules/dblog/tests/src/Functional/DbLogResourceTest.php +++ b/core/modules/dblog/tests/src/Functional/DbLogResourceTest.php @@ -88,7 +88,7 @@ public function testWatchdog() { // Request an unknown log entry. $url->setRouteParameter('id', 9999); $response = $this->request('GET', $url, $request_options); - $this->assertResourceErrorResponse(404, 'Log entry with ID 9999 was not found', $response); + $this->assertResourceErrorResponse(404, "Log entry with ID '9999' was not found", $response); // Make a bad request (a true malformed request would never be a route match). $url->setRouteParameter('id', 0); diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index 2b132a3244..36e5fcefe9 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -111,7 +111,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.', ['@field_name' => $field_storage->getName()])); + throw new \Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException("A list field '{$field_storage->getName()}' with existing data cannot have its keys changed."); } } } diff --git a/core/modules/field/field.purge.inc b/core/modules/field/field.purge.inc index 11b2ac11a6..ee49fc245b 100644 --- a/core/modules/field/field.purge.inc +++ b/core/modules/field/field.purge.inc @@ -157,7 +157,7 @@ function field_purge_field_storage(FieldStorageDefinitionInterface $field_storag $fields = $deleted_fields_repository->getFieldDefinitions($field_storage->getUniqueStorageIdentifier()); if (count($fields) > 0) { - throw new FieldException(t('Attempt to purge a field storage @field_name that still has fields.', ['@field_name' => $field_storage->getName()])); + throw new FieldException("Attempt to purge a field storage '{$field_storage->getName()}' that still has fields."); } $deleted_fields_repository->removeFieldStorageDefinition($field_storage); diff --git a/core/modules/image/src/Controller/ImageStyleDownloadController.php b/core/modules/image/src/Controller/ImageStyleDownloadController.php index 2913b9fe51..c7cf65cdf4 100644 --- a/core/modules/image/src/Controller/ImageStyleDownloadController.php +++ b/core/modules/image/src/Controller/ImageStyleDownloadController.php @@ -157,7 +157,7 @@ public function deliver(Request $request, $scheme, ImageStyleInterface $image_st if (!$lock_acquired) { // Tell client to retry again in 3 seconds. Currently no browsers are // known to support Retry-After. - throw new ServiceUnavailableHttpException(3, $this->t('Image generation in progress. Try again shortly.')); + throw new ServiceUnavailableHttpException(3, 'Image generation in progress. Try again shortly.'); } } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 5fab59822c..eae4365c79 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -959,7 +959,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 a0f586fa4d..30aefdd33c 100644 --- a/core/modules/options/options.module +++ b/core/modules/options/options.module @@ -113,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.', ['@field_name' => $field_storage->getName()])); + throw new FieldStorageDefinitionUpdateForbiddenException("A list field '{$field_storage->getName()}' with existing data cannot have its keys changed."); } } } diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 56204e1dd6..92cc337fc1 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -117,7 +117,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.', ['@prefix' => $prefix, '@namespace' => $namespace, '@orig_namespace' => $namespaces[$prefix]])); + throw new Exception("Tried to map '$prefix' to '$namespace', but '$prefix' is already mapped to '{$namespaces[$prefix]}'."); } else { $namespaces[$prefix] = $namespace; diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 5efa64c4ad..dc39b9a88c 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -356,7 +356,7 @@ function system_requirements($phase) { try { $bytes = random_bytes(10); if (strlen($bytes) != 10) { - throw new \Exception(t('Tried to generate 10 random bytes, generated @count', ['@count' => strlen($bytes)])); + throw new \Exception("Tried to generate 10 random bytes, generated '" . strlen($bytes) . "'"); } $requirements['php_random_bytes']['value'] = t('Successful'); } 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 45e59530b9..8abc74d7d8 100644 --- a/core/modules/system/tests/modules/common_test/common_test.module +++ b/core/modules/system/tests/modules/common_test/common_test.module @@ -194,7 +194,7 @@ function common_test_library_info_alter(&$libraries, $module) { * @see common_test_cron_helper() */ 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 902ff8429a..50272e19e3 100644 --- a/core/modules/update/update.manager.inc +++ b/core/modules/update/update.manager.inc @@ -156,7 +156,7 @@ function update_manager_archive_extract($file, $directory) { 'filepath' => $file, ]); if (!$archiver) { - throw new Exception(t('Cannot extract %file, not a valid archive.', ['%file' => $file])); + throw new Exception("Cannot extract '$file', not a valid archive"); } // Remove the directory if it exists, otherwise it might contain a mixture of diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index 85d5c81029..387fdf0a80 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -148,6 +148,7 @@ + -- GitLab