Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -3258,7 +3258,7 @@ |
3259 | 3259 | * Returns a valid placeholder object if the file does not exist. |
3260 | 3260 | * |
3261 | 3261 | * @param $title Title or String |
3262 | | - * @return File, or null if passed an invalid Title |
| 3262 | + * @return File|null A File, or null if passed an invalid Title |
3263 | 3263 | */ |
3264 | 3264 | function wfLocalFile( $title ) { |
3265 | 3265 | return RepoGroup::singleton()->getLocalRepo()->newFile( $title ); |
Index: trunk/phase3/includes/filerepo/FileRepo.php |
— | — | @@ -71,14 +71,12 @@ |
72 | 72 | * current file. Repositories not supporting version control |
73 | 73 | * should return false if this parameter is set. |
74 | 74 | * |
75 | | - * @return File |
| 75 | + * @return File|null A File, or null if passed an invalid Title |
76 | 76 | */ |
77 | 77 | function newFile( $title, $time = false ) { |
78 | | - if ( !( $title instanceof Title ) ) { |
79 | | - $title = Title::makeTitleSafe( NS_FILE, $title ); |
80 | | - if ( !is_object( $title ) ) { |
81 | | - return null; |
82 | | - } |
| 78 | + $title = File::normalizeTitle( $title ); |
| 79 | + if ( !$title ) { |
| 80 | + return null; |
83 | 81 | } |
84 | 82 | if ( $time ) { |
85 | 83 | if ( $this->oldFileFactory ) { |
— | — | @@ -111,13 +109,11 @@ |
112 | 110 | * @return File|false |
113 | 111 | */ |
114 | 112 | function findFile( $title, $options = array() ) { |
115 | | - $time = isset( $options['time'] ) ? $options['time'] : false; |
116 | | - if ( !($title instanceof Title) ) { |
117 | | - $title = Title::makeTitleSafe( NS_FILE, $title ); |
118 | | - if ( !is_object( $title ) ) { |
119 | | - return false; |
120 | | - } |
| 113 | + $title = File::normalizeTitle( $title ); |
| 114 | + if ( !$title ) { |
| 115 | + return false; |
121 | 116 | } |
| 117 | + $time = isset( $options['time'] ) ? $options['time'] : false; |
122 | 118 | # First try the current version of the file to see if it precedes the timestamp |
123 | 119 | $img = $this->newFile( $title ); |
124 | 120 | if ( !$img ) { |
Index: trunk/phase3/includes/filerepo/RepoGroup.php |
— | — | @@ -172,10 +172,10 @@ |
173 | 173 | if ( !is_array( $item ) ) { |
174 | 174 | $item = array( 'title' => $item ); |
175 | 175 | } |
176 | | - if ( !( $item['title'] instanceof Title ) ) |
177 | | - $item['title'] = Title::makeTitleSafe( NS_FILE, $item['title'] ); |
178 | | - if ( $item['title'] ) |
| 176 | + $item['title'] = File::normalizeTitle( $item['title'] ); |
| 177 | + if ( $item['title'] ) { |
179 | 178 | $items[$item['title']->getDBkey()] = $item; |
| 179 | + } |
180 | 180 | } |
181 | 181 | |
182 | 182 | $images = $this->localRepo->findFiles( $items ); |
Index: trunk/phase3/includes/specials/SpecialMovepage.php |
— | — | @@ -376,9 +376,11 @@ |
377 | 377 | $reason = wfMessage( 'delete_and_move_reason', $ot )->inContentLanguage()->text(); |
378 | 378 | |
379 | 379 | // Delete an associated image if there is |
380 | | - $file = wfLocalFile( $nt ); |
381 | | - if( $file->exists() ) { |
382 | | - $file->delete( $reason, false ); |
| 380 | + if ( $nt->getNamespace() == NS_FILE ) { |
| 381 | + $file = wfLocalFile( $nt ); |
| 382 | + if ( $file->exists() ) { |
| 383 | + $file->delete( $reason, false ); |
| 384 | + } |
383 | 385 | } |
384 | 386 | |
385 | 387 | $error = ''; // passed by ref |