X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialRecentchangeslinked.php;h=fee336e435e95f8548b3d88ac66e2910a56bf7f0;hp=873285b8c763a77f4703acda21d3b24fc03a9994;hb=24ebca2251f94a20acee53e583d65aa7fac2c15d;hpb=55043101b2a89ea1e811b6d35e415f57ed0bf41d diff --git a/includes/specials/SpecialRecentchangeslinked.php b/includes/specials/SpecialRecentchangeslinked.php index 873285b8c7..fee336e435 100644 --- a/includes/specials/SpecialRecentchangeslinked.php +++ b/includes/specials/SpecialRecentchangeslinked.php @@ -50,8 +50,8 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { * @inheritdoc */ protected function doMainQuery( $tables, $select, $conds, $query_options, - $join_conds, FormOptions $opts ) { - + $join_conds, FormOptions $opts + ) { $target = $opts['target']; $showlinkedto = $opts['showlinkedto']; $limit = $opts['limit']; @@ -103,15 +103,33 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ]; $select[] = 'page_latest'; } + + $tagFilter = $opts['tagfilter'] ? explode( '|', $opts['tagfilter'] ) : []; ChangeTags::modifyDisplayQuery( $tables, $select, $conds, $join_conds, $query_options, - $opts['tagfilter'] + $tagFilter ); + if ( $dbr->unionSupportsOrderAndLimit() ) { + if ( count( $tagFilter ) > 1 ) { + // ChangeTags::modifyDisplayQuery() will have added DISTINCT. + // To prevent this from causing query performance problems, we need to add + // a GROUP BY, and add rc_id to the ORDER BY. + $order = [ + 'GROUP BY' => 'rc_timestamp, rc_id', + 'ORDER BY' => 'rc_timestamp DESC, rc_id DESC' + ]; + } else { + $order = [ 'ORDER BY' => 'rc_timestamp DESC' ]; + } + } else { + $order = []; + } + if ( !$this->runMainQueryHook( $tables, $select, $conds, $query_options, $join_conds, $opts ) ) { @@ -181,12 +199,6 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { } } - if ( $dbr->unionSupportsOrderAndLimit() ) { - $order = [ 'ORDER BY' => 'rc_timestamp DESC' ]; - } else { - $order = []; - } - $query = $dbr->selectSQLText( array_merge( $tables, [ $link_table ] ), $select,