From 1faeb677ebcad9c2ef05a8c31e920ecd4627f604 Mon Sep 17 00:00:00 2001
From: drewish <drewish@34869.no-reply.drupal.org>
Date: Sat, 21 Apr 2012 12:59:05 -0700
Subject: [PATCH 1/2] [#966210] DB Case Sensitivity: system_update_7061()
 fails on inserting files with same name but different
 case

---
 modules/simpletest/tests/file.test |   13 +++++++++++++
 modules/system/system.install      |    2 ++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test
index 4c56bfc..3df31ba 100644
--- a/modules/simpletest/tests/file.test
+++ b/modules/simpletest/tests/file.test
@@ -2026,6 +2026,19 @@ class FileSaveTest extends FileHookTestCase {
     $loaded_file = db_query('SELECT * FROM {file_managed} f WHERE f.fid = :fid', array(':fid' => $saved_file->fid))->fetch(PDO::FETCH_OBJ);
     $this->assertNotNull($loaded_file, t("Record still exists in the database."), 'File');
     $this->assertEqual($loaded_file->status, $saved_file->status, t("Status was saved correctly."));
+
+    // Try to insert a second file with the same name apart from case insensitivity
+    // to ensure the 'uri' index allows for filenames with different cases.
+    $file = (object) array(
+      'uid' => 1,
+      'filename' => 'DRUPLICON.txt',
+      'uri' => 'public://DRUPLICON.txt',
+      'filemime' => 'text/plain',
+      'timestamp' => 1,
+      'status' => FILE_STATUS_PERMANENT,
+    );
+    file_put_contents($file->uri, 'hello world');
+    file_save($file);
   }
 }
 
diff --git a/modules/system/system.install b/modules/system/system.install
index 0b4e1fa..6481c55 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -810,6 +810,7 @@ function system_schema() {
         'length' => 255,
         'not null' => TRUE,
         'default' => '',
+        'binary' => TRUE,
       ),
       'uri' => array(
         'description' => 'The URI to access the file (either local or remote).',
@@ -817,6 +818,7 @@ function system_schema() {
         'length' => 255,
         'not null' => TRUE,
         'default' => '',
+        'binary' => TRUE,
       ),
       'filemime' => array(
         'description' => "The file's MIME type.",
-- 
1.7.5.4


From c51167c80898b1554962210bbd4c77b2c8b79fc8 Mon Sep 17 00:00:00 2001
From: Neil Drumm <drumm@delocalizedham.com>
Date: Sun, 22 Apr 2012 10:40:03 -0700
Subject: [PATCH 2/2] [#966210] Also add binary to system_update_7061() and
 another update to ensure it happens on
 previously-upgraded sites.

---
 modules/system/system.install |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/modules/system/system.install b/modules/system/system.install
index 6481c55..e6fdcf8 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -2175,6 +2175,7 @@ function system_update_7034() {
         'length' => 255,
         'not null' => TRUE,
         'default' => '',
+        'binary' => TRUE,
       ),
       'uri' => array(
         'description' => 'URI of file.',
@@ -2182,6 +2183,7 @@ function system_update_7034() {
         'length' => 255,
         'not null' => TRUE,
         'default' => '',
+        'binary' => TRUE,
       ),
       'filemime' => array(
         'description' => "The file's MIME type.",
@@ -2991,6 +2993,29 @@ function system_update_7072() {
  */
 
 /**
+ * Add binary to {file_managed}, in case system_update_7034() was run without
+ * it.
+ */
+function system_update_7073() {
+  db_change_field('file_managed', 'filename', array(
+    'description' => 'Name of the file with no path components. This may differ from the basename of the URI if the file is renamed to avoid overwriting an existing file.',
+    'type' => 'varchar',
+    'length' => 255,
+    'not null' => TRUE,
+    'default' => '',
+    'binary' => TRUE,
+  ));
+  db_change_field('file_managed', 'uri', array(
+    'description' => 'The URI to access the file (either local or remote).',
+    'type' => 'varchar',
+    'length' => 255,
+    'not null' => TRUE,
+    'default' => '',
+    'binary' => TRUE,
+  ));
+}
+
+/**
  * @} End of "defgroup updates-7.x-extra"
  * The next series of updates should start at 8000.
  */
-- 
1.7.5.4

