Add final period to API module descriptions
[lhc/web/wiklou.git] / includes / api / ApiQueryUserContributions.php
index 7896a2c..b58a951 100644 (file)
@@ -56,6 +56,11 @@ class ApiQueryContributions extends ApiQueryBase {
                $this->fld_patrolled = isset( $prop['patrolled'] );
                $this->fld_tags = isset( $prop['tags'] );
 
+               // Most of this code will use the 'contributions' group DB, which can map to slaves
+               // with extra user based indexes or partioning by user. The additional metadata
+               // queries should use a regular slave since the lookup pattern is not all by user.
+               $dbSecondary = $this->getDB(); // any random slave
+
                // TODO: if the query is going only against the revision table, should this be done?
                $this->selectNamedDB( 'contributions', DB_SLAVE, 'contributions' );
 
@@ -90,7 +95,7 @@ class ApiQueryContributions extends ApiQueryBase {
                                        $revIds[] = $row->rev_parent_id;
                                }
                        }
-                       $this->parentLens = Revision::getParentLengths( $this->getDB(), $revIds );
+                       $this->parentLens = Revision::getParentLengths( $dbSecondary, $revIds );
                        $res->rewind(); // reset
                }
 
@@ -207,10 +212,16 @@ class ApiQueryContributions extends ApiQueryBase {
                $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
 
                $show = $this->params['show'];
+               if ( $this->params['toponly'] ) { // deprecated/old param
+                       $show[] = 'top';
+               }
                if ( !is_null( $show ) ) {
                        $show = array_flip( $show );
+
                        if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
                                || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
+                               || ( isset( $show['top'] ) && isset( $show['!top'] ) )
+                               || ( isset( $show['new'] ) && isset( $show['!new'] ) )
                        ) {
                                $this->dieUsageMsg( 'show' );
                        }
@@ -219,6 +230,10 @@ class ApiQueryContributions extends ApiQueryBase {
                        $this->addWhereIf( 'rev_minor_edit != 0', isset( $show['minor'] ) );
                        $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
                        $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
+                       $this->addWhereIf( 'rev_id != page_latest', isset( $show['!top'] ) );
+                       $this->addWhereIf( 'rev_id = page_latest', isset( $show['top'] ) );
+                       $this->addWhereIf( 'rev_parent_id != 0', isset( $show['!new'] ) );
+                       $this->addWhereIf( 'rev_parent_id = 0', isset( $show['new'] ) );
                }
                $this->addOption( 'LIMIT', $this->params['limit'] + 1 );
                $index = array( 'revision' => 'usertext_timestamp' );
@@ -294,10 +309,6 @@ class ApiQueryContributions extends ApiQueryBase {
                        $this->addWhereFld( 'ct_tag', $this->params['tag'] );
                }
 
-               if ( $this->params['toponly'] ) {
-                       $this->addWhere( 'rev_id = page_latest' );
-               }
-
                $this->addOption( 'USE INDEX', $index );
        }
 
@@ -360,7 +371,13 @@ class ApiQueryContributions extends ApiQueryBase {
                                $vals['commenthidden'] = '';
                                $anyHidden = true;
                        }
-                       if ( Revision::userCanBitfield( $row->rev_deleted, Revision::DELETED_COMMENT, $this->getUser() ) ) {
+
+                       $userCanView = Revision::userCanBitfield(
+                               $row->rev_deleted,
+                               Revision::DELETED_COMMENT, $this->getUser()
+                       );
+
+                       if ( $userCanView ) {
                                if ( $this->fld_comment ) {
                                        $vals['comment'] = $row->rev_comment;
                                }
@@ -471,10 +488,17 @@ class ApiQueryContributions extends ApiQueryBase {
                                        '!minor',
                                        'patrolled',
                                        '!patrolled',
+                                       'top',
+                                       '!top',
+                                       'new',
+                                       '!new',
                                )
                        ),
                        'tag' => null,
-                       'toponly' => false,
+                       'toponly' => array(
+                               ApiBase::PARAM_DFLT => false,
+                               ApiBase::PARAM_DEPRECATED => true,
+                       ),
                );
        }
 
@@ -577,7 +601,7 @@ class ApiQueryContributions extends ApiQueryBase {
        }
 
        public function getDescription() {
-               return 'Get all edits by a user';
+               return 'Get all edits by a user.';
        }
 
        public function getPossibleErrors() {