r25263 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25262‎ | r25263 | r25264 >
Date:01:11, 29 August 2007
Author:aaron
Status:old
Tags:
Comment:
*Check user page/talk existence
*Remove some query cruft
*Use dbkey when checking log_title (not username)
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -1132,26 +1132,31 @@
11331133
11341134 if( !$wgFlaggedRevsAutopromote )
11351135 return true;
1136 - // Grab current groups
 1136+ # Grab current groups
11371137 $groups = $user->getGroups();
11381138 $now = time();
11391139 $usercreation = wfTimestamp(TS_UNIX,$user->mRegistration);
11401140 $userage = floor(($now-$usercreation) / 86400);
1141 - // Do not give this to current holders or bots
 1141+ # Do not give this to current holders or bots
11421142 if( in_array( array('bot','editor'), $groups ) )
11431143 return true;
1144 - // Check if we need to promote...
 1144+ # Check if we need to promote...
11451145 if( $userage < $wgFlaggedRevsAutopromote['days'] )
11461146 return true;
11471147 if( $user->getEditCount() < $wgFlaggedRevsAutopromote['edits'] )
11481148 return true;
11491149 if( $wgFlaggedRevsAutopromote['email'] && !$wgUser->isAllowed('emailconfirmed') )
11501150 return true;
 1151+ # User must have a user page and talk page
 1152+ $up = $user->getUserPage();
 1153+ $utp = $user->getTalkPage();
 1154+ if( !$up->exists() || !$utp->exists() )
 1155+ return true;
11511156 # Do not re-add status if it was previously removed...
11521157 $db = wfGetDB( DB_MASTER );
11531158 $removed = $dbw->selectField( 'logging', '1',
11541159 array( 'log_namespace' => NS_USER,
1155 - 'log_title' => $wgUser->getName(),
 1160+ 'log_title' => $wgUser->getUserPage()->getDBkey(),
11561161 'log_type' => 'rights',
11571162 'log_action' => 'erevoke' ),
11581163 __METHOD__,
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage_body.php
@@ -754,7 +754,7 @@
755755 class UnreviewedPagesPage extends PageQueryPage {
756756
757757 function __construct( $namespace, $showOutdated=false, $category=NULL ) {
758 - $this->namespace = intval($namespace);
 758+ $this->namespace = $namespace;
759759 $this->category = $category;
760760 $this->showOutdated = $showOutdated;
761761 }
@@ -775,13 +775,14 @@
776776
777777 list($page,$flaggedrevs,$categorylinks) = $dbr->tableNamesN('page','flaggedrevs','categorylinks');
778778 # Must be a content page...
 779+ if( !is_null($namespace) )
 780+ $namespace = intval($namespace);
 781+
779782 if( is_null($namespace) || !in_array($namespace,$wgFlaggedRevsNamespaces) ) {
780 - $where = 'page_namespace IN(' . implode(',',$wgFlaggedRevsNamespaces) . ') ';
781 - } else {
782 - $where = "page_namespace={$namespace} ";
 783+ $namespace = empty($wgFlaggedRevsNamespaces) ? -1 : $wgFlaggedRevsNamespaces[0];
783784 }
784785 # No redirects
785 - $where .= "AND page_is_redirect=0 ";
 786+ $where = "page_namespace={$namespace} AND page_is_redirect=0 ";
786787 # We don't like filesorts, so the query methods here will be very different
787788 if( !$showOutdated ) {
788789 $where .= "AND page_ext_reviewed IS NULL";
@@ -794,7 +795,6 @@
795796 $sql = "SELECT page_namespace AS ns,page_title AS title,page_len,page_ext_stable
796797 FROM $page FORCE INDEX(ext_namespace_reviewed)
797798 RIGHT JOIN $categorylinks ON(cl_from = page_id AND cl_to = '{$category}')";
798 - #$where .= " AND cl_from IS NOT NULL ";
799799 } else {
800800 $sql = "SELECT page_namespace AS ns,page_title AS title,page_len,page_ext_stable
801801 FROM $page FORCE INDEX(ext_namespace_reviewed)";

Status & tagging log