Index: branches/filerepo-work/phase3/includes/filerepo/OldLocalFile.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * @addtogroup FileRepo
|
8 | 8 | */
|
9 | 9 | class OldLocalFile extends LocalFile {
|
10 | | - var $requestedTime, $archive_name;
|
| 10 | + var $requestedTime, $archive_name, $deleted=0;
|
11 | 11 |
|
12 | 12 | const CACHE_VERSION = 1;
|
13 | 13 | const MAX_CACHE_ROWS = 20;
|
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | function __construct( $title, $repo, $time ) {
|
20 | 20 | parent::__construct( $title, $repo );
|
21 | 21 | $this->requestedTime = $time;
|
| 22 | + $this->isOldFile = true;
|
22 | 23 | }
|
23 | 24 |
|
24 | 25 | function getCacheKey() {
|
— | — | @@ -139,6 +140,34 @@ |
140 | 141 | function getUrlRel() {
|
141 | 142 | return 'archive/' . $this->getHashPath() . '/' . urlencode( $this->archive_name );
|
142 | 143 | }
|
| 144 | +
|
| 145 | + /**
|
| 146 | + * int $field one of DELETED_* bitfield constants
|
| 147 | + * for file or revision rows
|
| 148 | + * @return bool
|
| 149 | + */
|
| 150 | + function isDeleted( $field ) {
|
| 151 | + return ($this->deleted & $field) == $field;
|
| 152 | + }
|
| 153 | +
|
| 154 | + /**
|
| 155 | + * Determine if the current user is allowed to view a particular
|
| 156 | + * field of this file, if it's marked as deleted.
|
| 157 | + * @param int $field
|
| 158 | + * @return bool
|
| 159 | + */
|
| 160 | + function userCan( $field ) {
|
| 161 | + if( ($this->deleted & $field) == $field ) {
|
| 162 | + global $wgUser;
|
| 163 | + $permission = ( $this->deleted & File::DELETED_RESTRICTED ) == File::DELETED_RESTRICTED
|
| 164 | + ? 'hiderevision'
|
| 165 | + : 'deleterevision';
|
| 166 | + wfDebug( "Checking for $permission due to $field match on $this->mDeleted\n" );
|
| 167 | + return $wgUser->isAllowed( $permission );
|
| 168 | + } else {
|
| 169 | + return true;
|
| 170 | + }
|
| 171 | + }
|
143 | 172 | }
|
144 | 173 |
|
145 | 174 |
|
Index: branches/filerepo-work/phase3/includes/filerepo/LocalFile.php |
— | — | @@ -281,17 +281,34 @@ |
282 | 282 | |
283 | 283 | wfDebug(__METHOD__.': upgrading '.$this->getName()." to the current schema\n"); |
284 | 284 | |
285 | | - $dbw->update( 'image', |
286 | | - array( |
287 | | - 'img_width' => $this->width, |
288 | | - 'img_height' => $this->height, |
289 | | - 'img_bits' => $this->bits, |
290 | | - 'img_media_type' => $this->media_type, |
291 | | - 'img_major_mime' => $major, |
292 | | - 'img_minor_mime' => $minor, |
293 | | - 'img_metadata' => $this->metadata, |
294 | | - ), array( 'img_name' => $this->getName() ), __METHOD__ |
295 | | - ); |
| 285 | + if( !$this->isOldImage ) { |
| 286 | + $dbw->update( 'image', |
| 287 | + array( |
| 288 | + 'img_width' => $this->width, |
| 289 | + 'img_height' => $this->height, |
| 290 | + 'img_bits' => $this->bits, |
| 291 | + 'img_media_type' => $this->media_type, |
| 292 | + 'img_major_mime' => $major, |
| 293 | + 'img_minor_mime' => $minor, |
| 294 | + 'img_metadata' => $this->metadata, |
| 295 | + ), array( 'img_name' => $this->getName() ), |
| 296 | + __METHOD__ |
| 297 | + ); |
| 298 | + } else { |
| 299 | + $dbw->update( 'oldimage', |
| 300 | + array( |
| 301 | + 'oi_width' => $this->width, |
| 302 | + 'oi_height' => $this->height, |
| 303 | + 'oi_bits' => $this->bits, |
| 304 | + 'oi_media_type' => $this->media_type, |
| 305 | + 'oi_major_mime' => $major, |
| 306 | + 'oi_minor_mime' => $minor, |
| 307 | + 'oi_metadata' => $this->metadata, |
| 308 | + ), array( 'oi_name' => $this->getName(), 'oi_timestamp' => $this->requestedTime ), |
| 309 | + __METHOD__ |
| 310 | + ); |
| 311 | + } |
| 312 | + |
296 | 313 | wfProfileOut( __METHOD__ ); |
297 | 314 | } |
298 | 315 | |
Index: branches/filerepo-work/phase3/includes/filerepo/File.php |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | /** |
49 | 49 | * The following member variables are not lazy-initialised |
50 | 50 | */ |
51 | | - var $repo, $title, $lastError; |
| 51 | + var $repo, $title, $lastError, $isOldFile=false; |
52 | 52 | |
53 | 53 | function __construct( $title, $repo ) { |
54 | 54 | $this->title = $title; |