More of r61437 (adding/removing whitespace)
authorSam Reed <reedy@users.mediawiki.org>
Sat, 23 Jan 2010 22:47:49 +0000 (22:47 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sat, 23 Jan 2010 22:47:49 +0000 (22:47 +0000)
13 files changed:
includes/api/ApiParamInfo.php
includes/api/ApiParse.php
includes/api/ApiProtect.php
includes/api/ApiQuery.php
includes/api/ApiQueryAllmessages.php
includes/api/ApiQueryAllpages.php
includes/api/ApiQueryBacklinks.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryInfo.php
includes/api/ApiQueryLinks.php
includes/api/ApiQueryProtectedTitles.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryTags.php

index 0c4778f..bebc847 100644 (file)
@@ -147,9 +147,11 @@ class ApiParamInfo extends ApiBase {
                                                        ApiBase::LIMIT_SML2 :
                                                        ApiBase::LIMIT_SML1;
                                }
+
                        if ( isset( $p[ApiBase::PARAM_ALLOW_DUPLICATES] ) )
                                if ( $p[ApiBase::PARAM_ALLOW_DUPLICATES] )
                                        $a['allowsduplicates'] = '';
+
                        if ( isset( $p[ApiBase::PARAM_TYPE] ) )
                        {
                                $a['type'] = $p[ApiBase::PARAM_TYPE];
index ae05935..ff133e5 100644 (file)
@@ -66,6 +66,7 @@ class ApiParse extends ApiBase {
                                        $this->dieUsage( "There is no revision ID $oldid", 'missingrev' );
                                if ( !$rev->userCan( Revision::DELETED_TEXT ) )
                                        $this->dieUsage( "You don't have permission to view deleted revisions", 'permissiondenied' );
+
                                $text = $rev->getText( Revision::FOR_THIS_USER );
                                $titleObj = $rev->getTitle();
                                $wgTitle = $titleObj;
index 233486f..2253dc9 100644 (file)
@@ -78,10 +78,12 @@ class ApiProtect extends ApiBase {
                {
                        $p = explode( '=', $prot );
                        $protections[$p[0]] = ( $p[1] == 'all' ? '' : $p[1] );
+
                        if ( $titleObj->exists() && $p[0] == 'create' )
                                $this->dieUsageMsg( array( 'create-titleexists' ) );
                        if ( !$titleObj->exists() && $p[0] != 'create' )
                                $this->dieUsageMsg( array( 'missingtitle-createonly' ) );
+
                        if ( !in_array( $p[0], $restrictionTypes ) && $p[0] != 'create' )
                                $this->dieUsageMsg( array( 'protect-invalidaction', $p[0] ) );
                        if ( !in_array( $p[1], $wgRestrictionLevels ) && $p[1] != 'all' )
index 1fcbf6c..f425359 100644 (file)
@@ -197,22 +197,16 @@ class ApiQuery extends ApiBase {
                $this->params = $this->extractRequestParams();
                $this->redirects = $this->params['redirects'];
 
-               //
                // Create PageSet
-               //
                $this->mPageSet = new ApiPageSet( $this, $this->redirects );
 
-               //
                // Instantiate requested modules
-               //
                $modules = array ();
                $this->InstantiateModules( $modules, 'prop', $this->mQueryPropModules );
                $this->InstantiateModules( $modules, 'list', $this->mQueryListModules );
                $this->InstantiateModules( $modules, 'meta', $this->mQueryMetaModules );
 
-               //
                // If given, execute generator to substitute user supplied data with generated data.
-               //
                if ( isset ( $this->params['generator'] ) ) {
                        $this->executeGeneratorModule( $this->params['generator'], $modules );
                } else {
@@ -221,14 +215,10 @@ class ApiQuery extends ApiBase {
                        $this->mPageSet->execute();
                }
 
-               //
                // Record page information (title, namespace, if exists, etc)
-               //
                $this->outputGeneralPageInfo();
 
-               //
                // Execute all requested modules.
-               //
                foreach ( $modules as $module ) {
                        $module->profileIn();
                        $module->execute();
@@ -391,6 +381,7 @@ class ApiQuery extends ApiBase {
                        $exporter->closeStream();
                        $exportxml = ob_get_contents();
                        ob_end_clean();
+
                        // Don't check the size of exported stuff
                        // It's not continuable, so it would cause more
                        // problems than it'd solve
index 25fb1bf..5601e4e 100644 (file)
@@ -77,9 +77,9 @@ class ApiQueryAllmessages extends ApiQueryBase {
                $result = $this->getResult();
                foreach ( $messages_target as $message ) {
                        // Skip all messages up to $params['from']
-                       if ( $skip && $message === $params['from'] )
+                       if ( $skip && $message === $params['from'] ) {
                                $skip = false;
-                       if ( !$skip ) {
+
                                $a = array( 'name' => $message );
                                $msg = wfMsgGetKey( $message, true, false, false );
                                if ( wfEmptyMsg( $message, $msg ) )
index 0f29b3a..def1679 100644 (file)
@@ -51,7 +51,6 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
        }
 
        private function run( $resultPageSet = null ) {
-
                $db = $this->getDB();
 
                $params = $this->extractRequestParams();
index 6b4ee3f..2ec54f7 100644 (file)
@@ -109,11 +109,14 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                        $this->addFields( array( 'page_id', 'page_title', 'page_namespace' ) );
                else
                        $this->addFields( $resultPageSet->getPageTableFields() );
+
                $this->addFields( 'page_is_redirect' );
                $this->addWhereFld( $this->bl_title, $this->rootTitle->getDBkey() );
+
                if ( $this->hasNS )
                        $this->addWhereFld( $this->bl_ns, $this->rootTitle->getNamespace() );
                $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
+
                if ( !is_null( $this->contID ) )
                        $this->addWhere( "{$this->bl_from}>={$this->contID}" );
 
@@ -136,13 +139,16 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                $db = $this->getDB();
                $this->addTables( array( 'page', $this->bl_table ) );
                $this->addWhere( "{$this->bl_from}=page_id" );
+
                if ( is_null( $resultPageSet ) )
                        $this->addFields( array( 'page_id', 'page_title', 'page_namespace', 'page_is_redirect' ) );
                else
                        $this->addFields( $resultPageSet->getPageTableFields() );
+
                $this->addFields( $this->bl_title );
                if ( $this->hasNS )
                        $this->addFields( $this->bl_ns );
+
                // We can't use LinkBatch here because $this->hasNS may be false
                $titleWhere = array();
                foreach ( $this->redirTitles as $t )
@@ -150,6 +156,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                                        ( $this->hasNS ? " AND {$this->bl_ns} = '{$t->getNamespace()}'" : "" );
                $this->addWhere( $db->makeList( $titleWhere, LIST_OR ) );
                $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
+
                if ( !is_null( $this->redirID ) )
                {
                        $first = $this->redirTitles[0];
@@ -172,6 +179,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                        $this->addWhereFld( 'page_is_redirect', 1 );
                else if ( $this->params['filterredir'] == 'nonredirects' )
                        $this->addWhereFld( 'page_is_redirect', 0 );
+
                $this->addOption( 'LIMIT', $this->params['limit'] + 1 );
                $this->addOption( 'ORDER BY', $this->bl_sort );
                $this->addOption( 'USE INDEX', array( 'page' => 'PRIMARY' ) );
@@ -356,13 +364,16 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                        // Illegal continue parameter
                        $this->dieUsage( "Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue" );
                $this->rootTitle = Title::makeTitleSafe( $rootNs, $continueList[1] );
+
                if ( !$this->rootTitle )
                        $this->dieUsage( "Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue" );
                $contID = intval( $continueList[2] );
+
                if ( $contID === 0 && $continueList[2] !== '0' )
                        $this->dieUsage( "Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue" );
                $this->contID = $contID;
                $redirID = intval( @$continueList[3] );
+               
                if ( $redirID === 0 && @$continueList[3] !== '0' )
                        // This one isn't required
                        return;
index b325420..96c766b 100644 (file)
@@ -226,7 +226,6 @@ abstract class ApiQueryBase extends ApiBase {
         * @return ResultWrapper
         */
        protected function select( $method ) {
-
                // getDB has its own profileDBIn/Out calls
                $db = $this->getDB();
 
index 61787b3..a8df91c 100644 (file)
@@ -305,12 +305,16 @@ class ApiQueryInfo extends ApiQueryBase {
                                        $this->protections[$title->getNamespace()][$title->getDBkey()];
                        $this->getResult()->setIndexedTagName( $pageInfo['protection'], 'pr' );
                }
+
                if ( $this->fld_watched && isset( $this->watched[$title->getNamespace()][$title->getDBkey()] ) )
                        $pageInfo['watched'] = '';
+       
                if ( $this->fld_talkid && isset( $this->talkids[$title->getNamespace()][$title->getDBkey()] ) )
                        $pageInfo['talkid'] = $this->talkids[$title->getNamespace()][$title->getDBkey()];
+
                if ( $this->fld_subjectid && isset( $this->subjectids[$title->getNamespace()][$title->getDBkey()] ) )
                        $pageInfo['subjectid'] = $this->subjectids[$title->getNamespace()][$title->getDBkey()];
+
                if ( $this->fld_url ) {
                        $pageInfo['fullurl'] = $title->getFullURL();
                        $pageInfo['editurl'] = $title->getFullURL( 'action=edit' );
index 3a855b9..7f8ceec 100644 (file)
@@ -110,6 +110,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                        $order[] = "{$this->prefix}_from";
                if ( count( $params['namespace'] ) != 1 )
                        $order[] = "{$this->prefix}_namespace";
+
                $order[] = "{$this->prefix}_title";
                $this->addOption( 'ORDER BY', implode( ", ", $order ) );
                $this->addOption( 'USE INDEX', "{$this->prefix}_from" );
@@ -141,7 +142,6 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                                }
                        }
                } else {
-
                        $titles = array();
                        $count = 0;
                        while ( $row = $db->fetchObject( $res ) ) {
index ef95905..038988a 100644 (file)
@@ -91,12 +91,16 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
                                ApiQueryBase::addTitleInfo( $vals, $title );
                                if ( isset( $prop['timestamp'] ) )
                                        $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->pt_timestamp );
+                                       
                                if ( isset( $prop['user'] ) && !is_null( $row->user_name ) )
                                        $vals['user'] = $row->user_name;
+                                       
                                if ( isset( $prop['comment'] ) )
                                        $vals['comment'] = $row->pt_reason;
+                                       
                                if ( isset( $prop['expiry'] ) )
                                        $vals['expiry'] = Block::decodeExpiry( $row->pt_expiry, TS_ISO_8601 );
+                                       
                                if ( isset( $prop['level'] ) )
                                        $vals['level'] = $row->pt_create_perm;
                                
index d90fa3a..90f8473 100644 (file)
@@ -149,17 +149,20 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                        $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
                        $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
                        $this->addWhereIf( 'page_is_redirect = 1', isset ( $show['redirect'] ) );
+                       
                        // Don't throw log entries out the window here
                        $this->addWhereIf( 'page_is_redirect = 0 OR page_is_redirect IS NULL', isset ( $show['!redirect'] ) );
                }
                
                if ( !is_null( $params['user'] ) && !is_null( $param['excludeuser'] ) )
                        $this->dieUsage( 'user and excludeuser cannot be used together', 'user-excludeuser' );
+                       
                if ( !is_null( $params['user'] ) )
                {
                        $this->addWhereFld( 'rc_user_text', $params['user'] );
                        $index = 'rc_user_text';
                }
+               
                if ( !is_null( $params['excludeuser'] ) )
                        // We don't use the rc_user_text index here because
                        // * it would require us to sort by rc_user_text before rc_timestamp
@@ -284,12 +287,23 @@ class ApiQueryRecentChanges extends ApiQueryBase {
 
                /* Determine what kind of change this was. */
                switch ( $type ) {
-                       case RC_EDIT:  $vals['type'] = 'edit'; break;
-                       case RC_NEW:   $vals['type'] = 'new'; break;
-                       case RC_MOVE:  $vals['type'] = 'move'; break;
-                       case RC_LOG:   $vals['type'] = 'log'; break;
-                       case RC_MOVE_OVER_REDIRECT: $vals['type'] = 'move over redirect'; break;
-               default: $vals['type'] = $type;
+                       case RC_EDIT:
+                               $vals['type'] = 'edit';
+                               break;
+                       case RC_NEW:
+                               $vals['type'] = 'new';
+                               break;
+                       case RC_MOVE:
+                               $vals['type'] = 'move';
+                               break;
+                       case RC_LOG:
+                               $vals['type'] = 'log';
+                               break;
+                       case RC_MOVE_OVER_REDIRECT:
+                               $vals['type'] = 'move over redirect';
+                               break;
+                       default:
+                               $vals['type'] = $type;
                }
 
                /* Create a new entry in the result for the title. */
index 7e75cb7..bb3e450 100644 (file)
@@ -172,6 +172,6 @@ class ApiQueryTags extends ApiQueryBase {
        }
 
        public function getVersion() {
-               return __CLASS__ . ': $Id: ApiQueryTags.php';
+               return __CLASS__ . ': $Id$';
        }
 }