summaryrefslogtreecommitdiff
path: root/modules/image
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2012-04-30 21:53:37 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2012-04-30 21:53:37 -0700
commit6adf8ca0c26a9bc2c6cdc88be89974f7d8d096ad (patch)
treed5e27962c1fe37f53ad18b78b972a60513e8fb24 /modules/image
parentbd7712385a86bf4df9c35733c5ae2bb48277590f (diff)
downloadbrdo-6adf8ca0c26a9bc2c6cdc88be89974f7d8d096ad.tar.gz
brdo-6adf8ca0c26a9bc2c6cdc88be89974f7d8d096ad.tar.bz2
Issue #1262592 by jmarkel, pingers, marcingy: Fixed numeric names fail image creation.
Diffstat (limited to 'modules/image')
-rw-r--r--modules/image/image.module5
-rw-r--r--modules/image/image.test15
2 files changed, 19 insertions, 1 deletions
diff --git a/modules/image/image.module b/modules/image/image.module
index 3bf4b6861..dda4d9df9 100644
--- a/modules/image/image.module
+++ b/modules/image/image.module
@@ -749,7 +749,10 @@ function image_style_options($include_empty = TRUE) {
if ($include_empty && !empty($styles)) {
$options[''] = t('<none>');
}
- $options = array_merge($options, drupal_map_assoc(array_keys($styles)));
+ // Use the array concatenation operator '+' here instead of array_merge(),
+ // because the latter loses the datatype of the array keys, turning
+ // associative string keys into numeric ones without warning.
+ $options = $options + drupal_map_assoc(array_keys($styles));
if (empty($options)) {
$options[''] = t('No defined styles');
}
diff --git a/modules/image/image.test b/modules/image/image.test
index be6882764..de3c1b2e1 100644
--- a/modules/image/image.test
+++ b/modules/image/image.test
@@ -355,6 +355,21 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
}
/**
+ * Test creating an image style with a numeric name and ensuring it can be
+ * applied to an image.
+ */
+ function testNumericStyleName() {
+ $style_name = rand();
+ $edit = array(
+ 'name' => $style_name,
+ );
+ $this->drupalPost('admin/config/media/image-styles/add', $edit, t('Create new style'));
+ $this->assertRaw(t('Style %name was created.', array('%name' => $style_name)), t('Image style successfully created.'));
+ $options = image_style_options();
+ $this->assertTrue(array_key_exists($style_name, $options), t('Array key %key exists.', array('%key' => $style_name)));
+ }
+
+ /**
* General test to add a style, add/remove/edit effects to it, then delete it.
*/
function testStyle() {