Merge "Fully replace Title::moveTo() with MovePage"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 30 Oct 2014 20:06:27 +0000 (20:06 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 30 Oct 2014 20:06:27 +0000 (20:06 +0000)
1  2 
RELEASE-NOTES-1.25
includes/api/ApiMove.php

diff --combined RELEASE-NOTES-1.25
@@@ -42,14 -42,22 +42,24 @@@ production
      https://www.mediawiki.org/wiki/Manual:Skinning#Page_status_indicators
  * Edit tokens may now be time-limited: passing a maximum age to
    User::matchEditToken will reject any older tokens.
 +* The debug logging internals have been overhauled, and are now using the
 +  PSR-3 interfaces.
  
  === Bug fixes in 1.25 ===
  * (bug 71003) No additional code will be generated to try to load CSS-embedded
    SVG images in Internet Explorer 6 and 7, as they don't support them anyway.
  * (bug 67021) On Special:BookSources, corrected validation of ISBNs (both
    10- and 13-digit forms) containing "X".
+ * Page moving was refactored into a MovePage class. As part of that:
+ ** The AbortMove hook was removed.
+ ** MovePageIsValidMove is for extensions to specify whether a page
+    cannot be moved for technical reasons, and should not be overriden.
+ ** MovePageCheckPermissions is for checking whether the given user is
+    allowed to make the move.
+ ** Title::moveNoAuth() was deprecated. Use the MovePage class instead.
+ ** Title::moveTo() was deprecated. Use the MovePage class instead.
+ ** Title::isValidMoveOperation() broken down into MovePage::isValidMove()
+    and MovePage::checkPermissions().
  
  === Action API changes in 1.25 ===
  * (bug 65403) XML tag highlighting is now only performed for formats
@@@ -149,7 -157,7 +159,7 @@@ changes to languages because of Bugzill
  
  == Compatibility ==
  
 -MediaWiki 1.25 requires PHP 5.3.2 or later. There is experimental support for
 +MediaWiki 1.25 requires PHP 5.3.3 or later. There is experimental support for
  HHVM 3.3.0.
  
  MySQL is the recommended DBMS. PostgreSQL or SQLite can also be used, but
diff --combined includes/api/ApiMove.php
@@@ -72,9 -72,9 +72,9 @@@ class ApiMove extends ApiBase 
  
                // Move the page
                $toTitleExists = $toTitle->exists();
-               $retval = $fromTitle->moveTo( $toTitle, true, $params['reason'], !$params['noredirect'] );
-               if ( $retval !== true ) {
-                       $this->dieUsageMsg( reset( $retval ) );
+               $status = $this->movePage( $fromTitle, $toTitle, $params['reason'], !$params['noredirect'] );
+               if ( !$status->isOK() ) {
+                       $this->dieStatus( $status );
                }
  
                $r = array(
@@@ -99,8 -99,8 +99,8 @@@
                // Move the talk page
                if ( $params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage() ) {
                        $toTalkExists = $toTalk->exists();
-                       $retval = $fromTalk->moveTo( $toTalk, true, $params['reason'], !$params['noredirect'] );
-                       if ( $retval === true ) {
+                       $status = $this->movePage( $fromTalk, $toTalk, $params['reason'], !$params['noredirect'] );
+                       if ( $status->isOK() ) {
                                $r['talkfrom'] = $fromTalk->getPrefixedText();
                                $r['talkto'] = $toTalk->getPrefixedText();
                                if ( $toTalkExists ) {
                                }
                        } else {
                                // We're not gonna dieUsage() on failure, since we already changed something
-                               $parsed = $this->parseMsg( reset( $retval ) );
-                               $r['talkmove-error-code'] = $parsed['code'];
-                               $r['talkmove-error-info'] = $parsed['info'];
+                               $error = $this->getErrorFromStatus( $status );
+                               $r['talkmove-error-code'] = $error[0];
+                               $r['talkmove-error-info'] = $error[1];
                        }
                }
  
                $result->addValue( null, $this->getModuleName(), $r );
        }
  
+       /**
+        * @param Title $from
+        * @param Title $to
+        * @param string $reason
+        * @param bool $createRedirect
+        * @return Status
+        */
+       protected function movePage( Title $from, Title $to, $reason, $createRedirect ) {
+               $mp = new MovePage( $from, $to );
+               $valid = $mp->isValidMove();
+               if ( !$valid->isOK() ) {
+                       return $valid;
+               }
+               $permStatus = $mp->checkPermissions( $this->getUser(), $reason );
+               if ( !$permStatus->isOK() ) {
+                       return $permStatus;
+               }
+               return $mp->move( $this->getUser(), $reason, $createRedirect );
+       }
        /**
         * @param Title $fromTitle
         * @param Title $toTitle
                return 'csrf';
        }
  
 -      public function getExamplesMessages() {
 +      protected function getExamplesMessages() {
                return array(
                        'action=move&from=Badtitle&to=Goodtitle&token=123ABC&' .
                                'reason=Misspelled%20title&movetalk=&noredirect='