MediaWiki  master
MovePage Class Reference

Handles the backend logic of moving a page from one title to another. More...

Collaboration diagram for MovePage:

Public Member Functions

 __construct (Title $oldTitle, Title $newTitle, ServiceOptions $options=null, ILoadBalancer $loadBalancer=null, NamespaceInfo $nsInfo=null, WatchedItemStoreInterface $watchedItems=null, PermissionManager $permMgr=null, RepoGroup $repoGroup=null, IContentHandlerFactory $contentHandlerFactory=null, RevisionStore $revisionStore=null, SpamChecker $spamChecker=null, HookContainer $hookContainer=null)
 Calling this directly is deprecated in 1.34. More...
 
 checkPermissions (User $user, $reason)
 Check if the user is allowed to perform the move. More...
 
 isValidMove ()
 Does various sanity checks that the move is valid. More...
 
 move (User $user, $reason=null, $createRedirect=true, array $changeTags=[])
 Move a page without taking user permissions into account. More...
 
 moveIfAllowed (User $user, $reason=null, $createRedirect=true, array $changeTags=[])
 Same as move(), but with permissions checks. More...
 
 moveSubpages (User $user, $reason=null, $createRedirect=true, array $changeTags=[])
 Move the source page's subpages to be subpages of the target page, without checking user permissions. More...
 
 moveSubpagesIfAllowed (User $user, $reason=null, $createRedirect=true, array $changeTags=[])
 Move the source page's subpages to be subpages of the target page, with user permission checks. More...
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Protected Member Functions

 isValidFileMove ()
 Sanity checks for when a file is being moved. More...
 
 isValidMoveTarget ()
 Checks if $this can be moved to a given Title. More...
 

Protected Attributes

ILoadBalancer $loadBalancer
 
Title $newTitle
 
NamespaceInfo $nsInfo
 
Title $oldTitle
 
ServiceOptions $options
 
PermissionManager $permMgr
 
RepoGroup $repoGroup
 
WatchedItemStoreInterface $watchedItems
 

Private Member Functions

 moveFile ( $oldTitle, $newTitle)
 Move a file associated with a page to a new location. More...
 
 moveSubpagesInternal ( $checkPermissions, User $user, $reason, $createRedirect, array $changeTags)
 
 moveToInternal (User $user, &$nt, $reason='', $createRedirect=true, array $changeTags=[])
 Move page to a title which is either a redirect to the source page or nonexistent. More...
 
 moveUnsafe (User $user, $reason, $createRedirect, array $changeTags)
 Moves without any sort of safety or sanity checks. More...
 

Private Attributes

IContentHandlerFactory $contentHandlerFactory
 
HookContainer $hookContainer
 
HookRunner $hookRunner
 
RevisionStore $revisionStore
 
SpamChecker $spamChecker
 

Detailed Description

Handles the backend logic of moving a page from one title to another.

Since
1.24

Definition at line 42 of file MovePage.php.

Constructor & Destructor Documentation

◆ __construct()

MovePage::__construct ( Title  $oldTitle,
Title  $newTitle,
ServiceOptions  $options = null,
ILoadBalancer  $loadBalancer = null,
NamespaceInfo  $nsInfo = null,
WatchedItemStoreInterface  $watchedItems = null,
PermissionManager  $permMgr = null,
RepoGroup  $repoGroup = null,
IContentHandlerFactory  $contentHandlerFactory = null,
RevisionStore  $revisionStore = null,
SpamChecker  $spamChecker = null,
HookContainer  $hookContainer = null 
)

Calling this directly is deprecated in 1.34.

Use MovePageFactory instead.

Parameters
Title$oldTitle
Title$newTitle
ServiceOptions | null$options
ILoadBalancer | null$loadBalancer
NamespaceInfo | null$nsInfo
WatchedItemStoreInterface | null$watchedItems
PermissionManager | null$permMgr
RepoGroup | null$repoGroup
IContentHandlerFactory | null$contentHandlerFactory
RevisionStore | null$revisionStore
SpamChecker | null$spamChecker
HookContainer | null$hookContainer

Definition at line 129 of file MovePage.php.

References $contentHandlerFactory, $hookContainer, $loadBalancer, $newTitle, $nsInfo, $oldTitle, $options, $permMgr, $repoGroup, $revisionStore, $spamChecker, and $watchedItems.

Member Function Documentation

◆ checkPermissions()

MovePage::checkPermissions ( User  $user,
  $reason 
)

Check if the user is allowed to perform the move.

Parameters
User$user
string | null$reasonTo check against summary spam regex. Set to null to skip the check, for instance to display errors preemptively before the user has filled in a summary.
Returns
Status

Definition at line 174 of file MovePage.php.

References wfMergeErrorArrays().

Referenced by moveIfAllowed().

◆ isValidFileMove()

MovePage::isValidFileMove ( )
protected

Sanity checks for when a file is being moved.

Returns
Status

Definition at line 290 of file MovePage.php.

References $file, File\checkExtensionCompatibility(), NS_FILE, and wfStripIllegalFilenameChars().

Referenced by isValidMove().

◆ isValidMove()

MovePage::isValidMove ( )

Does various sanity checks that the move is valid.

Only things based on the two titles should be checked here.

Returns
Status

Definition at line 215 of file MovePage.php.

References ContentHandler\getLocalizedName(), isValidFileMove(), NS_FILE, and wfMessage().

Referenced by move(), and moveIfAllowed().

◆ isValidMoveTarget()

MovePage::isValidMoveTarget ( )
protected

Checks if $this can be moved to a given Title.

  • Selects for update, so don't call it unless you mean business
Since
1.25
Returns
bool

Definition at line 320 of file MovePage.php.

References $content, $file, NS_FILE, and wfDebug().

◆ move()

MovePage::move ( User  $user,
  $reason = null,
  $createRedirect = true,
array  $changeTags = [] 
)

Move a page without taking user permissions into account.

Only checks if the move is itself invalid, e.g., trying to move a special page or trying to move a page onto one that already exists.

Parameters
User$user
string | null$reason
bool | null$createRedirect
string[]$changeTagsChange tags to apply to the entry in the move log
Returns
Status

Definition at line 376 of file MovePage.php.

References isValidMove(), and moveUnsafe().

◆ moveFile()

MovePage::moveFile (   $oldTitle,
  $newTitle 
)
private

Move a file associated with a page to a new location.

Can also be used to revert after a DB failure.

Definition at line 771 of file MovePage.php.

References $file, $newTitle, $oldTitle, and StatusValue\newGood().

Referenced by moveUnsafe().

◆ moveIfAllowed()

MovePage::moveIfAllowed ( User  $user,
  $reason = null,
  $createRedirect = true,
array  $changeTags = [] 
)

Same as move(), but with permissions checks.

Parameters
User$user
string | null$reason
bool | null$createRedirectIgnored if user doesn't have suppressredirect permission
string[]$changeTagsChange tags to apply to the entry in the move log
Returns
Status

Definition at line 396 of file MovePage.php.

References ChangeTags\canAddTagsAccompanyingChange(), checkPermissions(), isValidMove(), moveUnsafe(), and User\spreadAnyEditBlock().

◆ moveSubpages()

MovePage::moveSubpages ( User  $user,
  $reason = null,
  $createRedirect = true,
array  $changeTags = [] 
)

Move the source page's subpages to be subpages of the target page, without checking user permissions.

The caller is responsible for moving the source page itself. We will still not do moves that are inherently not allowed, nor will we move more than $wgMaximumMovedPages.

Parameters
User$user
string | null$reasonThe reason for the move
bool | null$createRedirectWhether to create redirects from the old subpages to the new ones
string[]$changeTagsApplied to entries in the move log and redirect page revision
Returns
Status Good if no errors occurred. Ok if at least one page succeeded. The "value" of the top-level status is an array containing the per-title status for each page. For any move that succeeded, the "value" of the per-title status is the new page title.

Definition at line 434 of file MovePage.php.

References moveSubpagesInternal().

◆ moveSubpagesIfAllowed()

MovePage::moveSubpagesIfAllowed ( User  $user,
  $reason = null,
  $createRedirect = true,
array  $changeTags = [] 
)

Move the source page's subpages to be subpages of the target page, with user permission checks.

The caller is responsible for moving the source page itself.

Parameters
User$user
string | null$reasonThe reason for the move
bool | null$createRedirectWhether to create redirects from the old subpages to the new ones. Ignored if the user doesn't have the 'suppressredirect' right.
string[]$changeTagsApplied to entries in the move log and redirect page revision
Returns
Status Good if no errors occurred. Ok if at least one page succeeded. The "value" of the top-level status is an array containing the per-title status for each page. For any move that succeeded, the "value" of the per-title status is the new page title.

Definition at line 453 of file MovePage.php.

References moveSubpagesInternal().

◆ moveSubpagesInternal()

MovePage::moveSubpagesInternal (   $checkPermissions,
User  $user,
  $reason,
  $createRedirect,
array  $changeTags 
)
private
Parameters
bool$checkPermissions
User$user
string$reason
bool$createRedirect
array$changeTags
Returns
Status

Definition at line 467 of file MovePage.php.

References $nsInfo, $wgMaximumMovedPages, StringUtils\escapeRegexReplacement(), NamespaceInfo\getCanonicalName(), NamespaceInfo\hasSubpages(), Title\makeTitleSafe(), StatusValue\newFatal(), and StatusValue\newGood().

Referenced by moveSubpages(), and moveSubpagesIfAllowed().

◆ moveToInternal()

MovePage::moveToInternal ( User  $user,
$nt,
  $reason = '',
  $createRedirect = true,
array  $changeTags = [] 
)
private

Move page to a title which is either a redirect to the source page or nonexistent.

Todo:
This was basically directly moved from Title, it should be split into smaller functions
Parameters
User$userthe User doing the move
Title&$ntThe page to move to, which should be a redirect or non-existent
string$reasonThe reason for the move
bool$createRedirectWhether to leave a redirect at the old title. Does not check if the user has the suppressredirect right
string[]$changeTagsChange tags to apply to the entry in the move log
Returns
RevisionRecord the revision created by the move
Exceptions
MWException

Definition at line 801 of file MovePage.php.

References $oldTitle, ChangeTags\addTags(), DB_MASTER, WikiPage\factory(), ChangeTags\getSoftwareTags(), User\incEditCount(), RequestContext\newExtraneousContext(), LogFormatter\newFromEntry(), CommentStoreComment\newUnsavedComment(), NS_CATEGORY, WikiPage\onArticleCreate(), WikiPage\onArticleDelete(), IDBAccessObject\READ_LOCKING, and wfMessage().

Referenced by moveUnsafe().

◆ moveUnsafe()

MovePage::moveUnsafe ( User  $user,
  $reason,
  $createRedirect,
array  $changeTags 
)
private

Moves without any sort of safety or sanity checks.

Hooks can still fail the move, however.

Parameters
User$user
string$reason
bool$createRedirect
string[]$changeTagsChange tags to apply to the entry in the move log
Returns
Status

Definition at line 556 of file MovePage.php.

References $res, $type, DeferredUpdates\addUpdate(), DB_MASTER, moveFile(), moveToInternal(), StatusValue\newGood(), NS_FILE, Collation\singleton(), and wfMessage().

Referenced by move(), and moveIfAllowed().

Member Data Documentation

◆ $contentHandlerFactory

IContentHandlerFactory MovePage::$contentHandlerFactory
private

Definition at line 87 of file MovePage.php.

Referenced by __construct().

◆ $hookContainer

HookContainer MovePage::$hookContainer
private

Definition at line 102 of file MovePage.php.

Referenced by __construct().

◆ $hookRunner

HookRunner MovePage::$hookRunner
private

Definition at line 107 of file MovePage.php.

◆ $loadBalancer

ILoadBalancer MovePage::$loadBalancer
protected

Definition at line 62 of file MovePage.php.

Referenced by __construct().

◆ $newTitle

Title MovePage::$newTitle
protected

Definition at line 52 of file MovePage.php.

Referenced by __construct(), and moveFile().

◆ $nsInfo

NamespaceInfo MovePage::$nsInfo
protected

Definition at line 67 of file MovePage.php.

Referenced by __construct(), and moveSubpagesInternal().

◆ $oldTitle

Title MovePage::$oldTitle
protected

Definition at line 47 of file MovePage.php.

Referenced by __construct(), moveFile(), and moveToInternal().

◆ $options

ServiceOptions MovePage::$options
protected

Definition at line 57 of file MovePage.php.

Referenced by __construct().

◆ $permMgr

PermissionManager MovePage::$permMgr
protected

Definition at line 77 of file MovePage.php.

Referenced by __construct().

◆ $repoGroup

RepoGroup MovePage::$repoGroup
protected

Definition at line 82 of file MovePage.php.

Referenced by __construct().

◆ $revisionStore

RevisionStore MovePage::$revisionStore
private

Definition at line 92 of file MovePage.php.

Referenced by __construct().

◆ $spamChecker

SpamChecker MovePage::$spamChecker
private

Definition at line 97 of file MovePage.php.

Referenced by __construct().

◆ $watchedItems

WatchedItemStoreInterface MovePage::$watchedItems
protected

Definition at line 72 of file MovePage.php.

Referenced by __construct().

◆ CONSTRUCTOR_OPTIONS

const MovePage::CONSTRUCTOR_OPTIONS
Initial value:
= [
'CategoryCollation'
]

Definition at line 109 of file MovePage.php.


The documentation for this class was generated from the following file: