Manual:Hooks/TitleMove

From MediaWiki.org
Jump to navigation Jump to search
TitleMove
Available from version 1.22.0
Occurs immediately before a file or other page is moved
Define function:
public static function onTitleMove( Title &$title, Title &$newtitle, User &$user ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"TitleMove": "MyExtensionHooks::onTitleMove"
	}
}

For MediaWiki ≤1.25:

$wgHooks['TitleMove'][] = 'MyExtensionHooks::onTitleMove';
Called from:File(s): Title.php
Function(s): Title::moveTo()

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:TitleMove extensions.

This hook is in Title::moveTo(), which is called from SpecialMovepage.php and ApiMove.php .

Details[edit]

MediaWiki version: 1.33
  • $old: old title
  • $new: new title
  • $user: user who does the move
  • $reason: string of the reason provided by the user
  • &$status: Status object. To abort the move, add a fatal error to this object (i.e. call $status->fatal()).

MediaWiki version: 1.32
  • $title: old Title
  • $newtitle: new Title
  • $user: User who is doing the move

See also[edit]