* (bug 32367) Fixed SpecialMovePage to not call wfLocalFile() on a non file title and expect an actual File back. Previously "worked" due to an old file title checking loophole (File objects with non File: titles).
* Use File::normalizeTitle() in some more functions that were still doing their own incomplete normalization.
* Updated FileRepo::newFile() docs to reflect that it can return null; wfLocalFile() docs already mentioned this.
* Returns a valid placeholder object if the file does not exist.
*
* @param $title Title or String
- * @return File, or null if passed an invalid Title
+ * @return File|null A File, or null if passed an invalid Title
*/
function wfLocalFile( $title ) {
return RepoGroup::singleton()->getLocalRepo()->newFile( $title );
* current file. Repositories not supporting version control
* should return false if this parameter is set.
*
- * @return File
+ * @return File|null A File, or null if passed an invalid Title
*/
function newFile( $title, $time = false ) {
- if ( !( $title instanceof Title ) ) {
- $title = Title::makeTitleSafe( NS_FILE, $title );
- if ( !is_object( $title ) ) {
- return null;
- }
+ $title = File::normalizeTitle( $title );
+ if ( !$title ) {
+ return null;
}
if ( $time ) {
if ( $this->oldFileFactory ) {
* @return File|false
*/
function findFile( $title, $options = array() ) {
- $time = isset( $options['time'] ) ? $options['time'] : false;
- if ( !($title instanceof Title) ) {
- $title = Title::makeTitleSafe( NS_FILE, $title );
- if ( !is_object( $title ) ) {
- return false;
- }
+ $title = File::normalizeTitle( $title );
+ if ( !$title ) {
+ return false;
}
+ $time = isset( $options['time'] ) ? $options['time'] : false;
# First try the current version of the file to see if it precedes the timestamp
$img = $this->newFile( $title );
if ( !$img ) {
if ( !is_array( $item ) ) {
$item = array( 'title' => $item );
}
- if ( !( $item['title'] instanceof Title ) )
- $item['title'] = Title::makeTitleSafe( NS_FILE, $item['title'] );
- if ( $item['title'] )
+ $item['title'] = File::normalizeTitle( $item['title'] );
+ if ( $item['title'] ) {
$items[$item['title']->getDBkey()] = $item;
+ }
}
$images = $this->localRepo->findFiles( $items );
$reason = wfMessage( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
// Delete an associated image if there is
- $file = wfLocalFile( $nt );
- if( $file->exists() ) {
- $file->delete( $reason, false );
+ if ( $nt->getNamespace() == NS_FILE ) {
+ $file = wfLocalFile( $nt );
+ if ( $file->exists() ) {
+ $file->delete( $reason, false );
+ }
}
$error = ''; // passed by ref