r101030 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101029‎ | r101030 | r101031 >
Date:19:55, 27 October 2011
Author:aaron
Status:resolved (Comments)
Tags:
Comment:
* Added pageJoinCond() and userJoinCond() to Revision and exposed them publicly
* Removed commented-out code
Modified paths:
  • /trunk/phase3/includes/Revision.php (modified) (history)
  • /trunk/phase3/includes/RevisionList.php (modified) (history)
  • /trunk/phase3/includes/WikiPage.php (modified) (history)
  • /trunk/phase3/includes/actions/HistoryAction.php (modified) (history)
  • /trunk/phase3/includes/revisiondelete/RevisionDelete.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMergeHistory.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/revisiondelete/RevisionDelete.php
@@ -34,8 +34,9 @@
3535 ),
3636 __METHOD__,
3737 array( 'ORDER BY' => 'rev_id DESC' ),
38 - array( 'page' => array( 'INNER JOIN', 'rev_page = page_id' ),
39 - 'user' => array( 'LEFT JOIN', 'user_id = rev_user' ) )
 38+ array(
 39+ 'page' => Revision::pageJoinCond(),
 40+ 'user' => Revision::userJoinCond() )
4041 );
4142
4243 if ( $live->numRows() >= count( $ids ) ) {
Index: trunk/phase3/includes/actions/HistoryAction.php
@@ -351,7 +351,7 @@
352352 $this->conds ),
353353 'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ),
354354 'join_conds' => array(
355 - 'user' => array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' ),
 355+ 'user' => Revision::userJoinCond(),
356356 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
357357 );
358358 ChangeTags::modifyDisplayQuery(
Index: trunk/phase3/includes/Revision.php
@@ -294,12 +294,29 @@
295295 $conditions,
296296 __METHOD__,
297297 array( 'LIMIT' => 1 ),
298 - array( 'page' => array( 'INNER JOIN', 'page_id = rev_page' ),
299 - 'user' => array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' ) )
 298+ array( 'page' => self::pageJoinCond(), 'user' => self::userJoinCond() )
300299 );
301300 }
302301
303302 /**
 303+ * Return the value of a select() JOIN conds array for the user table.
 304+ * This will get user table rows for logged-in users.
 305+ * @return Array
 306+ */
 307+ public static function userJoinCond() {
 308+ return array( 'LEFT JOIN', array( 'rev_user != 0', 'user_id = rev_user' ) );
 309+ }
 310+
 311+ /**
 312+ * Return the value of a select() page conds array for the paeg table.
 313+ * This will assure that the revision(s) are not orphaned from live pages.
 314+ * @return Array
 315+ */
 316+ public static function pageJoinCond() {
 317+ return array( 'INNER JOIN', array( 'page_id = rev_page' ) );
 318+ }
 319+
 320+ /**
304321 * Return the list of revision fields that should be selected to create
305322 * a new revision.
306323 */
Index: trunk/phase3/includes/WikiPage.php
@@ -1529,10 +1529,6 @@
15301530 */
15311531 public function estimateRevisionCount() {
15321532 $dbr = wfGetDB( DB_SLAVE );
1533 -
1534 - // For an exact count...
1535 - // return $dbr->selectField( 'revision', 'COUNT(*)',
1536 - // array( 'rev_page' => $this->getId() ), __METHOD__ );
15371533 return $dbr->estimateRowCount( 'revision', '*',
15381534 array( 'rev_page' => $this->getId() ), __METHOD__ );
15391535 }
Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -476,9 +476,9 @@
477477 }
478478
479479 # Don't include orphaned revisions
480 - $join_cond['page'] = array( 'INNER JOIN', 'page_id = rev_page' );
 480+ $join_cond['page'] = Revision::pageJoinCond();
481481 # Get the current user name for accounts
482 - $join_cond['user'] = array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' );
 482+ $join_cond['user'] = Revision::userJoinCond();
483483
484484 $queryInfo = array(
485485 'tables' => $tables,
Index: trunk/phase3/includes/specials/SpecialMergeHistory.php
@@ -483,8 +483,8 @@
484484 'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
485485 'conds' => $conds,
486486 'join_conds' => array(
487 - 'page' => array( 'INNER JOIN', 'rev_page = page_id' ),
488 - 'user' => array( 'LEFT JOIN', 'user_id = rev_user' ) )
 487+ 'page' => Revision::pageJoinCond(),
 488+ 'user' => Revision::userJoinCond() )
489489 );
490490 }
491491
Index: trunk/phase3/includes/RevisionList.php
@@ -260,8 +260,9 @@
261261 $conds,
262262 __METHOD__,
263263 array( 'ORDER BY' => 'rev_id DESC' ),
264 - array( 'page' => array( 'INNER JOIN', 'rev_page = page_id' ),
265 - 'user' => array( 'LEFT JOIN', 'user_id = rev_user' ) )
 264+ array(
 265+ 'page' => Revision::pageJoinCond(),
 266+ 'user' => Revision::userJoinCond() )
266267 );
267268 }
268269

Follow-up revisions

RevisionCommit summaryAuthorDate
r108855@since, ping r101030nikerabbit21:50, 13 January 2012

Comments

#Comment by Nikerabbit (talk | contribs)   06:42, 28 October 2011

Looks good. Can you also add @since annotations to the new methods?

#Comment by Hashar (talk | contribs)   15:22, 3 January 2012

Revision::userJoinCond() add the additional 'rev_user != 0' condition

includes/revisiondelete/RevisionDelete.php includes/specials/SpecialMergeHistory.php includes/RevisionList.php

#Comment by Hashar (talk | contribs)   21:58, 13 January 2012

back to "new". Aaron can you look at my comment just above?

#Comment by Nikerabbit (talk | contribs)   22:01, 13 January 2012

I think it's followup to comments in r100286.

#Comment by Aaron Schulz (talk | contribs)   22:08, 13 January 2012

What's this about?

#Comment by Hashar (talk | contribs)   22:16, 13 January 2012

Clarified on IRC. Thanks Aaron!

Status & tagging log