From: Petr Onderka Date: Sat, 16 Feb 2013 18:30:57 +0000 (+0100) Subject: Return user ID as userid in watchlist API module X-Git-Tag: 1.31.0-rc.0~20408^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=b22d2155fcb58bc18efd5cb921d664d903199aa2;p=lhc%2Fweb%2Fwiklou.git Return user ID as userid in watchlist API module Currently, the watchlist module returns both user ID and user name as 'user'. This is not only confusing, but it also means both can't be returned at the same time. This change fixes that, by returning user ID as 'userid' and user name as 'user'. For backwards compatibility, if only user ID is requested, both 'user' and 'userid' will contain the user ID. This could be considered a breaking change if both user ID and user name are requested, but in that case, the output is currently broken anyway. Change-Id: I50364659f8fec0136d4ef25ccf137d509df33c41 --- diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index dd5062450a..53f4230630 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -240,14 +240,16 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { if ( $this->fld_user || $this->fld_userid ) { - if ( $this->fld_user ) { - $vals['user'] = $row->rc_user_text; - } - if ( $this->fld_userid ) { + $vals['userid'] = $row->rc_user; + // for backwards compatibility $vals['user'] = $row->rc_user; } + if ( $this->fld_user ) { + $vals['user'] = $row->rc_user_text; + } + if ( !$row->rc_user ) { $vals['anon'] = ''; }