Index: trunk/phase3/includes/revisiondelete/RevisionDelete.php |
— | — | @@ -34,8 +34,9 @@ |
35 | 35 | ), |
36 | 36 | __METHOD__, |
37 | 37 | 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() ) |
40 | 41 | ); |
41 | 42 | |
42 | 43 | if ( $live->numRows() >= count( $ids ) ) { |
Index: trunk/phase3/includes/actions/HistoryAction.php |
— | — | @@ -351,7 +351,7 @@ |
352 | 352 | $this->conds ), |
353 | 353 | 'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ), |
354 | 354 | 'join_conds' => array( |
355 | | - 'user' => array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' ), |
| 355 | + 'user' => Revision::userJoinCond(), |
356 | 356 | 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ), |
357 | 357 | ); |
358 | 358 | ChangeTags::modifyDisplayQuery( |
Index: trunk/phase3/includes/Revision.php |
— | — | @@ -294,12 +294,29 @@ |
295 | 295 | $conditions, |
296 | 296 | __METHOD__, |
297 | 297 | 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() ) |
300 | 299 | ); |
301 | 300 | } |
302 | 301 | |
303 | 302 | /** |
| 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 | + /** |
304 | 321 | * Return the list of revision fields that should be selected to create |
305 | 322 | * a new revision. |
306 | 323 | */ |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -1529,10 +1529,6 @@ |
1530 | 1530 | */ |
1531 | 1531 | public function estimateRevisionCount() { |
1532 | 1532 | $dbr = wfGetDB( DB_SLAVE ); |
1533 | | - |
1534 | | - // For an exact count... |
1535 | | - // return $dbr->selectField( 'revision', 'COUNT(*)', |
1536 | | - // array( 'rev_page' => $this->getId() ), __METHOD__ ); |
1537 | 1533 | return $dbr->estimateRowCount( 'revision', '*', |
1538 | 1534 | array( 'rev_page' => $this->getId() ), __METHOD__ ); |
1539 | 1535 | } |
Index: trunk/phase3/includes/specials/SpecialContributions.php |
— | — | @@ -476,9 +476,9 @@ |
477 | 477 | } |
478 | 478 | |
479 | 479 | # Don't include orphaned revisions |
480 | | - $join_cond['page'] = array( 'INNER JOIN', 'page_id = rev_page' ); |
| 480 | + $join_cond['page'] = Revision::pageJoinCond(); |
481 | 481 | # 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(); |
483 | 483 | |
484 | 484 | $queryInfo = array( |
485 | 485 | 'tables' => $tables, |
Index: trunk/phase3/includes/specials/SpecialMergeHistory.php |
— | — | @@ -483,8 +483,8 @@ |
484 | 484 | 'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ), |
485 | 485 | 'conds' => $conds, |
486 | 486 | '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() ) |
489 | 489 | ); |
490 | 490 | } |
491 | 491 | |
Index: trunk/phase3/includes/RevisionList.php |
— | — | @@ -260,8 +260,9 @@ |
261 | 261 | $conds, |
262 | 262 | __METHOD__, |
263 | 263 | 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() ) |
266 | 267 | ); |
267 | 268 | } |
268 | 269 | |