(bug 15881) API: Empty or invalid parameters cause database errors
authorRoan Kattouw <catrope@users.mediawiki.org>
Tue, 7 Oct 2008 18:23:39 +0000 (18:23 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Tue, 7 Oct 2008 18:23:39 +0000 (18:23 +0000)
RELEASE-NOTES
includes/api/ApiQueryBase.php

index 73c3c3b..11f7fe0 100644 (file)
@@ -311,6 +311,7 @@ The following extensions are migrated into MediaWiki 1.14:
 * (bug 15767) apfilterlanglinks returns duplicate results
 * (bug 15845) Added pageid/fromid parameter to action=delete/move, making
   manipulation of legacy pages with invalid titles possible
+* (bug 15881) Empty or invalid parameters cause database errors 
 
 === Languages updated in 1.14 ===
 
index 61fb365..26792a7 100644 (file)
@@ -126,13 +126,19 @@ abstract class ApiQueryBase extends ApiBase {
         * Clauses can be formatted as 'foo=bar' or array('foo' => 'bar'),
         * the latter only works if the value is a constant (i.e. not another field)
         *
+        * If $value is an empty array, this function does nothing.
+        *
         * For example, array('foo=bar', 'baz' => 3, 'bla' => 'foo') translates
         * to "foo=bar AND baz='3' AND bla='foo'"
         * @param mixed $value String or array
         */
        protected function addWhere($value) {
-               if (is_array($value))
-                       $this->where = array_merge($this->where, $value);
+               if (is_array($value)) {
+                       // Sanity check: don't insert empty arrays,
+                       // Database::makeList() chokes on them
+                       if(!empty($value))
+                               $this->where = array_merge($this->where, $value);
+               }
                else
                        $this->where[] = $value;
        }
@@ -157,7 +163,7 @@ abstract class ApiQueryBase extends ApiBase {
         * @param string $value Value; ignored if nul;
         */
        protected function addWhereFld($field, $value) {
-               if (!is_null($value))
+               if (!is_null($value) && !empty($value))
                        $this->where[$field] = $value;
        }