jenkins-bot has submitted this change and it was merged. Change subject: Use array_merge instead of the plus operator so that hooked functions are able to override the ORDER BY condition ......................................................................
Use array_merge instead of the plus operator so that hooked functions are able to override the ORDER BY condition This is needed to implement wikiHow's "reverse order" option cleanly, without any core hacks. Without this changeset, you can hook into ChangesListSpecialPageQuery hook, but it will be impossible to override the ORDER BY conditions to get rid of the DESC sort order when the reverse param is set to 1 in the URL. For a live example of the feature in question, see http://www.wikihow.com/Special:RecentChanges (tick the "reverse order" box, press button and take a look at the results). For the code behind this feature, see /extensions/wikihow/hooks/SpecialPagesHooks.php and /extensions/wikihow/hooks/WikihowHooks.php on the wikiHow codebase. Change-Id: I2177aed9e4807b90cbde4baf33083da492d3d194 --- M includes/specials/SpecialRecentchanges.php 1 file changed, 10 insertions(+), 3 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 1387988..7dc1158 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -233,14 +233,21 @@ return false; } - // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough - // knowledge to use an index merge if it wants (it may use some other index though). + // array_merge() is used intentionally here so that hooks can, should + // they so desire, override the ORDER BY / LIMIT condition(s); prior to + // MediaWiki 1.26 this used to use the plus operator instead, which meant + // that extensions weren't able to change these conditions + $query_options = array_merge( array( + 'ORDER BY' => 'rc_timestamp DESC', + 'LIMIT' => $opts['limit'] ), $query_options ); $rows = $dbr->select( $tables, $fields, + // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough + // knowledge to use an index merge if it wants (it may use some other index though). $conds + array( 'rc_new' => array( 0, 1 ) ), __METHOD__, - array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $opts['limit'] ) + $query_options, + $query_options, $join_conds ); -- To view, visit https://gerrit.wikimedia.org/r/206728 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2177aed9e4807b90cbde4baf33083da492d3d194 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jack Phoenix <j...@countervandalism.net> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits