Allow only users with the 'reupload-shared' right to complete the move.
* (bug 21006) maintenance/updateArticleCount.php now works again on PostgreSQL
* (bug 19319) Add activeusers-intro message at top of SpecialActiveUsers page
* (bug 21255) Fixed hostname construction for DNSBL checking
+* (bug 18019) Users are now warned when moving a file to a name in use on a
+ shared repository and only users with the 'reupload-shared' permission can
+ complete the move.
== API changes in 1.16 ==
'import-noarticle' => array('code' => 'badinterwiki', 'info' => 'Invalid interwiki title specified'),
'importbadinterwiki' => array('code' => 'badinterwiki', 'info' => 'Invalid interwiki title specified'),
'import-unknownerror' => array('code' => 'import-unknownerror', 'info' => "Unknown error on import: ``\$1''"),
+ 'cantoverwrite-sharedfile' => array('code' => 'cantoverwrite-sharedfile', 'info' => 'The target file exists on a shared repository and you do not have permission to override it'),
+ 'sharedfile-exists' => array('code' => 'fileexists-sharedrepo-perm', 'info' => 'The target file exists on a shared repository. Use the ignorewarnings parameter to override it.'),
// ApiEditPage messages
'noimageredirect-anon' => array('code' => 'noimageredirect-anon', 'info' => "Anonymous users can't create image redirects"),
if(!$toTitle)
$this->dieUsageMsg(array('invalidtitle', $params['to']));
$toTalk = $toTitle->getTalkPage();
-
+
+ if ( $toTitle->getNamespace() == NS_FILE
+ && !RepoGroup::singleton()->getLocalRepo()->findFile( $toTitle )
+ && wfFindFile( $toTitle ) )
+ {
+ if ( !$params['ignorewarnings'] && $wgUser->isAllowed( 'reupload-shared' ) ) {
+ $this->dieUsageMsg(array('sharedfile-exists'));
+ } elseif ( !$wgUser->isAllowed( 'reupload-shared' ) ) {
+ $this->dieUsageMsg(array('cantoverwrite-sharedfile'));
+ }
+ }
+
# Move the page
$hookErr = null;
$retval = $fromTitle->moveTo($toTitle, true, $params['reason'], !$params['noredirect']);
'movesubpages' => false,
'noredirect' => false,
'watch' => false,
- 'unwatch' => false
+ 'unwatch' => false,
+ 'ignorewarnings' => false
);
}
'movesubpages' => 'Move subpages, if applicable',
'noredirect' => 'Don\'t create a redirect',
'watch' => 'Add the page and the redirect to your watchlist',
- 'unwatch' => 'Remove the page and the redirect from your watchlist'
+ 'unwatch' => 'Remove the page and the redirect from your watchlist',
+ 'ignorewarnings' => 'Ignore any warnings'
);
}
class MovePageForm {
var $oldTitle, $newTitle; # Objects
var $reason; # Text input
- var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects, $leaveRedirect; # Checks
+ var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects, $leaveRedirect, $moveOverShared; # Checks
private $watch = false;
}
$this->moveSubpages = $wgRequest->getBool( 'wpMovesubpages', false );
$this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' );
+ $this->moveOverShared = $wgRequest->getBool( 'wpMoveOverSharedFile', false );
$this->watch = $wgRequest->getCheck( 'wpWatch' );
}
$confirm = false;
}
+ if ( !empty($err) && $err[0] == 'file-exists-sharedrepo' && $wgUser->isAllowed( 'reupload-shared' ) ) {
+ $wgOut->addWikiMsg( 'move-over-sharedrepo', $newTitle->getPrefixedText() );
+ $submitVar = 'wpMoveOverSharedFile';
+ $err = '';
+ }
+
$oldTalk = $this->oldTitle->getTalkPage();
$considerTalk = ( !$this->oldTitle->isTalkPage() && $oldTalk->exists() );
return;
}
+ # Show a warning if the target file exists on a shared repo
+ if ( $nt->getNamespace() == NS_FILE
+ && !( $this->moveOverShared && $wgUser->isAllowed( 'reupload-shared' ) )
+ && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt )
+ && wfFindFile( $nt ) )
+ {
+ $this->showForm( array('file-exists-sharedrepo') );
+ return;
+
+ }
+
if ( $wgUser->isAllowed( 'suppressredirect' ) ) {
$createRedirect = $this->leaveRedirect;
} else {
'move-leave-redirect' => 'Leave a redirect behind',
'protectedpagemovewarning' => "'''Warning:''' This page has been locked so that only users with administrator privileges can move it.",
'semiprotectedpagemovewarning' => "'''Note:''' This page has been locked so that only registered users can move it.",
+'move-over-sharedrepo' => '==File exists==
+[[:$1]] exists on a shared repository. Moving a file to this title will override the shared file.',
+'file-exists-sharedrepo' => 'The file name chosen is already in use on a shared repository.
+Please choose another name.',
# Export
'export' => 'Export pages',