Follow-up r84814: revert redundant summary message addition.
[lhc/web/wiklou.git] / includes / Title.php
index 060630c..4f0000b 100644 (file)
@@ -892,21 +892,29 @@ class Title {
                                        $url = str_replace( '$1', $dbkey, $wgArticlePath );
                                }
                        } else {
-                               $url = false;
-
                                global $wgActionPaths;
-                               if( !empty( $wgActionPaths ) ) {
-                                       $url = Title::resolveActionPath( $dbkey, $query );
+                               $url = false;
+                               $matches = array();
+                               if ( !empty( $wgActionPaths ) &&
+                                       preg_match( '/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches ) )
+                               {
+                                       $action = urldecode( $matches[2] );
+                                       if ( isset( $wgActionPaths[$action] ) ) {
+                                               $query = $matches[1];
+                                               if ( isset( $matches[4] ) ) {
+                                                       $query .= $matches[4];
+                                               }
+                                               $url = str_replace( '$1', $dbkey, $wgActionPaths[$action] );
+                                               if ( $query != '' ) {
+                                                       $url = wfAppendQuery( $url, $query );
+                                               }
+                                       }
                                }
-
                                if ( $url === false ) {
                                        if ( $query == '-' ) {
                                                $query = '';
                                        }
-                                       #$url = "{$wgScript}?title={$dbkey}&{$query}";
-                                       # forge a nice URL (ex: /wiki/Special:Foo?q=1&r=2 )
-                                       $baseurl = str_replace( '$1', $dbkey, $wgArticlePath );
-                                       $url = wfAppendQuery( $baseurl, $query );
+                                       $url = "{$wgScript}?title={$dbkey}&{$query}";
                                }
                        }
 
@@ -920,38 +928,6 @@ class Title {
                return $url;
        }
 
-       /**
-        * Helper for getLocalUrl() to handles $wgActionPaths
-        *
-        * @param $dbkey string Title in database key format
-        * @param $query string request parameters in CGI format (p=1&q=2&..)
-        * @return Url resolved or boolean false
-        */
-       private static function resolveActionPath( $dbkey, $query ) {
-               $url = '';
-
-               # query parameters are easier to handle using an array:
-               $queryArray = wfCGIToArray( $query );
-
-               global $wgActionPaths;
-               if( !array_key_exists( 'action', $queryArray ) ) {
-                       // Makes the default action 'view' and points to $wgArticlePath
-                       // FIXME: this should be handled in Setup or Wiki!
-                       global $wgArticlePath;
-                       $url = str_replace( '$1', $dbkey, $wgArticlePath );
-               } elseif( isset( $wgActionPaths[$queryArray['action']] ) ) {
-                       $url = str_replace( '$1', $dbkey, $wgActionPaths[$queryArray['action']] );
-               } else {
-                       # No path found
-                       return false;
-               }
-
-               # No need to append the action since we have embed it in the path
-               unset( $queryArray['action'] );
-               $url = wfAppendQuery( $url, wfArrayToCGI( $queryArray ) );
-               return $url;
-       }
-
        /**
         * Get a URL that's the simplest URL that will be valid to link, locally,
         * to the current Title.  It includes the fragment, but does not include
@@ -1586,7 +1562,7 @@ class Title {
                        }
 
                        $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
-                       $blockid = $block->mId;
+                       $blockid = $block->getId();
                        $blockExpiry = $user->mBlock->mExpiry;
                        $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $user->mBlock->mTimestamp ), true );
                        if ( $blockExpiry == 'infinity' ) {
@@ -1595,7 +1571,7 @@ class Title {
                                $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
                        }
 
-                       $intended = $user->mBlock->mAddress;
+                       $intended = $user->mBlock->getTarget();
 
                        $errors[] = array( ( $block->mAuto ? 'autoblockedtext' : 'blockedtext' ), $link, $reason, $ip, $name,
                                $blockid, $blockExpiry, $intended, $blockTimestamp );
@@ -3078,7 +3054,7 @@ class Title {
                }
 
                $destFile = wfLocalFile( $nt );
-               if ( !$wgUser->isAllowed( 'reupload-shared' ) && !$destfile->exists() && wfFindFile( $nt ) ) {
+               if ( !$wgUser->isAllowed( 'reupload-shared' ) && !$destFile->exists() && wfFindFile( $nt ) ) {
                        $errors[] = array( 'file-exists-sharedrepo' );
                }
 
@@ -3115,13 +3091,16 @@ class Title {
                        }
                }
 
-               $pageid = $this->getArticleID();
+               $dbw->begin(); # If $file was a LocalFile, its transaction would have closed our own.
+               $pageid = $this->getArticleID( GAID_FOR_UPDATE );
                $protected = $this->isProtected();
                $pageCountChange = ( $createRedirect ? 1 : 0 ) - ( $nt->exists() ? 1 : 0 );
 
                // Do the actual move
                $err = $this->moveToInternal( $nt, $reason, $createRedirect );
                if ( is_array( $err ) ) {
+                       # FIXME: What about the File we have already moved?
+                       $dbw->rollback();
                        return $err;
                }
 
@@ -3190,6 +3169,8 @@ class Title {
                $u = new SearchUpdate( $redirid, $this->getPrefixedDBkey(), '' );
                $u->doUpdate();
 
+               $dbw->commit();
+               
                # Update site_stats
                if ( $this->isContentPage() && !$nt->isContentPage() ) {
                        # No longer a content page
@@ -3250,8 +3231,8 @@ class Title {
                if ( $reason ) {
                        $comment .= wfMsgForContent( 'colon-separator' ) . $reason;
                }
-               # Truncate for whole multibyte characters. +5 bytes for ellipsis
-               $comment = $wgContLang->truncate( $comment, 250 );
+               # Truncate for whole multibyte characters.
+               $comment = $wgContLang->truncate( $comment, 255 );
 
                $oldid = $this->getArticleID();
                $latest = $this->getLatestRevID();
@@ -3344,7 +3325,7 @@ class Title {
                        $redirectSuppressed = false;
                } else {
                        // Get rid of old new page entries in Special:NewPages and RC.
-                       // Needs to be before $this->resetArticleUD( 0 ).
+                       // Needs to be before $this->resetArticleID( 0 ).
                        $dbw->delete( 'recentchanges', array(
                                        'rc_timestamp' => $dbw->timestamp( $this->getEarliestRevTime() ),
                                        'rc_namespace' => $oldns,