* Don't die when single-element arrays are passed to SQL query constructors
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 25 Mar 2008 23:08:19 +0000 (23:08 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 25 Mar 2008 23:08:19 +0000 (23:08 +0000)
  that have an array index other than 0

Since we don't enforce linear ordering of array keys on longer arrays, we
may as well not enforce it on single-element arrays either.
The freaky little Categoryfinder class was using different keys for its
arrays, which could cause a PHP notice and silent lookup failure when
only one ID was looked up.

RELEASE-NOTES
includes/Database.php

index fbf36c0..5418651 100644 (file)
@@ -134,6 +134,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 13436) Treat image captions correctly when they include option keywords
   (like ending with "px" or starting with "upright")
 * Trackback display formatting fixed
+* Don't die when single-element arrays are passed to SQL query constructors
+  that have an array index other than 0
 
 
 === API changes in 1.13 ===
index e9db0a3..e2f15b2 100644 (file)
@@ -1572,6 +1572,9 @@ class Database {
                                        throw new MWException( __METHOD__.': empty input' );
                                } elseif( count( $value ) == 1 ) {
                                        // Special-case single values, as IN isn't terribly efficient
+                                       // Don't necessarily assume the single key is 0; we don't
+                                       // enforce linear numeric ordering on other arrays here.
+                                       $value = array_values( $value );
                                        $list .= $field." = ".$this->addQuotes( $value[0] );
                                } else {
                                        $list .= $field." IN (".$this->makeList($value).") ";