r108856 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108855‎ | r108856 | r108857 >
Date:21:51, 13 January 2012
Author:reedy
Status:resolved
Tags:
Comment:
Refactored some code (reducing duplication)
Modified paths:
  • /trunk/extensions/CheckUser/api/ApiQueryCheckUser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CheckUser/api/ApiQueryCheckUser.php
@@ -77,20 +77,19 @@
7878 break;
7979
8080 case 'edits':
81 - if ( IP::isIPAddress( $target ) && isset( $xff ) ) {
82 - $cond = CheckUser::getIpConds( $db, $target, true );
 81+ if ( IP::isIPAddress( $target ) ) {
 82+ $cond = CheckUser::getIpConds( $db, $target, isset( $xff ) );
8383 if ( !$cond ) {
8484 $this->dieUsage( 'IP or range is invalid', 'invalidip' );
8585 }
8686 $this->addWhere( $cond );
87 - $log_type = array( 'ipedits-xff', 'ip' );
88 - } elseif ( IP::isIPAddress( $target ) ) {
89 - $cond = CheckUser::getIpConds( $db, $target );
90 - if ( !$cond ) {
91 - $this->dieUsage( 'IP or range is invalid', 'invalidip' );
 87+ $log_type = array();
 88+ if ( isset( $xff ) ) {
 89+ $log_type[] = 'ipeditsxff';
 90+ } else {
 91+ $log_type[] = 'ipedits';
9292 }
93 - $this->addWhere( $cond );
94 - $log_type = array( 'ipedits', 'ip' );
 93+ $log_type[] = 'ip' ;
9594 } else {
9695 $user_id = User::idFromName( $target );
9796 if ( !$user_id ) {
@@ -137,14 +136,13 @@
138137 break;
139138
140139 case 'ipusers':
141 - if ( IP::isIPAddress( $target ) && isset( $xff ) ) {
142 - $cond = CheckUser::getIpConds( $db, $target, true );
 140+ if ( IP::isIPAddress( $target ) ) {
 141+ $cond = CheckUser::getIpConds( $db, $target, isset( $xff ) );
143142 $this->addWhere( $cond );
144 - $log_type = 'ipusersxff';
145 - } elseif ( IP::isIPAddress( $target ) ) {
146 - $cond = CheckUser::getIpConds( $db, $target );
147 - $this->addWhere( $cond );
148143 $log_type = 'ipusers';
 144+ if ( isset( $xff ) ) {
 145+ $log_type .= 'xff';
 146+ }
149147 } else {
150148 $this->dieUsage( 'IP or range is invalid', 'invalidip' );
151149 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r108859Fix eaten hyphen from r108856...reedy21:59, 13 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100165Adds API Module by cryptocoryne...johnduhart21:37, 18 October 2011

Status & tagging log