* Improved handling of permissions errors
* (bug 10798) Exclude MediaWiki namespace from filtering options on
Special:Protectedpages (implicit protection, doesn't make sense to have it)
+* (bug 10793) "Mark patrolled" links will now be shown for users with
+ patrol permissions on all eligible diff pages
== Bugfixes since 1.10 ==
} else {
$rollback = '';
}
- if( $wgUseRCPatrol && $this->mRcidMarkPatrolled != 0 && $wgUser->isAllowed( 'patrol' ) ) {
- $patrol = ' [' . $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'markaspatrolleddiff' ), "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}" ) . ']';
+
+ // Prepare a change patrol link, if applicable
+ if( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) ) {
+ // If we've been given an explicit change identifier, use it; saves time
+ if( $this->mRcidMarkPatrolled ) {
+ $rcid = $this->mRcidMarkPatrolled;
+ } else {
+ // Look for an unpatrolled change corresponding to this diff
+ $change = RecentChange::newFromConds(
+ array(
+ 'rc_this_oldid' => $this->mNewid,
+ 'rc_last_oldid' => $this->mOldid,
+ 'rc_patrolled' => 0,
+ ),
+ __METHOD__
+ );
+ if( $change instanceof RecentChange ) {
+ $rcid = $change->mAttribs['rc_id'];
+ } else {
+ // None found
+ $rcid = 0;
+ }
+ }
+ // Build the link
+ if( $rcid ) {
+ $patrol = ' [' . $sk->makeKnownLinkObj(
+ $this->mTitle,
+ wfMsgHtml( 'markaspatrolleddiff' ),
+ "action=markpatrolled&rcid={$rcid}"
+ ) . ']';
+ } else {
+ $patrol = '';
+ }
} else {
$patrol = '';
}
return NULL;
}
}
+
+ /**
+ * Find the first recent change matching some specific conditions
+ *
+ * @param array $conds Array of conditions
+ * @param mixed $fname Override the method name in profiling/logs
+ * @return RecentChange
+ */
+ public static function newFromConds( $conds, $fname = false ) {
+ if( $fname === false )
+ $fname = __METHOD__;
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select(
+ 'recentchanges',
+ '*',
+ $conds,
+ $fname
+ );
+ if( $res instanceof ResultWrapper && $res->numRows() > 0 ) {
+ $row = $res->fetchObject();
+ $res->free();
+ return self::newFromRow( $row );
+ }
+ return null;
+ }
# Accessors
wfRunHooks( 'RecentChange_save', array( &$this ) );
}
- # Marks a certain row as patrolled
- function markPatrolled( $rcid )
- {
- $fname = 'RecentChange::markPatrolled';
-
+ /**
+ * Mark a given change as patrolled
+ *
+ * @param mixed $change RecentChange or corresponding rc_id
+ */
+ public static function markPatrolled( $change ) {
+ $rcid = $change instanceof RecentChange
+ ? $change->mAttribs['rc_id']
+ : $change;
$dbw = wfGetDB( DB_MASTER );
-
- $dbw->update( 'recentchanges',
- array( /* SET */
+ $dbw->update(
+ 'recentchanges',
+ array(
'rc_patrolled' => 1
- ), array( /* WHERE */
- 'rc_id' => $rcid
- ), $fname
+ ),
+ array(
+ 'rc_id' => $change
+ ),
+ __METHOD__
);
}
--- /dev/null
+-- Index to speed up locating unpatrolled changes
+-- matching specific edit criteria
+ALTER TABLE /*$wgDBprefix*/recentchanges
+ ADD INDEX `rc_patrolling` ( `rc_this_oldid` , `rc_last_oldid` , `rc_patrolled` );
\ No newline at end of file
INDEX rc_ip (rc_ip),
INDEX rc_ns_usertext (rc_namespace, rc_user_text),
INDEX rc_user_text (rc_user_text, rc_timestamp)
+ INDEX `rc_patrolling` ( `rc_this_oldid`, `rc_last_oldid`, `rc_patrolled` )
) /*$wgDBTableOptions*/;
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]
+// Add index on ( rc_namespace, rc_user_text ) [Jul. 2006]
+// Add index on ( rc_user_text, rc_timestamp ) [Nov. 2006]
+// Add index on ( rc_this_oldid, rc_last_oldid, rc_patrolled ) [Aug. 2007]
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( "...index on ( rc_namespace, rc_user_text ) seems to be ok\n" );
- }
- #Add (rc_user_text, rc_timestamp) index [A. Garrett], November 2006
- # See if we can find the index we want
- $info = $wgDatabase->indexInfo( 'recentchanges', 'rc_user_text', __METHOD__ );
- if( !$info ) {
- # None, so create
- echo( "...index on ( rc_user_text, rc_timestamp ) not found; creating\n" );
- dbsource( archive( 'patch-rc_user_text-index.sql' ) );
- } else {
- # Index seems to exist
- echo( "...index on ( rc_user_text, rc_timestamp ) seems to be ok\n" );
+ $indexes = array(
+ 'rc_ns_usertext' => 'patch-recentchanges-utindex.sql',
+ 'rc_user_text' => 'patch-rc_user_text-index.sql',
+ 'rc_patrolling' => 'patch-rc_patrol_index.sql',
+ );
+
+ foreach( $indexes as $index => $patch ) {
+ $info = $wgDatabase->indexInfo( 'recentchanges', $index, __METHOD__ );
+ if( !$info ) {
+ echo( "...index `{$index}` not found; adding..." );
+ dbsource( archive( $patch ) );
+ echo( "done.\n" );
+ } else {
+ echo( "...index `{$index}` seems ok.\n" );
+ }
}
}