summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2015-06-14 20:25:26 (GMT)
committerxjm2015-06-14 20:25:26 (GMT)
commit0f88b173b4b7dd2ba808606d4f312c4c386de028 (patch)
tree6b8d57796c8d0a7e390b1b71ced5e4d1d578f317
parentc6cc4fa122dc4d9e8c0ff0143c179ff6af7a9c83 (diff)
Issue #2501827 by cwells, kgoel, jcloys, YesCT, crowdcg, Bojhan: Remove SafeMarkup::set() in file_save_upload() and allow render/template code to control a single-item list
-rw-r--r--core/modules/file/file.module20
-rw-r--r--core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php3
-rw-r--r--core/modules/image/src/Tests/ImageFieldValidateTest.php5
3 files changed, 15 insertions, 13 deletions
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 9d1592d..9f0074f 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -850,18 +850,18 @@ function file_save_upload($form_field_name, $validators = array(), $destination
// Check for errors.
if (!empty($errors)) {
- $message = t('The specified file %name could not be uploaded.', array('%name' => $file->getFilename()));
- if (count($errors) > 1) {
- $item_list = array(
+ $message = array(
+ 'error' => array(
+ '#markup' => t('The specified file %name could not be uploaded.', array('%name' => $file->getFilename())),
+ ),
+ 'item_list' => array(
'#theme' => 'item_list',
'#items' => $errors,
- );
- $message = SafeMarkup::set($message . drupal_render($item_list));
- }
- else {
- $message = SafeMarkup::set($message . ' ' . SafeMarkup::escape(array_pop($errors)));
- }
- drupal_set_message($message, 'error');
+ ),
+ );
+ // @todo Add support for render arrays in drupal_set_message()? See
+ // https://www.drupal.org/node/2505497.
+ drupal_set_message(\Drupal::service('renderer')->render($message), 'error');
$files[$i] = FALSE;
continue;
}
diff --git a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
index 39e0d50..9dea3f5 100644
--- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
@@ -298,7 +298,8 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$non_image = $this->drupalGetTestFiles('text');
$this->drupalPostForm(NULL, array('files[settings_default_image_uuid]' => drupal_realpath($non_image[0]->uri)), t("Upload"));
- $this->assertText(t('The specified file text-0.txt could not be uploaded. Only files with the following extensions are allowed: png gif jpg jpeg.'), 'Non-image file cannot be used as default image.');
+ $this->assertText('The specified file text-0.txt could not be uploaded.');
+ $this->assertText('Only files with the following extensions are allowed: png gif jpg jpeg.');
// Confirm the default image is shown on the node form.
$file = File::load($default_images['field_new']->id());
diff --git a/core/modules/image/src/Tests/ImageFieldValidateTest.php b/core/modules/image/src/Tests/ImageFieldValidateTest.php
index 938176a..3822df6 100644
--- a/core/modules/image/src/Tests/ImageFieldValidateTest.php
+++ b/core/modules/image/src/Tests/ImageFieldValidateTest.php
@@ -45,9 +45,10 @@ class ImageFieldValidateTest extends ImageFieldTestBase {
}
}
$this->uploadNodeImage($image_that_is_too_small, $field_name, 'article');
- $this->assertRaw(t('The specified file %name could not be uploaded.', array('%name' => $image_that_is_too_small->filename)) . ' ' . t('The image is too small; the minimum dimensions are %dimensions pixels.', array('%dimensions' => '50x50')), 'Node save failed when minimum image resolution was not met.');
+ $this->assertRaw(t('The specified file %name could not be uploaded.', array('%name' => $image_that_is_too_small->filename)));
+ $this->assertRaw(t('The image is too small; the minimum dimensions are %dimensions pixels.', array('%dimensions' => '50x50')));
$this->uploadNodeImage($image_that_is_too_big, $field_name, 'article');
- $this->assertText(t('The image was resized to fit within the maximum allowed dimensions of 100x100 pixels.'), 'Image exceeding max resolution was properly resized.');
+ $this->assertText(t('The image was resized to fit within the maximum allowed dimensions of 100x100 pixels.'));
}
/**