* Handles selecting tags, and filtering.
* Needs $tables to be set up properly, so we can figure out which join conditions to use.
*/
- static function modifyDisplayQuery( &$tables, &$fields, &$conds, &$join_conds, $filter_tag = false ) {
- global $wgRequest;
+ static function modifyDisplayQuery( &$tables, &$fields, &$conds,
+ &$join_conds, &$options, $filter_tag = false ) {
+ global $wgRequest, $wgUseTagFilter;
if ($filter_tag === false) {
$filter_tag = $wgRequest->getVal( 'tagfilter' );
$join_conds['tag_summary'] = array( 'LEFT JOIN', "ts_$join_cond=$join_cond" );
$fields[] = 'ts_tags';
- if ($filter_tag) {
+ if ($wgUseTagFilter && $filter_tag) {
// Somebody wants to filter on a tag.
// Add an INNER JOIN on change_tag
+ // FORCE INDEX -- change_tags will almost ALWAYS be the correct query plan.
+ $options['USE INDEX'] = array( 'change_tag' => 'change_tag_tag_id' );
+ unset( $options['FORCE INDEX'] );
$tables[] = 'change_tag';
$join_conds['change_tag'] = array( 'INNER JOIN', "ct_$join_cond=$join_cond" );
$conds['ct_tag'] = $filter_tag;
* If $fullForm is true, it returns an entire form.
*/
static function buildTagFilterSelector( $selected='', $fullForm = false /* used to put a full form around the selector */ ) {
+ global $wgUseTagFilter;
+
+ if ( !$wgUseTagFilter || !count( self::listDefinedTags() ) )
+ return $fullForm ? '' : array();
+
global $wgTitle;
$data = array( wfMsgExt( 'tag-filter', 'parseinline' ), Xml::input( 'tagfilter', 20, $selected ) );
/** Basically lists defined tags which count even if they aren't applied to anything */
static function listDefinedTags() {
+ // Caching...
+ global $wgMemc;
+ $key = wfMemcKey( 'valid-tags' );
+
+ if ($tags = $wgMemc->get( $key ))
+ return $tags;
+
$emptyTags = array();
// Some DB stuff
wfRunHooks( 'ListDefinedTags', array(&$emptyTags) );
- return array_filter( array_unique( $emptyTags ) );
+ $emptyTags = array_filter( array_unique( $emptyTags ) );
+
+ // Short-term caching.
+ $wgMemc->set( $key, $emptyTags, 300 );
+ return $emptyTags;
}
-}
\ No newline at end of file
+}