From b739e97341be4b70b53aa732c336ae383ad46c78 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sat, 23 Jan 2010 22:47:49 +0000 Subject: [PATCH] More of r61437 (adding/removing whitespace) --- includes/api/ApiParamInfo.php | 2 ++ includes/api/ApiParse.php | 1 + includes/api/ApiProtect.php | 2 ++ includes/api/ApiQuery.php | 11 +--------- includes/api/ApiQueryAllmessages.php | 4 ++-- includes/api/ApiQueryAllpages.php | 1 - includes/api/ApiQueryBacklinks.php | 11 ++++++++++ includes/api/ApiQueryBase.php | 1 - includes/api/ApiQueryInfo.php | 4 ++++ includes/api/ApiQueryLinks.php | 2 +- includes/api/ApiQueryProtectedTitles.php | 4 ++++ includes/api/ApiQueryRecentChanges.php | 26 ++++++++++++++++++------ includes/api/ApiQueryTags.php | 2 +- 13 files changed, 49 insertions(+), 22 deletions(-) diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php index 0c4778f9fe..bebc84701f 100644 --- a/includes/api/ApiParamInfo.php +++ b/includes/api/ApiParamInfo.php @@ -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]; diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index ae0593547c..ff133e5a8a 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -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; diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index 233486f354..2253dc91e1 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -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' ) diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index 1fcbf6c912..f425359963 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -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 diff --git a/includes/api/ApiQueryAllmessages.php b/includes/api/ApiQueryAllmessages.php index 25fb1bf329..5601e4ede7 100644 --- a/includes/api/ApiQueryAllmessages.php +++ b/includes/api/ApiQueryAllmessages.php @@ -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 ) ) diff --git a/includes/api/ApiQueryAllpages.php b/includes/api/ApiQueryAllpages.php index 0f29b3a2ea..def1679afd 100644 --- a/includes/api/ApiQueryAllpages.php +++ b/includes/api/ApiQueryAllpages.php @@ -51,7 +51,6 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase { } private function run( $resultPageSet = null ) { - $db = $this->getDB(); $params = $this->extractRequestParams(); diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index 6b4ee3fa06..2ec54f72be 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -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; diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index b3254202d6..96c766b098 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -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(); diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 61787b37f2..a8df91c70b 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -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' ); diff --git a/includes/api/ApiQueryLinks.php b/includes/api/ApiQueryLinks.php index 3a855b912d..7f8ceec756 100644 --- a/includes/api/ApiQueryLinks.php +++ b/includes/api/ApiQueryLinks.php @@ -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 ) ) { diff --git a/includes/api/ApiQueryProtectedTitles.php b/includes/api/ApiQueryProtectedTitles.php index ef95905fec..038988abed 100644 --- a/includes/api/ApiQueryProtectedTitles.php +++ b/includes/api/ApiQueryProtectedTitles.php @@ -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; diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index d90fa3ac85..90f847346f 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -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. */ diff --git a/includes/api/ApiQueryTags.php b/includes/api/ApiQueryTags.php index 7e75cb76b5..bb3e450402 100644 --- a/includes/api/ApiQueryTags.php +++ b/includes/api/ApiQueryTags.php @@ -172,6 +172,6 @@ class ApiQueryTags extends ApiQueryBase { } public function getVersion() { - return __CLASS__ . ': $Id: ApiQueryTags.php'; + return __CLASS__ . ': $Id$'; } } -- 2.20.1