(bug 20256) Fixed SQL errors on Special:Recentchanges and Special:Recentchangeslinked...
[lhc/web/wiklou.git] / includes / specials / SpecialRecentchangeslinked.php
index a5bd098..d84ffa3 100644 (file)
@@ -144,19 +144,30 @@ class SpecialRecentchangeslinked extends SpecialRecentchanges {
                                }
                        }
 
-                       $subsql[] = $dbr->selectSQLText( 
+                       if( $dbr->unionSupportsOrderAndLimit())
+                               $order = array( 'ORDER BY' => 'rc_timestamp DESC' );
+                       else
+                               $order = array();
+
+                       
+                       $query = $dbr->selectSQLText( 
                                array_merge( $tables, array( $link_table ) ), 
                                $select, 
                                $conds + $subconds,
                                __METHOD__, 
-                               array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) + $query_options,
+                               $order + $query_options,
                                $join_conds + array( $link_table => array( 'INNER JOIN', $subjoin ) )
                        );
+                       
+                       if( $dbr->unionSupportsOrderAndLimit())
+                               $query = $dbr->limitResult( $query, $limit );
+
+                       $subsql[] = $query;
                }
 
                if( count($subsql) == 0 )
                        return false; // should never happen
-               if( count($subsql) == 1 )
+               if( count($subsql) == 1 && $dbr->unionSupportsOrderAndLimit() )
                        $sql = $subsql[0];
                else {
                        // need to resort and relimit after union