From: Brion Vibber Date: Tue, 25 Mar 2008 23:08:19 +0000 (+0000) Subject: * Don't die when single-element arrays are passed to SQL query constructors X-Git-Tag: 1.31.0-rc.0~48805 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=899f6440167d57f36fcafd6394a41fe67655e1e0;p=lhc%2Fweb%2Fwiklou.git * Don't die when single-element arrays are passed to SQL query constructors 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. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fbf36c002e..5418651ac4 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/Database.php b/includes/Database.php index e9db0a38d2..e2f15b2d02 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -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).") ";