Merge "Update Parser to use NamespaceInfo"
[lhc/web/wiklou.git] / includes / MovePage.php
index 7d27a27..24178ac 100644 (file)
@@ -21,6 +21,7 @@
 
 use MediaWiki\MediaWikiServices;
 use MediaWiki\Revision\SlotRecord;
+use Wikimedia\Rdbms\IDatabase;
 
 /**
  * Handles the backend logic of moving a page from one title
@@ -105,7 +106,7 @@ class MovePage {
 
                $oldid = $this->oldTitle->getArticleID();
 
-               if ( strlen( $this->newTitle->getDBkey() ) < 1 ) {
+               if ( $this->newTitle->getDBkey() === '' ) {
                        $status->fatal( 'articleexists' );
                }
                if (
@@ -250,7 +251,7 @@ class MovePage {
                }
 
                $dbw = wfGetDB( DB_MASTER );
-               $dbw->startAtomic( __METHOD__ );
+               $dbw->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
 
                Hooks::run( 'TitleMoveStarting', [ $this->oldTitle, $this->newTitle, $user ] );
 
@@ -271,7 +272,8 @@ class MovePage {
                        [ 'cl_from' => $pageid ],
                        __METHOD__
                );
-               $type = MWNamespace::getCategoryLinkType( $this->newTitle->getNamespace() );
+               $type = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       getCategoryLinkType( $this->newTitle->getNamespace() );
                foreach ( $prefixes as $prefixRow ) {
                        $prefix = $prefixRow->cl_sortkey_prefix;
                        $catTo = $prefixRow->cl_to;
@@ -425,9 +427,9 @@ class MovePage {
         * Move a file associated with a page to a new location.
         * Can also be used to revert after a DB failure.
         *
-        * @access private
-        * @param Title Old location to move the file from.
-        * @param Title New location to move the file to.
+        * @private
+        * @param Title $oldTitle Old location to move the file from.
+        * @param Title $newTitle New location to move the file to.
         * @return Status
         */
        private function moveFile( $oldTitle, $newTitle ) {
@@ -493,7 +495,8 @@ class MovePage {
                        );
 
                        if ( !$status->isGood() ) {
-                               throw new MWException( 'Failed to delete page-move revision: ' . $status );
+                               throw new MWException( 'Failed to delete page-move revision: '
+                                       . $status->getWikiText( false, false, 'en' ) );
                        }
 
                        $nt->resetArticleID( false );