From 7f3dfecc2ec771f13f33399ad21f0123edb968bf Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Wed, 14 Apr 2010 09:03:28 +0000 Subject: [PATCH] Special:Listfiles now supports a username parameter. This is indexed using the img_user_text_timestamp index. --- RELEASE-NOTES | 1 + includes/specials/SpecialListfiles.php | 27 +++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 253babfa67..d6cc0ba286 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -45,6 +45,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN viewing contributions of a blocked IP address * (bug 22474) {{urlencode:}} now takes an optional second paramter for type of escaping. +* Special:Listfiles now supports a username parameter === Bug fixes in 1.17 === * (bug 17560) Half-broken deletion moved image files to deletion archive diff --git a/includes/specials/SpecialListfiles.php b/includes/specials/SpecialListfiles.php index 024f6f9ad8..227adaa37e 100644 --- a/includes/specials/SpecialListfiles.php +++ b/includes/specials/SpecialListfiles.php @@ -7,10 +7,10 @@ /** * */ -function wfSpecialListfiles() { +function wfSpecialListfiles( $par = null ) { global $wgOut; - $pager = new ImageListPager; + $pager = new ImageListPager( $par ); $limit = $pager->getForm(); $body = $pager->getBody(); @@ -24,21 +24,30 @@ function wfSpecialListfiles() { class ImageListPager extends TablePager { var $mFieldNames = null; var $mQueryConds = array(); - - function __construct() { + + function __construct( $par = null ) { global $wgRequest, $wgMiserMode; if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) { $this->mDefaultDirection = true; } else { $this->mDefaultDirection = false; } + + $userName = $wgRequest->getText( 'username', $par ); + if ( $userName ) { + $nt = Title::newFromText( $userName, NS_USER ); + if ( !is_null( $nt ) ) { + $this->mQueryConds['img_user_text'] = $nt->getText(); + } + } + $search = $wgRequest->getText( 'ilsearch' ); if ( $search != '' && !$wgMiserMode ) { $nt = Title::newFromURL( $search ); if( $nt ) { $dbr = wfGetDB( DB_SLAVE ); - $this->mQueryConds = array( 'LOWER(img_name)' . $dbr->buildLike( $dbr->anyString(), - strtolower( $nt->getDBkey() ), $dbr->anyString() ) ); + $this->mQueryConds[] = 'LOWER(img_name)' . $dbr->buildLike( $dbr->anyString(), + strtolower( $nt->getDBkey() ), $dbr->anyString() ); } } @@ -63,7 +72,11 @@ class ImageListPager extends TablePager { } function isFieldSortable( $field ) { - static $sortable = array( 'img_timestamp', 'img_name', 'img_size' ); + static $sortable = array( 'img_timestamp', 'img_name' ); + if ( $field == 'img_size' ) { + # No index for both img_size and img_user_text + return !isset( $this->mQueryConds['img_user_text'] ); + } return in_array( $field, $sortable ); } -- 2.20.1