r15489 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r15488‎ | r15489 | r15490 >
Date:08:38, 10 July 2006
Author:robchurch
Status:old
Tags:
Comment:
* (bug 6448) Allow filtering of Special:Newpages according to username

Comes with a free index upgrade.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialNewpages.php (modified) (history)
  • /trunk/phase3/languages/Messages.php (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-recentchanges-utindex.sql (added) (history)
  • /trunk/phase3/maintenance/mysql5/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/archives/patch-recentchanges-utindex.sql
@@ -0,0 +1,4 @@
 2+--- July 2006
 3+--- Index on recentchanges.( rc_namespace, rc_user_text )
 4+--- Helps the username filtering in Special:Newpages
 5+ALTER TABLE /*$wgDBprefix*/recentchanges ADD INDEX `rc_ns_usertext` ( `rc_namespace` , `rc_user_text` );
\ No newline at end of file
Property changes on: trunk/phase3/maintenance/archives/patch-recentchanges-utindex.sql
___________________________________________________________________
Name: svn:eol-style
16 + native
Index: trunk/phase3/maintenance/updaters.inc
@@ -762,6 +762,23 @@
763763 echo "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n";
764764 }
765765
 766+# July 2006
 767+# Add ( rc_namespace, rc_user_text ) index [R. Church]
 768+function do_rc_indices_update() {
 769+ global $wgDatabase;
 770+ echo( "Checking for additional recent changes indices...\n" );
 771+ # See if we can find the index we want
 772+ $info = $wgDatabase->indexInfo( 'recentchanges', 'rc_ns_usertext', __METHOD__ );
 773+ if( !$info ) {
 774+ # None, so create
 775+ echo( "...index on ( rc_namespace, rc_user_text ) not found; creating\n" );
 776+ dbsource( archive( 'patch-recentchanges-utindex.sql' ) );
 777+ } else {
 778+ # Index seems to exist
 779+ echo( "...seems to be ok\n" );
 780+ }
 781+}
 782+
766783 function do_all_updates( $doShared = false ) {
767784 global $wgNewTables, $wgNewFields, $wgRenamedTables, $wgSharedDB, $wgDatabase;
768785
@@ -820,6 +837,8 @@
821838 do_logging_timestamp_index(); flush();
822839
823840 do_page_random_update(); flush();
 841+
 842+ do_rc_indices_update(); flush();
824843
825844 initialiseMessages(); flush();
826845 }
Index: trunk/phase3/maintenance/mysql5/tables.sql
@@ -809,7 +809,8 @@
810810 INDEX rc_namespace_title (rc_namespace, rc_title),
811811 INDEX rc_cur_id (rc_cur_id),
812812 INDEX new_name_timestamp(rc_new,rc_namespace,rc_timestamp),
813 - INDEX rc_ip (rc_ip)
 813+ INDEX rc_ip (rc_ip),
 814+ INDEX rc_ns_usertext ( rc_namespace, rc_user_text )
814815
815816 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
816817
Index: trunk/phase3/maintenance/tables.sql
@@ -795,7 +795,8 @@
796796 INDEX rc_namespace_title (rc_namespace, rc_title),
797797 INDEX rc_cur_id (rc_cur_id),
798798 INDEX new_name_timestamp(rc_new,rc_namespace,rc_timestamp),
799 - INDEX rc_ip (rc_ip)
 799+ INDEX rc_ip (rc_ip),
 800+ INDEX rc_ns_usertext ( rc_namespace, rc_user_text )
800801
801802 ) TYPE=InnoDB;
802803
Index: trunk/phase3/includes/SpecialNewpages.php
@@ -11,10 +11,13 @@
1212 * @subpackage SpecialPage
1313 */
1414 class NewPagesPage extends QueryPage {
 15+
1516 var $namespace;
 17+ var $username = '';
1618
17 - function NewPagesPage( $namespace = NS_MAIN ) {
 19+ function NewPagesPage( $namespace = NS_MAIN, $username = '' ) {
1820 $this->namespace = $namespace;
 21+ $this->username = $username;
1922 }
2023
2124 function getName() {
@@ -26,12 +29,18 @@
2730 return false;
2831 }
2932
 33+ function makeUserWhere( &$dbo ) {
 34+ return $this->username ? ' AND rc_user_text = ' . $dbo->addQuotes( $this->username ) : '';
 35+ }
 36+
3037 function getSQL() {
3138 global $wgUser, $wgUseRCPatrol;
3239 $usepatrol = ( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) ) ? 1 : 0;
3340 $dbr =& wfGetDB( DB_SLAVE );
3441 extract( $dbr->tableNames( 'recentchanges', 'page', 'text' ) );
3542
 43+ $uwhere = $this->makeUserWhere( $dbr );
 44+
3645 # FIXME: text will break with compression
3746 return
3847 "SELECT 'Newpages' as type,
@@ -50,7 +59,8 @@
5160 page_latest as rev_id
5261 FROM $recentchanges,$page
5362 WHERE rc_cur_id=page_id AND rc_new=1
54 - AND rc_namespace=" . $this->namespace . " AND page_is_redirect=0";
 63+ AND rc_namespace=" . $this->namespace . " AND page_is_redirect=0
 64+ {$uwhere}";
5565 }
5666
5767 function preprocessResults( &$dbo, &$res ) {
@@ -112,34 +122,20 @@
113123 }
114124
115125 /**
116 - * Show a namespace selection form for filtering
 126+ * Show a form for filtering namespace and username
117127 *
118128 * @return string
119129 */
120130 function getPageHeader() {
121 - $thisTitle = Title::makeTitle( NS_SPECIAL, $this->getName() );
122 - $form = wfOpenElement( 'form', array(
123 - 'method' => 'post',
124 - 'action' => $thisTitle->getLocalUrl() ) );
125 - $form .= wfElement( 'label', array( 'for' => 'namespace' ),
126 - wfMsg( 'namespace' ) ) . ' ';
127 - $form .= HtmlNamespaceSelector( $this->namespace );
128 - # Preserve the offset and limit
129 - $form .= wfElement( 'input', array(
130 - 'type' => 'hidden',
131 - 'name' => 'offset',
132 - 'value' => $this->offset ) );
133 - $form .= wfElement( 'input', array(
134 - 'type' => 'hidden',
135 - 'name' => 'limit',
136 - 'value' => $this->limit ) );
137 - $form .= wfElement( 'input', array(
138 - 'type' => 'submit',
139 - 'name' => 'submit',
140 - 'id' => 'submit',
141 - 'value' => wfMsg( 'allpagessubmit' ) ) );
142 - $form .= wfCloseElement( 'form' );
143 - return( $form );
 131+ $self = Title::makeTitle( NS_SPECIAL, $this->getName() );
 132+ $form = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) );
 133+ $form .= '<table><tr><td align="right">' . wfMsgHtml( 'namespace' ) . '</td>';
 134+ $form .= '<td>' . HtmlNamespaceSelector( $this->namespace ) . '</td><tr>';
 135+ $form .= '<tr><td align="right">' . wfMsgHtml( 'newpages-username' ) . '</td>';
 136+ $form .= '<td>' . wfInput( 'username', 30, $this->username ) . '</td></tr>';
 137+ $form .= '<tr><td></td><td>' . wfSubmitButton( wfMsg( 'allpagessubmit' ) ) . '</td></tr></table>';
 138+ $form .= wfHidden( 'offset', $this->offset ) . wfHidden( 'limit', $this->limit ) . '</form>';
 139+ return $form;
144140 }
145141
146142 /**
@@ -148,7 +144,7 @@
149145 * @return array
150146 */
151147 function linkParameters() {
152 - return( array( 'namespace' => $this->namespace ) );
 148+ return( array( 'namespace' => $this->namespace, 'username' => $this->username ) );
153149 }
154150
155151 }
@@ -161,6 +157,7 @@
162158
163159 list( $limit, $offset ) = wfCheckLimits();
164160 $namespace = NS_MAIN;
 161+ $username = '';
165162
166163 if ( $par ) {
167164 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
@@ -184,12 +181,14 @@
185182 } else {
186183 if( $ns = $wgRequest->getInt( 'namespace', 0 ) )
187184 $namespace = $ns;
 185+ if( $un = $wgRequest->getText( 'username' ) )
 186+ $username = $un;
188187 }
189188
190189 if ( ! isset( $shownavigation ) )
191190 $shownavigation = ! $specialPage->including();
192191
193 - $npp = new NewPagesPage( $namespace );
 192+ $npp = new NewPagesPage( $namespace, $username );
194193
195194 if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ), $limit ) )
196195 $npp->doQuery( $offset, $limit, $shownavigation );
Index: trunk/phase3/RELEASE-NOTES
@@ -41,6 +41,7 @@
4242 attempts to create an account. Fixed inefficiency of Special:Ipblocklist in
4343 the presence of large numbers of blocks; added indexes and implemented an
4444 indexed pager.
 45+* (bug 6448) Allow filtering of Special:Newpages according to username
4546
4647 == Languages updated ==
4748
Index: trunk/phase3/languages/Messages.php
@@ -981,6 +981,7 @@
982982 'recentchangeslinked' => 'Related changes',
983983 'rclsub' => "(to pages linked from \"$1\")",
984984 'newpages' => 'New pages',
 985+'newpages-username' => 'Username:',
985986 'ancientpages' => 'Oldest pages',
986987 'intl' => 'Interlanguage links',
987988 'move' => 'Move',