MovePage: Don't fail to delete a nonexistent file
If there's no file to be moved (e.g. it's a redirect in the File namespace), don't fail with an error about being unable to delete the nonexistent file. Just let it work. Bug: T249550 Change-Id: I605b0e4b39e7863bddbebf339994c819528e3a4c
This commit is contained in:
parent
60a39d4c8b
commit
68e0ff3f64
2 changed files with 8 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue