Add RecentChange::selectFields and use it
authorumherirrender <umherirrender_de.wp@web.de>
Thu, 8 Nov 2012 18:25:59 +0000 (19:25 +0100)
committerumherirrender <umherirrender_de.wp@web.de>
Thu, 8 Nov 2012 18:25:59 +0000 (19:25 +0100)
This avoids * in SELECTs

Change-Id: I218c93f23b650e597db1ae2055dc536f2cc195a3

includes/RecentChange.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialRecentchangeslinked.php
includes/specials/SpecialWatchlist.php

index 3cf6c72..2bdcab4 100644 (file)
@@ -125,7 +125,7 @@ class RecentChange {
         */
        public static function newFromConds( $conds, $fname = __METHOD__ ) {
                $dbr = wfGetDB( DB_SLAVE );
-               $row = $dbr->selectRow( 'recentchanges', '*', $conds, $fname );
+               $row = $dbr->selectRow( 'recentchanges', self::selectFields(), $conds, $fname );
                if ( $row !== false ) {
                        return self::newFromRow( $row );
                } else {
@@ -133,6 +133,40 @@ class RecentChange {
                }
        }
 
+       /**
+        * Return the list of recentchanges fields that should be selected to create
+        * a new recentchanges object.
+        * @return array
+        */
+       public static function selectFields() {
+               return array(
+                       'rc_id',
+                       'rc_timestamp',
+                       'rc_cur_time',
+                       'rc_user',
+                       'rc_user_text',
+                       'rc_namespace',
+                       'rc_title',
+                       'rc_comment',
+                       'rc_minor',
+                       'rc_bot',
+                       'rc_new',
+                       'rc_cur_id',
+                       'rc_this_oldid',
+                       'rc_last_oldid',
+                       'rc_type',
+                       'rc_patrolled',
+                       'rc_ip',
+                       'rc_old_len',
+                       'rc_new_len',
+                       'rc_deleted',
+                       'rc_logid',
+                       'rc_log_type',
+                       'rc_log_action',
+                       'rc_params',
+               );
+       }
+
        # Accessors
 
        /**
index 2bd8b0a..f542640 100644 (file)
@@ -382,7 +382,7 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                $invert = $opts['invert'];
                $associated = $opts['associated'];
 
-               $fields = array( $dbr->tableName( 'recentchanges' ) . '.*' ); // all rc columns
+               $fields = RecentChange::selectFields();
                // JOIN on watchlist for users
                if ( $uid ) {
                        $tables[] = 'watchlist';
index 40ebc2f..4db8958 100644 (file)
@@ -93,7 +93,7 @@ class SpecialRecentchangeslinked extends SpecialRecentChanges {
                $dbkey = $title->getDBkey();
 
                $tables = array( 'recentchanges' );
-               $select = array( $dbr->tableName( 'recentchanges' ) . '.*' );
+               $select = RecentChange::selectFields();
                $join_conds = array();
                $query_options = array();
 
index 5dfc113..688e0a5 100644 (file)
@@ -272,7 +272,7 @@ class SpecialWatchlist extends SpecialPage {
                $form .= '<hr />';
 
                $tables = array( 'recentchanges', 'watchlist' );
-               $fields = array( $dbr->tableName( 'recentchanges' ) . '.*' );
+               $fields = RecentChange::selectFields();
                $join_conds = array(
                        'watchlist' => array(
                                'INNER JOIN',