renamed NAMESPACE constant to NAMESPACE_RESTRICTION (and PAGE to PAGE_RESTRICTION...
[lhc/web/wiklou.git] / includes / specials / SpecialRecentchanges.php
index 9aec761..ab3830b 100644 (file)
@@ -177,7 +177,7 @@ class SpecialRecentChanges extends SpecialPage {
        public function checkLastModified( $feedFormat ) {
                global $wgUseRCPatrol, $wgOut;
                $dbr = wfGetDB( DB_SLAVE );
-               $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __FUNCTION__ );
+               $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
                if( $feedFormat || !$wgUseRCPatrol ) {
                        if( $lastmod && $wgOut->checkLastModified( $lastmod ) ) {
                                # Client cache fresh and headers sent, nothing more to do.
@@ -270,6 +270,7 @@ class SpecialRecentChanges extends SpecialPage {
 
                $tables = array( 'recentchanges' );
                $join_conds = array();
+               $query_options = array( 'USE INDEX' => array('recentchanges' => 'rc_timestamp') );
 
                $uid = $wgUser->getId();
                $dbr = wfGetDB( DB_SLAVE );
@@ -287,20 +288,28 @@ class SpecialRecentChanges extends SpecialPage {
                }
                if ($wgUser->isAllowed("rollback")) {
                        $tables[] = 'page';
-                       $join_conds['page'] = array('LEFT JOIN', 'rc_namespace=page_namespace AND rc_title=page_title AND rc_this_oldid=page_latest');
+                       $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
                }
                // Tag stuff.
-               $fields = array(); // Fields are * in this case, so let the function modify an empty array to keep it happy.
-               ChangeTags::modifyDisplayQuery( $tables, $fields, $conds, $join_conds, $opts['tagfilter'] );
+               $fields = array();
+               // Fields are * in this case, so let the function modify an empty array to keep it happy.
+               ChangeTags::modifyDisplayQuery( $tables,
+                                                                               $fields,
+                                                                               $conds,
+                                                                               $join_conds,
+                                                                               $query_options,
+                                                                               $opts['tagfilter']
+                                                                       );
 
                wfRunHooks('SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts ) );
 
                // Is there either one namespace selected or excluded?
+               // Tag filtering also has a better index.
                // Also, if this is "all" or main namespace, just use timestamp index.
-               if( is_null($namespace) || $invert || $namespace == NS_MAIN ) {
+               if( is_null($namespace) || $invert || $opts['tagfilter'] ) {
                        $res = $dbr->select( $tables, '*', $conds, __METHOD__,
-                               array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit,
-                                       'USE INDEX' => array('recentchanges' => 'rc_timestamp') ),
+                               array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) +
+                               $query_options,
                                $join_conds );
                // We have a new_namespace_time index! UNION over new=(0,1) and sort result set!
                } else {
@@ -309,17 +318,18 @@ class SpecialRecentChanges extends SpecialPage {
                                array( 'rc_new' => 1 ) + $conds,
                                __METHOD__,
                                array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit,
-                                       'USE INDEX' =>  array('recentchanges' => 'new_name_timestamp') ),
+                                       'USE INDEX' =>  array('recentchanges' => 'rc_timestamp') ),
                                $join_conds );
                        // Old pages
                        $sqlOld = $dbr->selectSQLText( $tables, '*',
                                array( 'rc_new' => 0 ) + $conds,
                                __METHOD__,
                                array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit,
-                                       'USE INDEX' =>  array('recentchanges' => 'new_name_timestamp') ),
+                                       'USE INDEX' =>  array('recentchanges' => 'rc_timestamp') ),
                                $join_conds );
                        # Join the two fast queries, and sort the result set
-                       $sql = "($sqlNew) UNION ($sqlOld) ORDER BY rc_timestamp DESC LIMIT $limit";
+                       $sql = $dbr->unionQueries(array($sqlNew, $sqlOld), false).' ORDER BY rc_timestamp DESC';
+                       $sql = $dbr->limitResult($sql, $limit, false);
                        $res = $dbr->query( $sql, __METHOD__ );
                }
 
@@ -588,8 +598,12 @@ class SpecialRecentChanges extends SpecialPage {
                global $wgUser;
                $sk = $wgUser->getSkin();
                $params = $override + $options;
-               return $sk->link( $this->getTitle(), htmlspecialchars( $title ),
-                       ( $active ? array( 'style'=>'font-weight: bold;' ) : array() ), $params, array( 'known' ) );
+               if ( $active ) {
+                       return $sk->link( $this->getTitle(), '<strong>' . htmlspecialchars( $title ) . '</strong>',
+                                                         array(), $params, array( 'known' ) );
+               } else {
+                       return $sk->link( $this->getTitle(), htmlspecialchars( $title ), array() , $params, array( 'known' ) );
+               }
        }
 
        /**
@@ -609,7 +623,9 @@ class SpecialRecentChanges extends SpecialPage {
                if( $options['from'] ) {
                        $note .= wfMsgExt( 'rcnotefrom', array( 'parseinline' ),
                                $wgLang->formatNum( $options['limit'] ),
-                               $wgLang->timeanddate( $options['from'], true ) ) . '<br />';
+                               $wgLang->timeanddate( $options['from'], true ),
+                               $wgLang->date( $options['from'], true ),
+                               $wgLang->time( $options['from'], true ) ) . '<br />';
                }
 
                # Sort data for display and make sure it's unique after we've added user data.