r24607 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24606‎ | r24607 | r24608 >
Date:03:29, 6 August 2007
Author:robchurch
Status:old
Tags:
Comment:
* (bug 10793) Show patrol links on all eligible diff pages
* Introduce RecentChange::newFromConds() to support the above, and a new index
* Refactored some bits
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DifferenceEngine.php (modified) (history)
  • /trunk/phase3/includes/RecentChange.php (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-rc_patrol_index.sql (added) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

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
16 + native
Index: trunk/phase3/maintenance/updaters.inc
@@ -848,32 +848,28 @@
849849 echo "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n";
850850 }
851851
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]
854855 function do_rc_indices_update() {
855856 global $wgDatabase;
856857 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 - }
867858
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+ }
878874 }
879875 }
880876
Index: trunk/phase3/maintenance/tables.sql
@@ -880,6 +880,7 @@
881881 INDEX rc_ip (rc_ip),
882882 INDEX rc_ns_usertext (rc_namespace, rc_user_text),
883883 INDEX rc_user_text (rc_user_text, rc_timestamp)
 884+ INDEX `rc_patrolling` ( `rc_this_oldid`, `rc_last_oldid`, `rc_patrolled` )
884885
885886 ) /*$wgDBTableOptions*/;
886887
Index: trunk/phase3/includes/RecentChange.php
@@ -80,6 +80,31 @@
8181 return NULL;
8282 }
8383 }
 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+ }
84109
85110 # Accessors
86111
@@ -210,19 +235,25 @@
211236 wfRunHooks( 'RecentChange_save', array( &$this ) );
212237 }
213238
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;
219248 $dbw = wfGetDB( DB_MASTER );
220 -
221 - $dbw->update( 'recentchanges',
222 - array( /* SET */
 249+ $dbw->update(
 250+ 'recentchanges',
 251+ array(
223252 'rc_patrolled' => 1
224 - ), array( /* WHERE */
225 - 'rc_id' => $rcid
226 - ), $fname
 253+ ),
 254+ array(
 255+ 'rc_id' => $change
 256+ ),
 257+ __METHOD__
227258 );
228259 }
229260
Index: trunk/phase3/includes/DifferenceEngine.php
@@ -156,8 +156,39 @@
157157 } else {
158158 $rollback = '';
159159 }
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+ }
162193 } else {
163194 $patrol = '';
164195 }
Index: trunk/phase3/RELEASE-NOTES
@@ -164,6 +164,8 @@
165165 * Improved handling of permissions errors
166166 * (bug 10798) Exclude MediaWiki namespace from filtering options on
167167 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
168170
169171 == Bugfixes since 1.10 ==
170172

Follow-up revisions

RevisionCommit summaryAuthorDate
r24632Merged revisions 24601-24631 via svnmerge from...david18:44, 6 August 2007
r24969Static code analysis housekeeping time... things that could be double-checked...nickj03:57, 21 August 2007
r25016Merged revisions 24866-25015 via svnmerge from...david23:06, 21 August 2007

Status & tagging log