Make WordPress Core

Ticket #10404: 10404.patch_case_insensitive_key_matching

File 10404.patch_case_insensitive_key_matching, 2.1 KB (added by charlestonsw, 12 years ago)

Update case insensitive compare on dbDelta plus minor phpDoc updates.

Line 
1Index: upgrade.php
2===================================================================
3--- upgrade.php (revision 26270)
4+++ upgrade.php (working copy)
5@@ -1501,15 +1501,15 @@
6 }
7 
8 /**
9- * {@internal Missing Short Description}}
10+ * Create or update database tables based on analyis of SQL queries provided.
11  *
12  * {@internal Missing Long Description}}
13  *
14  * @since 1.5.0
15  *
16- * @param unknown_type $queries
17- * @param unknown_type $execute
18- * @return unknown
19+ * @param string[] $queries single string or array of strings representing SQL queries
20+ * @param boolean $execute
21+ * @return string[]
22  */
23 function dbDelta( $queries = '', $execute = true ) {
24        global $wpdb;
25@@ -1577,7 +1577,11 @@
26                        preg_match("|^([^ ]*)|", trim($fld), $fvals);
27                        $fieldname = trim( $fvals[1], '`' );
28 
29-                       // Verify the found field name
30+                       // Verify the found field name,
31+            //
32+            // Field names do NOT have index commands on the query line.
33+            // Put those lines into the indices array for later inspection.
34+            //
35                        $validfield = true;
36                        switch (strtolower($fieldname)) {
37                        case '':
38@@ -1587,7 +1591,7 @@
39                        case 'unique':
40                        case 'key':
41                                $validfield = false;
42-                               $indices[] = trim(trim($fld), ", \n");
43+                               $indices[] = strtoupper(trim(trim($fld), ", \n"));
44                                break;
45                        }
46                        $fld = trim($fld);
47@@ -1679,11 +1683,11 @@
48                                }
49                                // Add the column list to the index create string
50                                $index_string .= ' ('.$index_columns.')';
51-                               if (!(($aindex = array_search($index_string, $indices)) === false)) {
52+                               if (!(($aindex = array_search(strtoupper($index_string), $indices)) === false)) {
53                                        unset($indices[$aindex]);
54                                        //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
55                                }
56-                               //else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br /><b>Did not find index:</b>".$index_string."<br />".print_r($indices, true)."</pre>\n";
57+                               //else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br /><b>Did not find index:</b>".strtoupper($index_string)."<br />".print_r($indices, true)."</pre>\n";
58                        }
59                }
60