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];
$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;
{
$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' )
$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 {
$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();
$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
$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 ) )
}
private function run( $resultPageSet = null ) {
-
$db = $this->getDB();
$params = $this->extractRequestParams();
$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}" );
$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 )
( $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];
$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' ) );
// 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;
* @return ResultWrapper
*/
protected function select( $method ) {
-
// getDB has its own profileDBIn/Out calls
$db = $this->getDB();
$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' );
$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" );
}
}
} else {
-
$titles = array();
$count = 0;
while ( $row = $db->fetchObject( $res ) ) {
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;
$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
/* 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. */
}
public function getVersion() {
- return __CLASS__ . ': $Id: ApiQueryTags.php';
+ return __CLASS__ . ': $Id$';
}
}