r65013 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65012‎ | r65013 | r65014 >
Date:09:03, 14 April 2010
Author:btongminh
Status:ok (Comments)
Tags:
Comment:
Special:Listfiles now supports a username parameter. This is indexed using the img_user_text_timestamp index.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialListfiles.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialListfiles.php
@@ -7,10 +7,10 @@
88 /**
99 *
1010 */
11 -function wfSpecialListfiles() {
 11+function wfSpecialListfiles( $par = null ) {
1212 global $wgOut;
1313
14 - $pager = new ImageListPager;
 14+ $pager = new ImageListPager( $par );
1515
1616 $limit = $pager->getForm();
1717 $body = $pager->getBody();
@@ -24,21 +24,30 @@
2525 class ImageListPager extends TablePager {
2626 var $mFieldNames = null;
2727 var $mQueryConds = array();
28 -
29 - function __construct() {
 28+
 29+ function __construct( $par = null ) {
3030 global $wgRequest, $wgMiserMode;
3131 if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) {
3232 $this->mDefaultDirection = true;
3333 } else {
3434 $this->mDefaultDirection = false;
3535 }
 36+
 37+ $userName = $wgRequest->getText( 'username', $par );
 38+ if ( $userName ) {
 39+ $nt = Title::newFromText( $userName, NS_USER );
 40+ if ( !is_null( $nt ) ) {
 41+ $this->mQueryConds['img_user_text'] = $nt->getText();
 42+ }
 43+ }
 44+
3645 $search = $wgRequest->getText( 'ilsearch' );
3746 if ( $search != '' && !$wgMiserMode ) {
3847 $nt = Title::newFromURL( $search );
3948 if( $nt ) {
4049 $dbr = wfGetDB( DB_SLAVE );
41 - $this->mQueryConds = array( 'LOWER(img_name)' . $dbr->buildLike( $dbr->anyString(),
42 - strtolower( $nt->getDBkey() ), $dbr->anyString() ) );
 50+ $this->mQueryConds[] = 'LOWER(img_name)' . $dbr->buildLike( $dbr->anyString(),
 51+ strtolower( $nt->getDBkey() ), $dbr->anyString() );
4352 }
4453 }
4554
@@ -63,7 +72,11 @@
6473 }
6574
6675 function isFieldSortable( $field ) {
67 - static $sortable = array( 'img_timestamp', 'img_name', 'img_size' );
 76+ static $sortable = array( 'img_timestamp', 'img_name' );
 77+ if ( $field == 'img_size' ) {
 78+ # No index for both img_size and img_user_text
 79+ return !isset( $this->mQueryConds['img_user_text'] );
 80+ }
6881 return in_array( $field, $sortable );
6982 }
7083
Index: trunk/phase3/RELEASE-NOTES
@@ -45,6 +45,7 @@
4646 viewing contributions of a blocked IP address
4747 * (bug 22474) {{urlencode:}} now takes an optional second paramter for type of
4848 escaping.
 49+* Special:Listfiles now supports a username parameter
4950
5051 === Bug fixes in 1.17 ===
5152 * (bug 17560) Half-broken deletion moved image files to deletion archive

Follow-up revisions

RevisionCommit summaryAuthorDate
r65035Follow-up to r65013: Preserve username when clicking navigation links.btongminh16:15, 14 April 2010
r68096Follow-up r65013: Add an input field for the username. Use the nice Xml::buil...raymond18:16, 15 June 2010
r84118(follow-up r65035/r65013) The username parameter wasn't preserved when clicki...bawolff18:23, 16 March 2011

Comments

#Comment by Raymond (talk | contribs)   15:39, 14 April 2010

Username is lost when clicking on "next page".

Not a fixme but worth to do: Add an input field for the username to the "File list" fieldset.

#Comment by Bryan (talk | contribs)   16:15, 14 April 2010

Navigation fixed in r65035.

Status & tagging log