Index: trunk/phase3/includes/api/ApiQueryFilearchive.php |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | |
68 | 68 | $this->addTables( 'filearchive' ); |
69 | 69 | |
70 | | - $this->addFields( 'fa_name' ); |
| 70 | + $this->addFields( array( 'fa_name', 'fa_deleted' ) ); |
71 | 71 | $this->addFieldsIf( 'fa_storage_key', $fld_sha1 ); |
72 | 72 | $this->addFieldsIf( 'fa_timestamp', $fld_timestamp ); |
73 | 73 | |
— | — | @@ -92,9 +92,22 @@ |
93 | 93 | $dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' ); |
94 | 94 | $from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) ); |
95 | 95 | $this->addWhereRange( 'fa_name', $dir, $from, null ); |
96 | | - if ( isset( $params['prefix'] ) ) |
| 96 | + if ( isset( $params['prefix'] ) ) { |
97 | 97 | $this->addWhere( 'fa_name' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) ); |
| 98 | + } |
| 99 | + |
| 100 | + if ( !$wgUser->isAllowed( 'suppressrevision' ) ) { |
| 101 | + // Filter out revisions that the user is not allowed to see. There |
| 102 | + // is no way to indicate that we have skipped stuff because the |
| 103 | + // continuation parameter is fa_name |
| 104 | + |
| 105 | + // Note that this field is unindexed. This should however not be |
| 106 | + // a big problem as files with fa_deleted are rare |
| 107 | + $this->addWhereFld( 'fa_deleted', 0 ); |
| 108 | + } |
98 | 109 | |
| 110 | + |
| 111 | + |
99 | 112 | $limit = $params['limit']; |
100 | 113 | $this->addOption( 'LIMIT', $limit + 1 ); |
101 | 114 | $this->addOption( 'ORDER BY', 'fa_name' . |
— | — | @@ -147,7 +160,22 @@ |
148 | 161 | if ( $fld_mime ) { |
149 | 162 | $file['mime'] = "$row->fa_major_mime/$row->fa_minor_mime"; |
150 | 163 | } |
| 164 | + |
| 165 | + if ( $row->fa_deleted & File::DELETED_FILE ) { |
| 166 | + $file['deletedfile'] = ''; |
| 167 | + } |
| 168 | + if ( $row->fa_deleted & File::DELETED_COMMENT ) { |
| 169 | + $file['deletedcomment'] = ''; |
| 170 | + } |
| 171 | + if ( $row->fa_deleted & File::DELETED_USER ) { |
| 172 | + $file['deleteduser'] = ''; |
| 173 | + } |
| 174 | + if ( $row->fa_deleted & File::DELETED_RESTRICTED ) { |
| 175 | + // This file is deleted for normal admins |
| 176 | + $file['deletedrestricted'] = ''; |
| 177 | + } |
151 | 178 | |
| 179 | + |
152 | 180 | $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $file ); |
153 | 181 | if ( !$fit ) { |
154 | 182 | $this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->fa_name ) ); |