Always return an array if an error has occurred in Title::moveTo.
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 30 May 2008 19:59:47 +0000 (19:59 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 30 May 2008 19:59:47 +0000 (19:59 +0000)
includes/SpecialMovepage.php
includes/Status.php
includes/Title.php
includes/api/ApiMove.php

index 3188a85..faad593 100644 (file)
@@ -273,12 +273,8 @@ class MovePageForm {
 
                $error = $ot->moveTo( $nt, true, $this->reason );
                if ( $error !== true ) {
-                       # FIXME: moveTo() can return a string
-                       if(is_array($error))
-                               # FIXME: showForm() should handle multiple errors
-                               call_user_func_array(array($this, 'showForm'), $error[0]);
-                       else
-                               $this->showForm($error);
+                       # FIXME: showForm() should handle multiple errors
+                       call_user_func_array(array($this, 'showForm'), $error[0]);
                        return;
                }
 
index 98602cf..ed1455c 100644 (file)
@@ -170,4 +170,13 @@ class Status {
                $this->successCount += $other->successCount;
                $this->failCount += $other->failCount;
        }
+       
+       function getErrorsArray() {
+               $result = array();
+               foreach ( $this->errors as $error ) {
+                       if ( $error['type'] == 'error' )
+                               $result[] = $error['message'];
+               }
+               return $result;
+       }
 }
index f7116cc..a9fff64 100644 (file)
@@ -2479,7 +2479,7 @@ class Title {
         */
        public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true ) {
                $err = $this->isValidMoveOperation( $nt, $auth );
-               if( is_array($err) ) {
+               if( is_array( $err ) ) {
                        return $err;
                }
 
@@ -2491,9 +2491,8 @@ class Title {
                        $err = $this->moveToNewTitle( $nt, $reason, $createRedirect );
                        $pageCountChange = ($createRedirect ? 1 : 0);
                }
-               # FIXME: moveToNewTitle() and moveOverExistingRedirect() return
-               #        wikitext if a file move goes bad
-               if( is_string( $err ) ) {
+
+               if( is_array( $err ) ) {
                        return $err;
                }
                $redirid = $this->getArticleID();
@@ -2668,7 +2667,7 @@ class Title {
                                $status = $file->move( $nt );
                                if( !$status->isOk() ) {
                                        $dbw->rollback();
-                                       return $status->getWikiText();
+                                       return $status->getErrorsArray();
                                }
                        }
                }
@@ -2684,6 +2683,7 @@ class Title {
                        $u = new SquidUpdate( $urls );
                        $u->doUpdate();
                }
+               
        }
 
        /**
@@ -2761,7 +2761,7 @@ class Title {
                                $status = $file->move( $nt );
                                if( !$status->isOk() ) {
                                        $dbw->rollback();
-                                       return $status->getWikiText();
+                                       return $status->getErrorsArray();
                                }
                        }
                }
@@ -2777,6 +2777,7 @@ class Title {
                # Purge old title from squid
                # The new title, and links to the new title, are purged in Article::onArticleCreate()
                $this->purgeSquid();
+               
        }
 
        /**
index 3d22cfc..a3801bf 100644 (file)
@@ -85,10 +85,7 @@ class ApiMove extends ApiBase {
                if($retval !== true)
                {
                        # FIXME: Title::moveTo() sometimes returns a string
-                       if(is_array($retval))
-                               $this->dieUsageMsg(reset($retval));
-                       else
-                               $this->dieUsageMsg(array('unknownerror', $error));
+                       $this->dieUsageMsg(reset($retval));
                }
 
                $r = array('from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason']);