* Added pageJoinCond() and userJoinCond() to Revision and exposed them publicly
authorAaron Schulz <aaron@users.mediawiki.org>
Thu, 27 Oct 2011 19:55:00 +0000 (19:55 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Thu, 27 Oct 2011 19:55:00 +0000 (19:55 +0000)
* Removed commented-out code

includes/Revision.php
includes/RevisionList.php
includes/WikiPage.php
includes/actions/HistoryAction.php
includes/revisiondelete/RevisionDelete.php
includes/specials/SpecialContributions.php
includes/specials/SpecialMergeHistory.php

index f75442c..7136c1b 100644 (file)
@@ -294,11 +294,28 @@ class Revision {
                        $conditions,
                        __METHOD__,
                        array( 'LIMIT' => 1 ),
-                       array( 'page' => array( 'INNER JOIN', 'page_id = rev_page' ),
-                               'user' => array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' ) )
+                       array( 'page' => self::pageJoinCond(), 'user' => self::userJoinCond() )
                );
        }
 
+       /**
+        * Return the value of a select() JOIN conds array for the user table.
+        * This will get user table rows for logged-in users.
+        * @return Array
+        */
+       public static function userJoinCond() {
+               return array( 'LEFT JOIN', array( 'rev_user != 0', 'user_id = rev_user' ) );
+       }
+
+       /**
+        * Return the value of a select() page conds array for the paeg table.
+        * This will assure that the revision(s) are not orphaned from live pages.
+        * @return Array
+        */
+       public static function pageJoinCond() {
+               return array( 'INNER JOIN', array( 'page_id = rev_page' ) );
+       }
+
        /**
         * Return the list of revision fields that should be selected to create
         * a new revision.
index 2781764..5a9bbad 100644 (file)
@@ -260,8 +260,9 @@ class RevisionList extends RevisionListBase {
                        $conds,
                        __METHOD__,
                        array( 'ORDER BY' => 'rev_id DESC' ),
-                       array( 'page' => array( 'INNER JOIN', 'rev_page = page_id' ),
-                               'user' => array( 'LEFT JOIN', 'user_id = rev_user' ) )
+                       array(
+                               'page' => Revision::pageJoinCond(),
+                               'user' => Revision::userJoinCond() )
                );
        }
 
index 4bc7873..8d6d3eb 100644 (file)
@@ -1529,10 +1529,6 @@ class WikiPage extends Page {
         */
        public function estimateRevisionCount() {
                $dbr = wfGetDB( DB_SLAVE );
-
-               // For an exact count...
-               // return $dbr->selectField( 'revision', 'COUNT(*)',
-               //      array( 'rev_page' => $this->getId() ), __METHOD__ );
                return $dbr->estimateRowCount( 'revision', '*',
                        array( 'rev_page' => $this->getId() ), __METHOD__ );
        }
index 3775bf1..f6d48ea 100644 (file)
@@ -351,7 +351,7 @@ class HistoryPager extends ReverseChronologicalPager {
                                $this->conds ),
                        'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ),
                        'join_conds' => array(
-                               'user'        => array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' ),
+                               'user'        => Revision::userJoinCond(),
                                'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
                );
                ChangeTags::modifyDisplayQuery(
index b495552..0a6566b 100644 (file)
@@ -34,8 +34,9 @@ class RevDel_RevisionList extends RevDel_List {
                        ),
                        __METHOD__,
                        array( 'ORDER BY' => 'rev_id DESC' ),
-                       array( 'page' => array( 'INNER JOIN', 'rev_page = page_id' ),
-                               'user' => array( 'LEFT JOIN', 'user_id = rev_user' ) )
+                       array(
+                               'page' => Revision::pageJoinCond(),
+                               'user' => Revision::userJoinCond() )
                );
 
                if ( $live->numRows() >= count( $ids ) ) {
index ee9ae08..df4db79 100644 (file)
@@ -476,9 +476,9 @@ class ContribsPager extends ReverseChronologicalPager {
                }
 
                # Don't include orphaned revisions
-               $join_cond['page'] = array( 'INNER JOIN', 'page_id = rev_page' );
+               $join_cond['page'] = Revision::pageJoinCond();
                # Get the current user name for accounts
-               $join_cond['user'] = array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' );
+               $join_cond['user'] = Revision::userJoinCond();
 
                $queryInfo = array(
                        'tables'     => $tables,
index 27c5495..658680a 100644 (file)
@@ -483,8 +483,8 @@ class MergeHistoryPager extends ReverseChronologicalPager {
                        'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
                        'conds'  => $conds,
                        'join_conds' => array(
-                               'page' => array( 'INNER JOIN', 'rev_page = page_id' ),
-                               'user' => array( 'LEFT JOIN', 'user_id = rev_user' ) )
+                               'page' => Revision::pageJoinCond(),
+                               'user' => Revision::userJoinCond() )
                );
        }