Index: trunk/phase3/maintenance/archives/patch-rc_patrol_index.sql |
— | — | @@ -0,0 +1,4 @@ |
| 2 | +-- Index to speed up locating unpatrolled changes |
| 3 | +-- matching specific edit criteria |
| 4 | +ALTER TABLE /*$wgDBprefix*/recentchanges |
| 5 | + ADD INDEX `rc_patrolling` ( `rc_this_oldid` , `rc_last_oldid` , `rc_patrolled` ); |
\ No newline at end of file |
Property changes on: trunk/phase3/maintenance/archives/patch-rc_patrol_index.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 6 | + native |
Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -848,32 +848,28 @@ |
849 | 849 | echo "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n"; |
850 | 850 | } |
851 | 851 | |
852 | | -# July 2006 |
853 | | -# Add ( rc_namespace, rc_user_text ) index [R. Church] |
| 852 | +// Add index on ( rc_namespace, rc_user_text ) [Jul. 2006] |
| 853 | +// Add index on ( rc_user_text, rc_timestamp ) [Nov. 2006] |
| 854 | +// Add index on ( rc_this_oldid, rc_last_oldid, rc_patrolled ) [Aug. 2007] |
854 | 855 | function do_rc_indices_update() { |
855 | 856 | global $wgDatabase; |
856 | 857 | echo( "Checking for additional recent changes indices...\n" ); |
857 | | - # See if we can find the index we want |
858 | | - $info = $wgDatabase->indexInfo( 'recentchanges', 'rc_ns_usertext', __METHOD__ ); |
859 | | - if( !$info ) { |
860 | | - # None, so create |
861 | | - echo( "...index on ( rc_namespace, rc_user_text ) not found; creating\n" ); |
862 | | - dbsource( archive( 'patch-recentchanges-utindex.sql' ) ); |
863 | | - } else { |
864 | | - # Index seems to exist |
865 | | - echo( "...index on ( rc_namespace, rc_user_text ) seems to be ok\n" ); |
866 | | - } |
867 | 858 | |
868 | | - #Add (rc_user_text, rc_timestamp) index [A. Garrett], November 2006 |
869 | | - # See if we can find the index we want |
870 | | - $info = $wgDatabase->indexInfo( 'recentchanges', 'rc_user_text', __METHOD__ ); |
871 | | - if( !$info ) { |
872 | | - # None, so create |
873 | | - echo( "...index on ( rc_user_text, rc_timestamp ) not found; creating\n" ); |
874 | | - dbsource( archive( 'patch-rc_user_text-index.sql' ) ); |
875 | | - } else { |
876 | | - # Index seems to exist |
877 | | - echo( "...index on ( rc_user_text, rc_timestamp ) seems to be ok\n" ); |
| 859 | + $indexes = array( |
| 860 | + 'rc_ns_usertext' => 'patch-recentchanges-utindex.sql', |
| 861 | + 'rc_user_text' => 'patch-rc_user_text-index.sql', |
| 862 | + 'rc_patrolling' => 'patch-rc_patrol_index.sql', |
| 863 | + ); |
| 864 | + |
| 865 | + foreach( $indexes as $index => $patch ) { |
| 866 | + $info = $wgDatabase->indexInfo( 'recentchanges', $index, __METHOD__ ); |
| 867 | + if( !$info ) { |
| 868 | + echo( "...index `{$index}` not found; adding..." ); |
| 869 | + dbsource( archive( $patch ) ); |
| 870 | + echo( "done.\n" ); |
| 871 | + } else { |
| 872 | + echo( "...index `{$index}` seems ok.\n" ); |
| 873 | + } |
878 | 874 | } |
879 | 875 | } |
880 | 876 | |
Index: trunk/phase3/maintenance/tables.sql |
— | — | @@ -880,6 +880,7 @@ |
881 | 881 | INDEX rc_ip (rc_ip), |
882 | 882 | INDEX rc_ns_usertext (rc_namespace, rc_user_text), |
883 | 883 | INDEX rc_user_text (rc_user_text, rc_timestamp) |
| 884 | + INDEX `rc_patrolling` ( `rc_this_oldid`, `rc_last_oldid`, `rc_patrolled` ) |
884 | 885 | |
885 | 886 | ) /*$wgDBTableOptions*/; |
886 | 887 | |
Index: trunk/phase3/includes/RecentChange.php |
— | — | @@ -80,6 +80,31 @@ |
81 | 81 | return NULL; |
82 | 82 | } |
83 | 83 | } |
| 84 | + |
| 85 | + /** |
| 86 | + * Find the first recent change matching some specific conditions |
| 87 | + * |
| 88 | + * @param array $conds Array of conditions |
| 89 | + * @param mixed $fname Override the method name in profiling/logs |
| 90 | + * @return RecentChange |
| 91 | + */ |
| 92 | + public static function newFromConds( $conds, $fname = false ) { |
| 93 | + if( $fname === false ) |
| 94 | + $fname = __METHOD__; |
| 95 | + $dbr = wfGetDB( DB_SLAVE ); |
| 96 | + $res = $dbr->select( |
| 97 | + 'recentchanges', |
| 98 | + '*', |
| 99 | + $conds, |
| 100 | + $fname |
| 101 | + ); |
| 102 | + if( $res instanceof ResultWrapper && $res->numRows() > 0 ) { |
| 103 | + $row = $res->fetchObject(); |
| 104 | + $res->free(); |
| 105 | + return self::newFromRow( $row ); |
| 106 | + } |
| 107 | + return null; |
| 108 | + } |
84 | 109 | |
85 | 110 | # Accessors |
86 | 111 | |
— | — | @@ -210,19 +235,25 @@ |
211 | 236 | wfRunHooks( 'RecentChange_save', array( &$this ) ); |
212 | 237 | } |
213 | 238 | |
214 | | - # Marks a certain row as patrolled |
215 | | - function markPatrolled( $rcid ) |
216 | | - { |
217 | | - $fname = 'RecentChange::markPatrolled'; |
218 | | - |
| 239 | + /** |
| 240 | + * Mark a given change as patrolled |
| 241 | + * |
| 242 | + * @param mixed $change RecentChange or corresponding rc_id |
| 243 | + */ |
| 244 | + public static function markPatrolled( $change ) { |
| 245 | + $rcid = $change instanceof RecentChange |
| 246 | + ? $change->mAttribs['rc_id'] |
| 247 | + : $change; |
219 | 248 | $dbw = wfGetDB( DB_MASTER ); |
220 | | - |
221 | | - $dbw->update( 'recentchanges', |
222 | | - array( /* SET */ |
| 249 | + $dbw->update( |
| 250 | + 'recentchanges', |
| 251 | + array( |
223 | 252 | 'rc_patrolled' => 1 |
224 | | - ), array( /* WHERE */ |
225 | | - 'rc_id' => $rcid |
226 | | - ), $fname |
| 253 | + ), |
| 254 | + array( |
| 255 | + 'rc_id' => $change |
| 256 | + ), |
| 257 | + __METHOD__ |
227 | 258 | ); |
228 | 259 | } |
229 | 260 | |
Index: trunk/phase3/includes/DifferenceEngine.php |
— | — | @@ -156,8 +156,39 @@ |
157 | 157 | } else { |
158 | 158 | $rollback = ''; |
159 | 159 | } |
160 | | - if( $wgUseRCPatrol && $this->mRcidMarkPatrolled != 0 && $wgUser->isAllowed( 'patrol' ) ) { |
161 | | - $patrol = ' [' . $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'markaspatrolleddiff' ), "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}" ) . ']'; |
| 160 | + |
| 161 | + // Prepare a change patrol link, if applicable |
| 162 | + if( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) ) { |
| 163 | + // If we've been given an explicit change identifier, use it; saves time |
| 164 | + if( $this->mRcidMarkPatrolled ) { |
| 165 | + $rcid = $this->mRcidMarkPatrolled; |
| 166 | + } else { |
| 167 | + // Look for an unpatrolled change corresponding to this diff |
| 168 | + $change = RecentChange::newFromConds( |
| 169 | + array( |
| 170 | + 'rc_this_oldid' => $this->mNewid, |
| 171 | + 'rc_last_oldid' => $this->mOldid, |
| 172 | + 'rc_patrolled' => 0, |
| 173 | + ), |
| 174 | + __METHOD__ |
| 175 | + ); |
| 176 | + if( $change instanceof RecentChange ) { |
| 177 | + $rcid = $change->mAttribs['rc_id']; |
| 178 | + } else { |
| 179 | + // None found |
| 180 | + $rcid = 0; |
| 181 | + } |
| 182 | + } |
| 183 | + // Build the link |
| 184 | + if( $rcid ) { |
| 185 | + $patrol = ' [' . $sk->makeKnownLinkObj( |
| 186 | + $this->mTitle, |
| 187 | + wfMsgHtml( 'markaspatrolleddiff' ), |
| 188 | + "action=markpatrolled&rcid={$rcid}" |
| 189 | + ) . ']'; |
| 190 | + } else { |
| 191 | + $patrol = ''; |
| 192 | + } |
162 | 193 | } else { |
163 | 194 | $patrol = ''; |
164 | 195 | } |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -164,6 +164,8 @@ |
165 | 165 | * Improved handling of permissions errors |
166 | 166 | * (bug 10798) Exclude MediaWiki namespace from filtering options on |
167 | 167 | Special:Protectedpages (implicit protection, doesn't make sense to have it) |
| 168 | +* (bug 10793) "Mark patrolled" links will now be shown for users with |
| 169 | + patrol permissions on all eligible diff pages |
168 | 170 | |
169 | 171 | == Bugfixes since 1.10 == |
170 | 172 | |