Merge "Restore messages of old login and signup forms"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 20 Jun 2013 05:53:59 +0000 (05:53 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 20 Jun 2013 05:53:59 +0000 (05:53 +0000)
includes/Export.php
includes/WikiPage.php
includes/search/SearchEngine.php
includes/search/SearchUpdate.php
includes/specials/SpecialUserrights.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/Maintenance.php
maintenance/language/messages.inc
maintenance/rebuildtextindex.php

index a26e853..98de4c0 100644 (file)
@@ -824,10 +824,13 @@ class XmlDumpWriter {
                        $archiveName = '';
                }
                if ( $dumpContents ) {
+                       $be = $file->getRepo()->getBackend();
                        # Dump file as base64
                        # Uses only XML-safe characters, so does not need escaping
+                       # @TODO: too bad this loads the contents into memory (script might swap)
                        $contents = '      <contents encoding="base64">' .
-                               chunk_split( base64_encode( file_get_contents( $file->getPath() ) ) ) .
+                               chunk_split( base64_encode(
+                                       $be->getFileContents( array( 'src' => $file->getPath() ) ) ) ) .
                                "      </contents>\n";
                } else {
                        $contents = '';
index 9e6a0c8..398a424 100644 (file)
@@ -2109,8 +2109,7 @@ class WikiPage implements Page, IDBAccessObject {
                }
 
                DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, $good, $total ) );
-               DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content->getTextForSearchIndex() ) );
-               // @todo let the search engine decide what to do with the content object
+               DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content ) );
 
                // If this is another user's talk page, update newtalk.
                // Don't do this if $options['changed'] = false (null-edits) nor if
index 00f7923..bbd8886 100644 (file)
@@ -816,7 +816,8 @@ class SearchResult {
                if ( !isset( $this->mText ) ) {
                        if ( $this->mRevision != null ) {
                                //TODO: if we could plug in some code that knows about special content models *and* about
-                               //      special features of the search engine, the search could benefit.
+                               //      special features of the search engine, the search could benefit. See similar
+                               //      comment in SearchUpdate's constructor
                                $content = $this->mRevision->getContent();
                                $this->mText = $content ? $content->getTextForSearchIndex() : '';
                        } else { // TODO: can we fetch raw wikitext for commons images?
index e2155ad..6e9c9c5 100644 (file)
@@ -33,7 +33,16 @@ class SearchUpdate implements DeferrableUpdate {
        private $mId = 0, $mNamespace, $mTitle, $mText;
        private $mTitleWords;
 
-       public function __construct( $id, $title, $text = false ) {
+       /**
+        * Constructor
+        *
+        * @param int $id Page id to update
+        * @param Title|string $title Title of page to update
+        * @param Content|string|false $content Content of the page to update.
+        *  If a Content object, text will be gotten from it. String is for back-compat.
+        *  Passing false tells the backend to just update the title, not the content
+        */
+       public function __construct( $id, $title, $content = false ) {
                if ( is_string( $title ) ) {
                        $nt = Title::newFromText( $title );
                } else {
@@ -42,7 +51,14 @@ class SearchUpdate implements DeferrableUpdate {
 
                if ( $nt ) {
                        $this->mId = $id;
-                       $this->mText = $text;
+                       // @todo This isn't ideal, we'd really like to have content-specific
+                       // handling here. See similar content in SearchEngine::initText().
+                       if( is_string( $content ) ) {
+                               // b/c for ApprovedRevs
+                               $this->mText = $content;
+                       } else {
+                               $this->mText = $content ? $content->getTextForSearchIndex() : false;
+                       }
 
                        $this->mNamespace = $nt->getNamespace();
                        $this->mTitle = $nt->getText(); # Discard namespace
index f23bc2d..8b24372 100644 (file)
@@ -110,6 +110,17 @@ class UserrightsPage extends SpecialPage {
                }
 
                if ( !$this->userCanChangeRights( $user, true ) ) {
+                       if ( $this->isself && $request->getCheck( 'success' ) ) {
+                               // bug 48609: if the user just removed its own rights, this would
+                               // leads it in a "permissions error" page. In that case, show a
+                               // message that it can't anymore use this page instead of an error
+                               $this->setHeaders();
+                               $out = $this->getOutput();
+                               $out->wrapWikiMsg( "<div class=\"successbox\">\n$1\n</div>", 'userrights-removed-self' );
+                               $out->returnToMain();
+                               return;
+                       }
+
                        // @todo FIXME: There may be intermediate groups we can mention.
                        $msg = $user->isAnon() ? 'userrights-nologin' : 'userrights-notallowed';
                        throw new PermissionsError( null, array( array( $msg ) ) );
@@ -163,7 +174,7 @@ class UserrightsPage extends SpecialPage {
        }
 
        function getSuccessURL() {
-               return $this->getTitle( $this->mTarget )->getFullURL();
+               return $this->getTitle( $this->mTarget )->getFullURL( array( 'success' => 1 ) );
        }
 
        /**
index 2992dea..b2b3a92 100644 (file)
@@ -2022,6 +2022,7 @@ Your email address is not revealed when other users contact you.',
 'userrights-unchangeable-col'    => 'Groups you cannot change',
 'userrights-irreversible-marker' => '$1*', # only translate this message to other languages if you have to change it
 'userrights-conflict'            => 'User rights conflict! Please apply your changes again.',
+'userrights-removed-self'        => 'You successfully removed your own rights. As such, you are no longer able to access this page.',
 
 # Groups
 'group'               => 'Group:',
index 518efb6..86ef3c2 100644 (file)
@@ -2749,6 +2749,7 @@ Parameters:
 * $1 - optional, for PLURAL use, the number of items in the column following the message. Avoid PLURAL, if your language allows that.',
 'userrights-irreversible-marker' => '{{optional}}',
 'userrights-conflict' => "Shown on [[Special:UserRights]] if the target's rights have been changed since the form was loaded.",
+'userrights-removed-self' => "Shown on [[Special:UserRights]] in a green box after the user removed its own rights to access that page.",
 
 # Groups
 'group' => '{{Identical|Group}}',
index a2bbec5..e29ffd9 100644 (file)
@@ -1155,8 +1155,7 @@ abstract class Maintenance {
                        $title = $titleObj->getPrefixedDBkey();
                        $this->output( "$title..." );
                        # Update searchindex
-                       # TODO: pass the Content object to SearchUpdate, let the search engine decide how to deal with it.
-                       $u = new SearchUpdate( $pageId, $titleObj->getText(), $rev->getContent()->getTextForSearchIndex() );
+                       $u = new SearchUpdate( $pageId, $titleObj->getText(), $rev->getContent() );
                        $u->doUpdate();
                        $this->output( "\n" );
                }
index c226ce8..28c3e81 100644 (file)
@@ -1147,6 +1147,7 @@ $wgMessageStructure = array(
                'userrights-unchangeable-col',
                'userrights-irreversible-marker',
                'userrights-conflict',
+               'userrights-removed-self',
        ),
        'group' => array(
                'group',
index a31aba2..c651f72 100644 (file)
@@ -115,9 +115,8 @@ class RebuildTextIndex extends Maintenance {
 
                                        $rev = new Revision( $s );
                                        $content = $rev->getContent();
-                                       $text = $content->getTextForSearchIndex();
 
-                                       $u = new SearchUpdate( $s->page_id, $title, $text );
+                                       $u = new SearchUpdate( $s->page_id, $title, $content );
                                        $u->doUpdate();
                                } catch ( MWContentSerializationException $ex ) {
                                        $this->output( "Failed to deserialize content of revision {$s->rev_id} of page "