diff --git a/includes/MovePage.php b/includes/MovePage.php index 3c12a0af589..5a0f04c6554 100644 --- a/includes/MovePage.php +++ b/includes/MovePage.php @@ -703,15 +703,12 @@ class MovePage { * @return Status */ private function moveFile( $oldTitle, $newTitle ) { - $status = Status::newFatal( - 'cannotdelete', - $oldTitle->getPrefixedText() - ); - $file = $this->repoGroup->getLocalRepo()->newFile( $oldTitle ); $file->load( File::READ_LATEST ); if ( $file->exists() ) { $status = $file->move( $newTitle ); + } else { + $status = Status::newGood(); } // Clear RepoGroup process cache diff --git a/tests/phpunit/includes/MovePageTest.php b/tests/phpunit/includes/MovePageTest.php index 4d5b5564dba..19c39f7505f 100644 --- a/tests/phpunit/includes/MovePageTest.php +++ b/tests/phpunit/includes/MovePageTest.php @@ -105,6 +105,7 @@ class MovePageTest extends MediaWikiTestCase { $this->getExistingTestPage( 'Existent2' ); $this->getExistingTestPage( 'File:Existent.jpg' ); $this->getExistingTestPage( 'File:Existent2.jpg' ); + $this->getExistingTestPage( 'File:Non-file.jpg' ); $this->getExistingTestPage( 'MediaWiki:Existent.js' ); $this->getExistingTestPage( 'Hooked in place' ); $this->getNonExistingTestPage( 'Nonexistent' ); @@ -306,6 +307,11 @@ class MovePageTest extends MediaWikiTestCase { 'File:Nonexistent.png', [ [ 'imagetypemismatch' ] ], ], + 'Non-file page in the File namespace' => [ + 'File:Non-file.jpg', + 'File:Non-file-new.png', + [], + ], ]; return $ret; }