-
- # Update counters if the article got moved into or out of NS_MAIN namespace
- $ons = $ot->getNamespace();
- $nns = $nt->getNamespace();
-
- # moved out of article namespace?
- if ( $ons == NS_MAIN and $nns != NS_MAIN ) {
- $u = new SiteStatsUpdate( 0, 1, -1); # not viewed, edited, removing
- }
- # moved into article namespace?
- elseif ( $ons != NS_MAIN and $nns == NS_MAIN ) {
- $u = new SiteStatsUpdate( 0, 1, +1 ); # not viewed, edited, adding
- } else {
- $u = false;
- }
- if ( $u !== false ) {
- # save it for later update
- array_push( $wgDeferredUpdateList, $u );
- unset($u);
- }
-
- # Move talk page if
- # (1) the checkbox says to,
- # (2) the namespaces are not themselves talk namespaces, and of course
- # (3) it exists.
-
- if ( ( $wgRequest->getVal('wpMovetalk') == 1 ) &&
- ( ! Namespace::isTalk( $ons ) ) &&
- ( ! Namespace::isTalk( $nns ) ) ) {
-
- # get old talk page namespace
- $ons = Namespace::getTalk( $ons );
- # get new talk page namespace
- $nns = Namespace::getTalk( $nns );
-
- # make talk page title objects
- $ott = Title::makeTitle( $ons, $ot->getDBkey() );
- $ntt = Title::makeTitle( $nns, $nt->getDBkey() );
-
- # Attempt the move
- $error = $ott->moveTo( $ntt );
- if ( $error === true ) {
- $talkmoved = 1;
+
+ wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ot , &$nt ) ) ;
+
+ # Move the talk page if relevant, if it exists, and if we've been told to
+ $ott = $ot->getTalkPage();
+ if( $ott->exists() ) {
+ if( $this->moveTalk && !$ot->isTalkPage() && !$nt->isTalkPage() ) {
+ $ntt = $nt->getTalkPage();
+
+ # Attempt the move
+ $error = $ott->moveTo( $ntt, true, $this->reason );
+ if ( $error === true ) {
+ $talkmoved = 1;
+ wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ott , &$ntt ) ) ;
+ } else {
+ $talkmoved = $error;
+ }