* (bug 6448) Allow filtering of Special:Newpages according to username

Comes with a free index upgrade.
This commit is contained in:
Rob Church 2006-07-10 08:38:48 +00:00
parent 23f2b6b5c5
commit 861e40c622
7 changed files with 57 additions and 31 deletions

View file

@ -41,6 +41,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
attempts to create an account. Fixed inefficiency of Special:Ipblocklist in
the presence of large numbers of blocks; added indexes and implemented an
indexed pager.
* (bug 6448) Allow filtering of Special:Newpages according to username
== Languages updated ==

View file

@ -11,10 +11,13 @@
* @subpackage SpecialPage
*/
class NewPagesPage extends QueryPage {
var $namespace;
function NewPagesPage( $namespace = NS_MAIN ) {
var $namespace;
var $username = '';
function NewPagesPage( $namespace = NS_MAIN, $username = '' ) {
$this->namespace = $namespace;
$this->username = $username;
}
function getName() {
@ -26,12 +29,18 @@ class NewPagesPage extends QueryPage {
return false;
}
function makeUserWhere( &$dbo ) {
return $this->username ? ' AND rc_user_text = ' . $dbo->addQuotes( $this->username ) : '';
}
function getSQL() {
global $wgUser, $wgUseRCPatrol;
$usepatrol = ( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) ) ? 1 : 0;
$dbr =& wfGetDB( DB_SLAVE );
extract( $dbr->tableNames( 'recentchanges', 'page', 'text' ) );
$uwhere = $this->makeUserWhere( $dbr );
# FIXME: text will break with compression
return
"SELECT 'Newpages' as type,
@ -50,7 +59,8 @@ class NewPagesPage extends QueryPage {
page_latest as rev_id
FROM $recentchanges,$page
WHERE rc_cur_id=page_id AND rc_new=1
AND rc_namespace=" . $this->namespace . " AND page_is_redirect=0";
AND rc_namespace=" . $this->namespace . " AND page_is_redirect=0
{$uwhere}";
}
function preprocessResults( &$dbo, &$res ) {
@ -112,34 +122,20 @@ class NewPagesPage extends QueryPage {
}
/**
* Show a namespace selection form for filtering
* Show a form for filtering namespace and username
*
* @return string
*/
function getPageHeader() {
$thisTitle = Title::makeTitle( NS_SPECIAL, $this->getName() );
$form = wfOpenElement( 'form', array(
'method' => 'post',
'action' => $thisTitle->getLocalUrl() ) );
$form .= wfElement( 'label', array( 'for' => 'namespace' ),
wfMsg( 'namespace' ) ) . ' ';
$form .= HtmlNamespaceSelector( $this->namespace );
# Preserve the offset and limit
$form .= wfElement( 'input', array(
'type' => 'hidden',
'name' => 'offset',
'value' => $this->offset ) );
$form .= wfElement( 'input', array(
'type' => 'hidden',
'name' => 'limit',
'value' => $this->limit ) );
$form .= wfElement( 'input', array(
'type' => 'submit',
'name' => 'submit',
'id' => 'submit',
'value' => wfMsg( 'allpagessubmit' ) ) );
$form .= wfCloseElement( 'form' );
return( $form );
$self = Title::makeTitle( NS_SPECIAL, $this->getName() );
$form = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) );
$form .= '<table><tr><td align="right">' . wfMsgHtml( 'namespace' ) . '</td>';
$form .= '<td>' . HtmlNamespaceSelector( $this->namespace ) . '</td><tr>';
$form .= '<tr><td align="right">' . wfMsgHtml( 'newpages-username' ) . '</td>';
$form .= '<td>' . wfInput( 'username', 30, $this->username ) . '</td></tr>';
$form .= '<tr><td></td><td>' . wfSubmitButton( wfMsg( 'allpagessubmit' ) ) . '</td></tr></table>';
$form .= wfHidden( 'offset', $this->offset ) . wfHidden( 'limit', $this->limit ) . '</form>';
return $form;
}
/**
@ -148,7 +144,7 @@ class NewPagesPage extends QueryPage {
* @return array
*/
function linkParameters() {
return( array( 'namespace' => $this->namespace ) );
return( array( 'namespace' => $this->namespace, 'username' => $this->username ) );
}
}
@ -161,6 +157,7 @@ function wfSpecialNewpages($par, $specialPage) {
list( $limit, $offset ) = wfCheckLimits();
$namespace = NS_MAIN;
$username = '';
if ( $par ) {
$bits = preg_split( '/\s*,\s*/', trim( $par ) );
@ -184,12 +181,14 @@ function wfSpecialNewpages($par, $specialPage) {
} else {
if( $ns = $wgRequest->getInt( 'namespace', 0 ) )
$namespace = $ns;
if( $un = $wgRequest->getText( 'username' ) )
$username = $un;
}
if ( ! isset( $shownavigation ) )
$shownavigation = ! $specialPage->including();
$npp = new NewPagesPage( $namespace );
$npp = new NewPagesPage( $namespace, $username );
if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ), $limit ) )
$npp->doQuery( $offset, $limit, $shownavigation );

View file

@ -981,6 +981,7 @@ The [http://meta.wikimedia.org/wiki/Help:Job_queue job queue] length is '''$7'''
'recentchangeslinked' => 'Related changes',
'rclsub' => "(to pages linked from \"$1\")",
'newpages' => 'New pages',
'newpages-username' => 'Username:',
'ancientpages' => 'Oldest pages',
'intl' => 'Interlanguage links',
'move' => 'Move',

View file

@ -0,0 +1,4 @@
--- July 2006
--- Index on recentchanges.( rc_namespace, rc_user_text )
--- Helps the username filtering in Special:Newpages
ALTER TABLE /*$wgDBprefix*/recentchanges ADD INDEX `rc_ns_usertext` ( `rc_namespace` , `rc_user_text` );

View file

@ -809,7 +809,8 @@ CREATE TABLE /*$wgDBprefix*/recentchanges (
INDEX rc_namespace_title (rc_namespace, rc_title),
INDEX rc_cur_id (rc_cur_id),
INDEX new_name_timestamp(rc_new,rc_namespace,rc_timestamp),
INDEX rc_ip (rc_ip)
INDEX rc_ip (rc_ip),
INDEX rc_ns_usertext ( rc_namespace, rc_user_text )
) TYPE=InnoDB, DEFAULT CHARSET=utf8;

View file

@ -795,7 +795,8 @@ CREATE TABLE /*$wgDBprefix*/recentchanges (
INDEX rc_namespace_title (rc_namespace, rc_title),
INDEX rc_cur_id (rc_cur_id),
INDEX new_name_timestamp(rc_new,rc_namespace,rc_timestamp),
INDEX rc_ip (rc_ip)
INDEX rc_ip (rc_ip),
INDEX rc_ns_usertext ( rc_namespace, rc_user_text )
) TYPE=InnoDB;

View file

@ -762,6 +762,23 @@ function do_templatelinks_update() {
echo "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n";
}
# July 2006
# Add ( rc_namespace, rc_user_text ) index [R. Church]
function do_rc_indices_update() {
global $wgDatabase;
echo( "Checking for additional recent changes indices...\n" );
# See if we can find the index we want
$info = $wgDatabase->indexInfo( 'recentchanges', 'rc_ns_usertext', __METHOD__ );
if( !$info ) {
# None, so create
echo( "...index on ( rc_namespace, rc_user_text ) not found; creating\n" );
dbsource( archive( 'patch-recentchanges-utindex.sql' ) );
} else {
# Index seems to exist
echo( "...seems to be ok\n" );
}
}
function do_all_updates( $doShared = false ) {
global $wgNewTables, $wgNewFields, $wgRenamedTables, $wgSharedDB, $wgDatabase;
@ -820,6 +837,8 @@ function do_all_updates( $doShared = false ) {
do_logging_timestamp_index(); flush();
do_page_random_update(); flush();
do_rc_indices_update(); flush();
initialiseMessages(); flush();
}