Skip to content

Commit

Permalink
Issue #2055851 by andypost, sja112, jungle, dawehner, Mac_Weber, bori…
Browse files Browse the repository at this point in the history
…sson_, fietserwin, xjm, init90, Gábor Hojtsy, effulgentsia, tim.plunkett: [backport] Remove translation of exception messages
  • Loading branch information
xjm committed May 19, 2020
1 parent 155918c commit 51e186a
Show file tree
Hide file tree
Showing 25 changed files with 75 additions and 77 deletions.
2 changes: 1 addition & 1 deletion includes/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ function archiver_get_archiver($file) {
// Archivers can only work on local paths
$filepath = \Drupal::service('file_system')->realpath($file);
if (!is_file($filepath)) {
throw new Exception(t('Archivers can only operate on local files: %file not supported', ['%file' => $file]));
throw new Exception("Archivers can only operate on local files: '$file' not supported");
}
return \Drupal::service('plugin.manager.archiver')->getInstance(['filepath' => $filepath]);
}
Expand Down
4 changes: 2 additions & 2 deletions includes/install.core.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,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);
Expand Down Expand Up @@ -1397,7 +1397,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.');
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions includes/install.inc
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,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
Expand All @@ -394,7 +394,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.");
}
}

Expand Down Expand Up @@ -555,10 +555,7 @@ function drupal_install_config_directories() {
// Bail out using a similar error message as in system_requirements().
if (!\Drupal::service('file_system')->prepareDirectory($config_directories[CONFIG_SYNC_DIRECTORY], FileSystemInterface::CREATE_DIRECTORY)
&& !file_exists($config_directories[CONFIG_SYNC_DIRECTORY])) {
throw new Exception(t('The directory %directory could not be created. To proceed with the installation, either create the directory or ensure that the installer has the permissions to create it automatically. For more information, see the <a href=":handbook_url">online handbook</a>.', [
'%directory' => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
':handbook_url' => 'https://www.drupal.org/server-permissions',
]));
throw new Exception("The directory '" . config_get_config_directory(CONFIG_SYNC_DIRECTORY) . "' could not be created. To proceed with the installation, either create the directory or ensure that the installer has the permissions to create it automatically. For more information, see the <a href='https://www.drupal.org/server-permissions'>online handbook</a>.");
}
elseif (is_writable($config_directories[CONFIG_SYNC_DIRECTORY])) {
// Put a README.txt into the sync config directory. This is required so that
Expand Down
2 changes: 1 addition & 1 deletion includes/update.inc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,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
Expand Down
2 changes: 1 addition & 1 deletion lib/Drupal/Core/Archiver/Zip.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'");
}
}

Expand Down
28 changes: 14 additions & 14 deletions lib/Drupal/Core/Database/Driver/mysql/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,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);
Expand All @@ -407,10 +407,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.
Expand Down Expand Up @@ -491,7 +491,7 @@ public function dropField($table, $field) {
public function fieldSetDefault($table, $field, $default) {
@trigger_error('fieldSetDefault() is deprecated in drupal:8.7.0 and will be removed before drupal:9.0.0. Instead, call ::changeField() passing a full field specification. See https://www.drupal.org/node/2999035', E_USER_DEPRECATED);
if (!$this->fieldExists($table, $field)) {
throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field]));
throw new SchemaObjectDoesNotExistException("Cannot set default value of field '$table.$field': field doesn't exist.");
}

$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` SET DEFAULT ' . $this->escapeDefaultValue($default));
Expand All @@ -503,7 +503,7 @@ public function fieldSetDefault($table, $field, $default) {
public function fieldSetNoDefault($table, $field) {
@trigger_error('fieldSetNoDefault() is deprecated in drupal:8.7.0 and will be removed before drupal:9.0.0. Instead, call ::changeField() passing a full field specification. See https://www.drupal.org/node/2999035', E_USER_DEPRECATED);
if (!$this->fieldExists($table, $field)) {
throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field]));
throw new SchemaObjectDoesNotExistException("Cannot remove default value of field '$table.$field': field doesn't exist.");
}

$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` DROP DEFAULT');
Expand All @@ -524,10 +524,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) . ')');
Expand Down Expand Up @@ -561,10 +561,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) . ')');
Expand All @@ -587,10 +587,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;
Expand Down Expand Up @@ -646,10 +646,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]);
Expand Down
28 changes: 14 additions & 14 deletions lib/Drupal/Core/Database/Driver/pgsql/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,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.
Expand Down Expand Up @@ -626,10 +626,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.
Expand Down Expand Up @@ -702,7 +702,7 @@ public function dropField($table, $field) {
public function fieldSetDefault($table, $field, $default) {
@trigger_error('fieldSetDefault() is deprecated in drupal:8.7.0 and will be removed before drupal:9.0.0. Instead, call ::changeField() passing a full field specification. See https://www.drupal.org/node/2999035', E_USER_DEPRECATED);
if (!$this->fieldExists($table, $field)) {
throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field]));
throw new SchemaObjectDoesNotExistException("Cannot set default value of field '$table.$field': field doesn't exist.");
}

$default = $this->escapeDefaultValue($default);
Expand All @@ -716,7 +716,7 @@ public function fieldSetDefault($table, $field, $default) {
public function fieldSetNoDefault($table, $field) {
@trigger_error('fieldSetNoDefault() is deprecated in drupal:8.7.0 and will be removed before drupal:9.0.0. Instead, call ::changeField() passing a full field specification. See https://www.drupal.org/node/2999035', E_USER_DEPRECATED);
if (!$this->fieldExists($table, $field)) {
throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field]));
throw new SchemaObjectDoesNotExistException("Cannot remove default value of field '$table.$field': field doesn't exist.");
}

$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN "' . $field . '" DROP DEFAULT');
Expand Down Expand Up @@ -779,10 +779,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) . ')');
Expand Down Expand Up @@ -830,10 +830,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) . ')');
Expand All @@ -858,10 +858,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));
Expand Down Expand Up @@ -918,10 +918,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]);
Expand Down

0 comments on commit 51e186a

Please sign in to comment.