Index: branches/filerepo-work/phase3/includes/filerepo/LocalFile.php |
— | — | @@ -76,7 +76,12 @@ |
77 | 77 | // Check if the key existed and belongs to this version of MediaWiki |
78 | 78 | if ( isset($cachedValues['version']) && ( $cachedValues['version'] == MW_FILE_VERSION ) ) { |
79 | 79 | wfDebug( "Pulling file metadata from cache key $key\n" ); |
80 | | - $this->loadFromRow( $cachedValues, '' ); |
| 80 | + $this->fileExists = $cachedValues['fileExists']; |
| 81 | + if ( $this->fileExists ) { |
| 82 | + unset( $cachedValues['version'] ); |
| 83 | + unset( $cachedValues['fileExists'] ); |
| 84 | + $this->loadFromRow( $cachedValues, '' ); |
| 85 | + } |
81 | 86 | } |
82 | 87 | if ( $this->dataLoaded ) { |
83 | 88 | wfIncrStats( 'image_cache_hit' ); |
— | — | @@ -100,8 +105,11 @@ |
101 | 106 | } |
102 | 107 | $fields = $this->getCacheFields( '' ); |
103 | 108 | $cache = array( 'version' => MW_FILE_VERSION ); |
104 | | - foreach ( $fields as $field ) { |
105 | | - $cache[$field] = $this->$field; |
| 109 | + $cache['fileExists'] = $this->fileExists; |
| 110 | + if ( $this->fileExists ) { |
| 111 | + foreach ( $fields as $field ) { |
| 112 | + $cache[$field] = $this->$field; |
| 113 | + } |
106 | 114 | } |
107 | 115 | |
108 | 116 | $wgMemc->set( $key, $cache, 60 * 60 * 24 * 7 ); // A week |
— | — | @@ -120,6 +128,7 @@ |
121 | 129 | $magic=& MimeMagic::singleton(); |
122 | 130 | |
123 | 131 | $this->mime = $magic->guessMimeType($path,true); |
| 132 | + list( $this->major_mime, $this->minor_mime ) = self::splitMime( $this->mime ); |
124 | 133 | $this->media_type = $magic->getMediaType($path,$this->mime); |
125 | 134 | $handler = MediaHandler::getHandler( $this->mime ); |
126 | 135 | |
— | — | @@ -168,7 +177,7 @@ |
169 | 178 | static $fields = array( 'size', 'width', 'height', 'bits', 'media_type', |
170 | 179 | 'major_mime', 'minor_mime', 'metadata', 'timestamp' ); |
171 | 180 | static $results = array(); |
172 | | - if ( $prefix = '' ) { |
| 181 | + if ( $prefix == '' ) { |
173 | 182 | return $fields; |
174 | 183 | } |
175 | 184 | if ( !isset( $results[$prefix] ) ) { |
— | — | @@ -176,9 +185,9 @@ |
177 | 186 | foreach ( $fields as $field ) { |
178 | 187 | $prefixedFields[] = $prefix . $field; |
179 | 188 | } |
180 | | - $fields[$prefix] = $prefixedFields; |
| 189 | + $results[$prefix] = $prefixedFields; |
181 | 190 | } |
182 | | - return $fields[$prefix]; |
| 191 | + return $results[$prefix]; |
183 | 192 | } |
184 | 193 | |
185 | 194 | /** |
— | — | @@ -192,6 +201,7 @@ |
193 | 202 | $row = $dbr->selectRow( 'image', $this->getCacheFields( 'img_' ), |
194 | 203 | array( 'img_name' => $this->getName() ), __METHOD__ ); |
195 | 204 | if ( $row ) { |
| 205 | + $this->fileExists = true; |
196 | 206 | $this->decodeRow( $row ); |
197 | 207 | $this->loadFromRow( $row ); |
198 | 208 | // Check for rows from a previous schema, quietly upgrade them |
— | — | @@ -207,7 +217,7 @@ |
208 | 218 | |
209 | 219 | function decodeRow( &$row, $prefix = 'img_' ) { |
210 | 220 | $tsName = $prefix . 'timestamp'; |
211 | | - $row->$tsName = wfTimestamp( $row->$tsName ); |
| 221 | + $row->$tsName = wfTimestamp( TS_MW, $row->$tsName ); |
212 | 222 | } |
213 | 223 | |
214 | 224 | function encodeRow( &$row, $db, $prefix = 'img_' ) { |
— | — | @@ -237,7 +247,6 @@ |
238 | 248 | } |
239 | 249 | $this->mime = $this->major_mime.'/'.$this->minor_mime; |
240 | 250 | } |
241 | | - $this->fileExists = true; |
242 | 251 | $this->dataLoaded = true; |
243 | 252 | } |
244 | 253 | |
Index: branches/filerepo-work/phase3/includes/filerepo/FSRepo.php |
— | — | @@ -62,6 +62,9 @@ |
63 | 63 | */ |
64 | 64 | function findFile( $title, $time = false ) { |
65 | 65 | $img = $this->newFile( $title ); |
| 66 | + if ( !$img ) { |
| 67 | + return false; |
| 68 | + } |
66 | 69 | if ( $img->exists() && $img->getTimestamp() <= $time ) { |
67 | 70 | return $img; |
68 | 71 | } |