Refactor GROUP BY clause, add extra columns for SQL compatibility, remove debugging...
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Fri, 4 Aug 2006 20:18:43 +0000 (20:18 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Fri, 4 Aug 2006 20:18:43 +0000 (20:18 +0000)
Tested on MySQL with both $uid and !$uid. :)

includes/SpecialRecentchangeslinked.php

index 2a611c4..59a3beb 100644 (file)
@@ -71,6 +71,14 @@ function wfSpecialRecentchangeslinked( $par = NULL ) {
 
        $uid = $wgUser->getID();
 
+       $GROUPBY = "
+       GROUP BY rc_cur_id,rc_namespace,rc_title,
+               rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,
+               rc_new, rc_id, rc_this_oldid, rc_last_oldid, rc_bot, rc_patrolled, rc_type
+" . ($uid ? ",wl_user" : "") . "
+               ORDER BY rc_timestamp DESC
+       LIMIT {$limit}";
+
        // If target is a Category, use categorylinks and invert from and to
        if( $nt->getNamespace() == NS_CATEGORY ) {
                $catkey = $dbr->addQuotes( $nt->getDBKey() );
@@ -97,11 +105,7 @@ function wfSpecialRecentchangeslinked( $par = NULL ) {
             {$cmq}
             AND cl_from=rc_cur_id
             AND cl_to=$catkey
-       GROUP BY rc_cur_id,rc_namespace,rc_title,
-               rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,
-               rc_new
-               ORDER BY rc_timestamp DESC
-       LIMIT {$limit};
+$GROUPBY
  ";
        } else {
                $sql =
@@ -129,11 +133,8 @@ function wfSpecialRecentchangeslinked( $par = NULL ) {
      AND pl_namespace=rc_namespace
      AND pl_title=rc_title
      AND pl_from=$id
-GROUP BY rc_cur_id,rc_namespace,rc_title,
-        rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,
-        rc_new
-ORDER BY rc_timestamp DESC
-   LIMIT {$limit}";
+$GROUPBY
+";
        }
        $res = $dbr->query( $sql, $fname );
 
@@ -156,9 +157,6 @@ ORDER BY rc_timestamp DESC
                if ( 0 == $count ) { break; }
                $obj = $dbr->fetchObject( $res );
                --$count;
-#              print_r ( $obj ) ;
-#              print "<br/>\n" ;
-
                $rc = RecentChange::newFromRow( $obj );
                $rc->counter = $counter++;
                $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user) );