$this->addTables( 'filearchive' );
- $this->addFields( 'fa_name' );
+ $this->addFields( array( 'fa_name', 'fa_deleted' ) );
$this->addFieldsIf( 'fa_storage_key', $fld_sha1 );
$this->addFieldsIf( 'fa_timestamp', $fld_timestamp );
$dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
$from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) );
$this->addWhereRange( 'fa_name', $dir, $from, null );
- if ( isset( $params['prefix'] ) )
+ if ( isset( $params['prefix'] ) ) {
$this->addWhere( 'fa_name' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) );
+ }
+
+ if ( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+ // Filter out revisions that the user is not allowed to see. There
+ // is no way to indicate that we have skipped stuff because the
+ // continuation parameter is fa_name
+
+ // Note that this field is unindexed. This should however not be
+ // a big problem as files with fa_deleted are rare
+ $this->addWhereFld( 'fa_deleted', 0 );
+ }
+
+
$limit = $params['limit'];
$this->addOption( 'LIMIT', $limit + 1 );
$this->addOption( 'ORDER BY', 'fa_name' .
if ( $fld_mime ) {
$file['mime'] = "$row->fa_major_mime/$row->fa_minor_mime";
}
+
+ if ( $row->fa_deleted & File::DELETED_FILE ) {
+ $file['deletedfile'] = '';
+ }
+ if ( $row->fa_deleted & File::DELETED_COMMENT ) {
+ $file['deletedcomment'] = '';
+ }
+ if ( $row->fa_deleted & File::DELETED_USER ) {
+ $file['deleteduser'] = '';
+ }
+ if ( $row->fa_deleted & File::DELETED_RESTRICTED ) {
+ // This file is deleted for normal admins
+ $file['deletedrestricted'] = '';
+ }
+
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $file );
if ( !$fit ) {
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->fa_name ) );