* (bug 6448) Allow filtering of Special:Newpages according to username
authorRob Church <robchurch@users.mediawiki.org>
Mon, 10 Jul 2006 08:38:48 +0000 (08:38 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Mon, 10 Jul 2006 08:38:48 +0000 (08:38 +0000)
Comes with a free index upgrade.

RELEASE-NOTES
includes/SpecialNewpages.php
languages/Messages.php
maintenance/archives/patch-recentchanges-utindex.sql [new file with mode: 0644]
maintenance/mysql5/tables.sql
maintenance/tables.sql
maintenance/updaters.inc

index c4959bf..4f1ebcd 100644 (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 ==
 
index c0c6ba9..c050137 100644 (file)
  * @subpackage SpecialPage
  */
 class NewPagesPage extends QueryPage {
+
        var $namespace;
+       var $username = '';
 
-       function NewPagesPage( $namespace = NS_MAIN ) {
+       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 );
index 1f02b2b..68efed8 100644 (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',
diff --git a/maintenance/archives/patch-recentchanges-utindex.sql b/maintenance/archives/patch-recentchanges-utindex.sql
new file mode 100644 (file)
index 0000000..4ebe316
--- /dev/null
@@ -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` );
\ No newline at end of file
index 0ee6e2a..e1ae0e6 100644 (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;
 
index b00115e..67b620a 100644 (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;
 
index 0174168..9acf302 100644 (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();
 }