Remove useless left join in watchlist
authorAryeh Gregor <simetrical@users.mediawiki.org>
Wed, 28 Jan 2009 15:14:38 +0000 (15:14 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Wed, 28 Jan 2009 15:14:38 +0000 (15:14 +0000)
By request of Domas.  Extensions that were relying on the left join to
page being present must add it if it's not; LQT was the only one I found
in trunk, and I updated it so it should still work.

includes/specials/SpecialWatchlist.php

index 6e7fb6e..4313f87 100644 (file)
@@ -159,10 +159,12 @@ function wfSpecialWatchlist( $par ) {
        if( $wgUser->getOption( 'extendwatchlist' )) {
                $andLatest='';
                $limitWatchlist = intval( $wgUser->getOption( 'wllimit' ) );
+               $usePage = false;
        } else {
        # Top log Ids for a page are not stored
                $andLatest = 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG;
                $limitWatchlist = 0;
+               $usePage = true;
        }
 
        # Show a message about slave lag, if applicable
@@ -189,12 +191,11 @@ function wfSpecialWatchlist( $par ) {
        }
        $form .= '<hr />';
        
-       $tables = array( 'recentchanges', 'watchlist', 'page' );
+       $tables = array( 'recentchanges', 'watchlist' );
        $fields = array( "{$recentchanges}.*" );
        $conds = array();
        $join_conds = array(
                'watchlist' => array('INNER JOIN',"wl_user='{$uid}' AND wl_namespace=rc_namespace AND wl_title=rc_title"),
-               'page'      => array('LEFT JOIN','rc_cur_id=page_id')
        );
        $options = array( 'ORDER BY' => 'rc_timestamp DESC' );
        if( $wgShowUpdatedMarker ) {
@@ -212,6 +213,11 @@ function wfSpecialWatchlist( $par ) {
        if( $andHideAnons ) $conds[] = $andHideAnons;
        if( $andHidePatrolled ) $conds[] = $andHidePatrolled;
        if( $nameSpaceClause ) $conds[] = $nameSpaceClause;
+
+       if ( $usePage ) {
+               $tables[] = 'page';
+               $join_conds['page'] = array('LEFT JOIN','rc_cur_id=page_id');
+       }
        
        wfRunHooks('SpecialWatchlistQuery', array(&$conds,&$tables,&$join_conds,&$fields) );