diff options
author | DannyS712 <DannyS712.enwiki@gmail.com> | 2019-12-19 23:13:31 +0000 |
---|---|---|
committer | DannyS712 <DannyS712.enwiki@gmail.com> | 2020-09-04 03:50:17 +0000 |
commit | 77781b08c7d9268b8ba6aea8ac8e667ba5666d57 (patch) | |
tree | 3d46b650d753f80cf5c0d75fbb410d561f955be6 /includes/MovePage.php | |
parent | d8ae5a03a772fa0c7f8b048e8d4b4905d50f5238 (diff) | |
download | mediawikicore-77781b08c7d9268b8ba6aea8ac8e667ba5666d57.tar.gz mediawikicore-77781b08c7d9268b8ba6aea8ac8e667ba5666d57.zip |
Add `delete-redirect` for deleting single-rev redirects during moves
A new user right, `delete-redirect`, is added (not given to anyone
by default). At Special:MovePage, if attempting to move to a single
revision redirect that would otherwise be an invalid target (i.e.
doesn't point to the source page), the user is able to delete the
target.
Deletions are logged as `delete/delete_redir2`, and the move is
then logged normally as `move/move`, mirroring current delete and
move logging.
To allow for separate handling by Special:MovePage,
MovePage::isValidMove now returns a fatal status `redirectexists` if
the target isn't valid but passes Title::isSingleRevRedirect.
Otherwise, `articleexists` is returned (as previously). Other callers
that don't intend to treat single revision redirects differently
should treat `redirectexists` the same as `articleexists`.
Currently, this deletion (like normal delete and move) cannot be
done through the move api. Since the deletion is only valid when
moving a page, unlike for normal deletion, deleting redirects with
this right cannot be done via the delete api either.
Bug: T239277
Change-Id: I36c8df0a12d326ae07018046541bd00103936144
Diffstat (limited to 'includes/MovePage.php')
-rw-r--r-- | includes/MovePage.php | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/includes/MovePage.php b/includes/MovePage.php index 5540aadbb9cd..c99ae72fe98c 100644 --- a/includes/MovePage.php +++ b/includes/MovePage.php @@ -222,8 +222,11 @@ class MovePage { } elseif ( $this->newTitle->getArticleID() && !$this->isValidMoveTarget() ) { // The move is allowed only if (1) the target doesn't exist, or (2) the target is a // redirect to the source, and has no history (so we can undo bad moves right after - // they're done). - $status->fatal( 'articleexists', $this->newTitle->getPrefixedText() ); + // they're done). If the target is a single revision redirect to a different page, + // it can be deleted with just `delete-redirect` rights (i.e. without needing + // `delete`) - see T239277 + $fatal = $this->newTitle->isSingleRevRedirect() ? 'redirectexists' : 'articleexists'; + $status->fatal( $fatal, $this->newTitle->getPrefixedText() ); } // @todo If the old title is invalid, maybe we should check if it somehow exists in the |