r41814 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41813‎ | r41814 | r41815 >
Date:18:23, 7 October 2008
Author:catrope
Status:old
Tags:
Comment:
(bug 15881) API: Empty or invalid parameters cause database errors
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryBase.php
@@ -126,13 +126,19 @@
127127 * Clauses can be formatted as 'foo=bar' or array('foo' => 'bar'),
128128 * the latter only works if the value is a constant (i.e. not another field)
129129 *
 130+ * If $value is an empty array, this function does nothing.
 131+ *
130132 * For example, array('foo=bar', 'baz' => 3, 'bla' => 'foo') translates
131133 * to "foo=bar AND baz='3' AND bla='foo'"
132134 * @param mixed $value String or array
133135 */
134136 protected function addWhere($value) {
135 - if (is_array($value))
136 - $this->where = array_merge($this->where, $value);
 137+ if (is_array($value)) {
 138+ // Sanity check: don't insert empty arrays,
 139+ // Database::makeList() chokes on them
 140+ if(!empty($value))
 141+ $this->where = array_merge($this->where, $value);
 142+ }
137143 else
138144 $this->where[] = $value;
139145 }
@@ -157,7 +163,7 @@
158164 * @param string $value Value; ignored if nul;
159165 */
160166 protected function addWhereFld($field, $value) {
161 - if (!is_null($value))
 167+ if (!is_null($value) && !empty($value))
162168 $this->where[$field] = $value;
163169 }
164170
Index: trunk/phase3/RELEASE-NOTES
@@ -311,6 +311,7 @@
312312 * (bug 15767) apfilterlanglinks returns duplicate results
313313 * (bug 15845) Added pageid/fromid parameter to action=delete/move, making
314314 manipulation of legacy pages with invalid titles possible
 315+* (bug 15881) Empty or invalid parameters cause database errors
315316
316317 === Languages updated in 1.14 ===
317318

Follow-up revisions

RevisionCommit summaryAuthorDate
r42536* Fix r41814: totally broken use of empty(), ignores conditions that compare ...tstarling08:13, 25 October 2008

Status & tagging log