merged master
authordaniel <daniel.kinzler@wikimedia.de>
Thu, 2 Aug 2012 09:01:22 +0000 (11:01 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Thu, 2 Aug 2012 09:01:22 +0000 (11:01 +0200)
Change-Id: I6afafe971afb3f38fc8f1e66ba409283b8a698f8

15 files changed:
1  2 
RELEASE-NOTES-1.20
includes/Article.php
includes/AutoLoader.php
includes/DefaultSettings.php
includes/Defines.php
includes/ImagePage.php
includes/OutputPage.php
includes/WikiPage.php
includes/diff/DifferenceEngine.php
includes/installer/OracleUpdater.php
includes/parser/Parser.php
languages/Language.php
languages/LanguageConverter.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php

diff --combined RELEASE-NOTES-1.20
@@@ -32,6 -32,8 +32,8 @@@ upgrade PHP if you have not done so pri
    certain namespace can be moved.
  * Added SpecialPageBeforeExecute hook which gets called before SpecialPage::execute.
  * Added SpecialPageAfterExecute hook which gets called after SpecialPage::execute.
+ * Added ORMTable, ORMRow and ORMResult classes for additional abstraction of
+   database interaction.
  * (bug 32341) Add upload by URL domain limitation.
  * &useskin=default will now always display the default skin. Useful for users with a
    preference for the non-default skin to look at something using the default skin.
@@@ -61,7 -63,7 +63,7 @@@
    Special:Version
  * Edit notices can now be translated.
  * (bug 35680) jQuery upgraded to 1.7.2.
- * jQuery UI upgraded to 1.8.21.
+ * jQuery UI upgraded to 1.8.22.
  * (bug 35705) QUnit upgraded from v1.2.0 to v1.8.0.
  * (bug 37604) jquery.cookie upgraded to 2011 version.
  * (bug 22887) Add warning and tracking category for preprocessor errors
@@@ -82,8 -84,6 +84,8 @@@
  * Added new function getDomain to AuthPlugin for getting a user's domain
  * (bug 23427) New magic word {{PAGEID}} which gives the current page ID.
    Will be null on previewing a page being created.
 +* Added new hook AfterFinalPageOutput to allow modifications to buffered page output before sent
 +  to the client.
  * (bug 37627) UserNotLoggedIn() exception to show a generic error page whenever
    a user is not logged in.
  * Watched status in changes lists are no longer indicated by <strong></strong>
    instead of the site content language
  * (bug 37926) Deleterevision will no longer allow users to delete log entries,
    the new deletelogentry permission is required for this.
+ * (bug 14237) Allow PAGESINCATEGORY to distinguish between 'all', 'pages', 'files'
+   and 'subcats'
+ * (bug 38362) Make Special:Listuser includeable on wiki pages.
+ * Added support in jquery.localize for placeholder attributes.
+ * (bug 38151) Implemented mw.user.getRights for getting and caching the current
+   user's user rights.
+ * Implemented mw.user.getGroups for getting and caching user groups.
+ * (bug 37830) Added $wgRequirePasswordforEmailChange to control whether password
+   confirmation is required for changing an email address or not.
  
  === Bug fixes in 1.20 ===
  * (bug 30245) Use the correct way to construct a log page title.
    who don't have access to /tmp can specify an alternative.
  * (bug 27283) SqlBagOStuff breaks PostgreSQL transactions.
  * (bug 35727) mw.Api ajax() should put token parameter last.
- * (bug 260) Handle <pre> overflow automatically with a scroll bar.
  * (bug 37708) mw.Uri.clone() should make a deep copy.
  * (bug 38024) ResourceLoader should not create empty stylesheets for modules
    that don't have stylesheets.
    values are used instead of just the fixed values from when the tablesorter
    was initialized.
  * (bug 38093) Gender of changed user groups missing in Special:Log/rights
+ * (bug 35893) Special:Block needs to load mediawiki.special.block.js.
+ * (bug 37331) ResourceLoader modules sometimes execute twice in Firefox
+ * (bug 31644) GlobalUsage, CentralAuth and AbuseLog extensions should not use
+   insecure links to foreign wikis in the WikiMap.
+ * (bug 36073) Avoid duplicate element IDs on File pages
  
  === API changes in 1.20 ===
  * (bug 34316) Add ability to retrieve maximum upload size from MediaWiki API.
  * (bug 36987) API avoids mangling fields in continuation parameters
  * (bug 30836) siteinfo prop=specialpagealiases will no longer return nonexistent special pages
  * (bug 38190) Add "required" flag to some token params for hint in api docs.
+ * (bug 27567) Add file repo support to prop=duplicatefiles.
+ * (bug 27610) Add archivename for non-latest image version to list=filearchive
  
  === Languages updated in 1.20 ===
  
@@@ -215,6 -230,8 +232,8 @@@ changes to languages because of Bugzill
  * (bug 35541) Namespace gender aliases for Croatian (hr).
  * (bug 36012) Space in $separatorTransformTable should be non-breaking in
    Portuguese, Esperanto and Udmurt.
+ * Turoyo (tru) added.
+ * Cyrillic-Latin language converter added for Uzbek (uz).
  
  === Other changes in 1.20 ===
  * The user_token field is now left empty until a user attempts to login and
    and only applies to MyISAM or similar DBs. Those should only be used
    for archived sites anyway. We can't get edit conflicts on such sites,
    so the WikiPage code wasn't useful there either.
+ * Deprecated mw.user.name in favour of mw.user.getName.
+ * Deprecated mw.user.anonymous in favour of mw.user.isAnon.
  
  == Compatibility ==
  
diff --combined includes/Article.php
@@@ -57,17 -57,10 +57,17 @@@ class Article extends Page 
        public $mParserOptions;
  
        /**
 -       * Content of the revision we are working on
 +       * Text of the revision we are working on
         * @var string $mContent
         */
 -      var $mContent;                    // !<
 +      var $mContent;                    // !< #BC cruft
 +
 +      /**
 +       * Content of the revision we are working on
 +       * @var Content
 +       * @since 1.WD
 +       */
 +      var $mContentObject;              // !<
  
        /**
         * Is the content ($mContent) already loaded?
         * This function has side effects! Do not use this function if you
         * only want the real revision text if any.
         *
 +       * @deprecated in 1.WD; use getContentObject() instead
 +       *
         * @return string Return the text of this revision
         */
        public function getContent() {
 +              wfDeprecated( __METHOD__, '1.WD' );
 +              $content = $this->getContentObject();
 +              return ContentHandler::getContentText( $content );
 +      }
 +
 +      /**
 +       * Returns a Content object representing the pages effective display content,
 +       * not necessarily the revision's content!
 +       *
 +       * Note that getContent/loadContent do not follow redirects anymore.
 +       * If you need to fetch redirectable content easily, try
 +       * the shortcut in WikiPage::getRedirectTarget()
 +       *
 +       * This function has side effects! Do not use this function if you
 +       * only want the real revision text if any.
 +       *
 +       * @return Content Return the content of this revision
 +       *
 +       * @since 1.WD
 +       *
 +       * @todo: FIXME: this should really be protected, all callers should be changed to use WikiPage::getContent() instead.
 +       */
 +      public function getContentObject() {
 +              global $wgUser;
                wfProfileIn( __METHOD__ );
  
                if ( $this->mPage->getID() === 0 ) {
                                if ( $text === false ) {
                                        $text = '';
                                }
 +
 +                              $content = ContentHandler::makeContent( $text, $this->getTitle() );
                        } else {
 -                              $text = wfMsgExt( $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', 'parsemag' );
 +                              $content = new MessageContent( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', null, 'parsemag' );
                        }
                        wfProfileOut( __METHOD__ );
  
 -                      return $text;
 +                      return $content;
                } else {
 -                      $this->fetchContent();
 +                      $this->fetchContentObject();
                        wfProfileOut( __METHOD__ );
  
 -                      return $this->mContent;
 +                      return $this->mContentObject;
                }
        }
  
         * Get text of an article from database
         * Does *NOT* follow redirects.
         *
 +       * @protected
 +       * @note this is really internal functionality that should really NOT be used by other functions. For accessing
 +       *       article content, use the WikiPage class, especially WikiBase::getContent(). However, a lot of legacy code
 +       *       uses this method to retrieve page text from the database, so the function has to remain public for now.
 +       *
         * @return mixed string containing article contents, or false if null
 +       * @deprecated in 1.WD, use WikiPage::getContent() instead
         */
 -      function fetchContent() {
 -              if ( $this->mContentLoaded ) {
 +      function fetchContent() { #BC cruft!
 +              wfDeprecated( __METHOD__, '1.WD' );
 +
 +              if ( $this->mContentLoaded && $this->mContent ) {
                        return $this->mContent;
                }
  
                wfProfileIn( __METHOD__ );
  
 +              $content = $this->fetchContentObject();
 +
 +              $this->mContent = ContentHandler::getContentText( $content ); #@todo: get rid of mContent everywhere!
 +              wfRunHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) ); #BC cruft, deprecated!
 +
 +              wfProfileOut( __METHOD__ );
 +
 +              return $this->mContent;
 +      }
 +
 +
 +      /**
 +       * Get text content object
 +       * Does *NOT* follow redirects.
 +       * TODO: when is this null?
 +       *
 +       * @note code that wants to retrieve page content from the database should use WikiPage::getContent().
 +       *
 +       * @return Content|null
 +       *
 +       * @since 1.WD
 +       */
 +      protected function fetchContentObject() {
 +              if ( $this->mContentLoaded ) {
 +                      return $this->mContentObject;
 +              }
 +
 +              wfProfileIn( __METHOD__ );
 +
                $this->mContentLoaded = true;
 +              $this->mContent = null;
  
                $oldid = $this->getOldID();
  
                # fails we'll have something telling us what we intended.
                $t = $this->getTitle()->getPrefixedText();
                $d = $oldid ? wfMsgExt( 'missingarticle-rev', array( 'escape' ), $oldid ) : '';
 -              $this->mContent = wfMsgNoTrans( 'missing-article', $t, $d ) ;
 +              $this->mContentObject = new MessageContent( 'missing-article', array($t, $d), array() ) ; // @todo: this isn't page content but a UI message. horrible.
  
                if ( $oldid ) {
                        # $this->mRevision might already be fetched by getOldIDFromRequest()
                        }
  
                        $this->mRevision = $this->mPage->getRevision();
 +
                        if ( !$this->mRevision ) {
                                wfDebug( __METHOD__ . " failed to retrieve current page, rev_id " . $this->mPage->getLatest() . "\n" );
                                wfProfileOut( __METHOD__ );
  
                // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
                // We should instead work with the Revision object when we need it...
 -              $this->mContent = $this->mRevision->getText( Revision::FOR_THIS_USER ); // Loads if user is allowed
 +              $this->mContentObject = $this->mRevision->getContent( Revision::FOR_THIS_USER ); // Loads if user is allowed
                $this->mRevIdFetched = $this->mRevision->getId();
  
 -              wfRunHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) );
 +              wfRunHooks( 'ArticleAfterFetchContentObject', array( &$this, &$this->mContentObject ) );
  
                wfProfileOut( __METHOD__ );
  
 -              return $this->mContent;
 +              return $this->mContentObject;
        }
  
        /**
         * @return Revision|null
         */
        public function getRevisionFetched() {
 -              $this->fetchContent();
 +              $this->fetchContentObject();
  
                return $this->mRevision;
        }
                                        break;
                                case 3:
                                        # This will set $this->mRevision if needed
 -                                      $this->fetchContent();
 +                                      $this->fetchContentObject();
  
                                        # Are we looking at an old revision
                                        if ( $oldid && $this->mRevision ) {
                                                wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
                                                $this->showCssOrJsPage();
                                                $outputDone = true;
 -                                      } elseif( !wfRunHooks( 'ArticleViewCustom', array( $this->mContent, $this->getTitle(), $outputPage ) ) ) {
 +                                      } elseif( !wfRunHooks( 'ArticleContentViewCustom', array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
 +                                              # Allow extensions do their own custom view for certain pages
 +                                              $outputDone = true;
 +                                      } elseif( Hooks::isRegistered( 'ArticleViewCustom' ) && !wfRunHooks( 'ArticleViewCustom', array( $this->fetchContent(), $this->getTitle(), $outputPage ) ) ) { #FIXME: fetchContent() is deprecated!
                                                # Allow extensions do their own custom view for certain pages
                                                $outputDone = true;
                                        } else {
 -                                              $text = $this->getContent();
 -                                              $rt = Title::newFromRedirectArray( $text );
 +                                              $content = $this->getContentObject();
 +                                              $rt = $content->getRedirectChain();
                                                if ( $rt ) {
                                                        wfDebug( __METHOD__ . ": showing redirect=no page\n" );
                                                        # Viewing a redirect page (e.g. with parameter redirect=no)
                                                        $outputPage->addHTML( $this->viewRedirect( $rt ) );
                                                        # Parse just to get categories, displaytitle, etc.
 -                                                      $this->mParserOutput = $wgParser->parse( $text, $this->getTitle(), $parserOptions );
 +                                                      $this->mParserOutput = $content->getParserOutput( $this->getTitle(), $oldid, $parserOptions, false );
                                                        $outputPage->addParserOutputNoText( $this->mParserOutput );
                                                        $outputDone = true;
                                                }
                                        # Run the parse, protected by a pool counter
                                        wfDebug( __METHOD__ . ": doing uncached parse\n" );
  
 +                                      // @todo: shouldn't we be passing $this->getPage() to PoolWorkArticleView instead of plain $this?
                                        $poolArticleView = new PoolWorkArticleView( $this, $parserOptions,
 -                                              $this->getRevIdFetched(), $useParserCache, $this->getContent() );
 +                                              $this->getRevIdFetched(), $useParserCache, $this->getContentObject(), $this->getContext() );
  
                                        if ( !$poolArticleView->execute() ) {
                                                $error = $poolArticleView->getError();
                $unhide = $request->getInt( 'unhide' ) == 1;
                $oldid = $this->getOldID();
  
 -              $de = new DifferenceEngine( $this->getContext(), $oldid, $diff, $rcid, $purge, $unhide );
 +              $contentHandler = ContentHandler::getForTitle( $this->getTitle() );
 +              $de = $contentHandler->createDifferenceEngine( $this->getContext(), $oldid, $diff, $rcid, $purge, $unhide );
 +
                // DifferenceEngine directly fetched the revision:
                $this->mRevIdFetched = $de->mNewid;
                $de->showDiffPage( $diffOnly );
         * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these
         * page views.
         */
 -      protected function showCssOrJsPage() {
 -              $dir = $this->getContext()->getLanguage()->getDir();
 -              $lang = $this->getContext()->getLanguage()->getCode();
 +      protected function showCssOrJsPage( $showCacheHint = true ) {
 +              global $wgOut;
  
 -              $outputPage = $this->getContext()->getOutput();
 -              $outputPage->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
 -                      'clearyourcache' );
 +              if ( $showCacheHint ) {
 +                      $dir = $this->getContext()->getLanguage()->getDir();
 +                      $lang = $this->getContext()->getLanguage()->getCode();
 +
 +                      $wgOut->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
 +                              'clearyourcache' );
 +              }
  
                // Give hooks a chance to customise the output
 -              if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->getTitle(), $outputPage ) ) ) {
 -                      // Wrap the whole lot in a <pre> and don't parse
 -                      $m = array();
 -                      preg_match( '!\.(css|js)$!u', $this->getTitle()->getText(), $m );
 -                      $outputPage->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
 -                      $outputPage->addHTML( htmlspecialchars( $this->mContent ) );
 -                      $outputPage->addHTML( "\n</pre>\n" );
 +              if ( !Hooks::isRegistered('ShowRawCssJs') || wfRunHooks( 'ShowRawCssJs', array( $this->fetchContent(), $this->getTitle(), $wgOut ) ) ) { #FIXME: fetchContent() is deprecated
 +                      $po = $this->mContentObject->getParserOutput( $this->getTitle() );
 +                      $wgOut->addHTML( $po->getText() );
                }
        }
  
                        "<div class='patrollink'>" .
                                wfMsgHtml(
                                        'markaspatrolledlink',
-                                       Linker::link(
+                                       Linker::linkKnown(
                                                $this->getTitle(),
                                                wfMsgHtml( 'markaspatrolledtext' ),
                                                array(),
                                                        'action' => 'markpatrolled',
                                                        'rcid' => $rcid,
                                                        'token' => $token,
-                                               ),
-                                               array( 'known', 'noclasses' )
+                                               )
                                        )
                                ) .
                        '</div>'
                }
  
                $outputPage = $this->getContext()->getOutput();
+               $user = $this->getContext()->getUser();
                // If the user is not allowed to see it...
-               if ( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) {
+               if ( !$this->mRevision->userCan( Revision::DELETED_TEXT, $user ) ) {
                        $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
                                'rev-deleted-text-permission' );
  
  
                $lnk = $current
                        ? wfMsgHtml( 'currentrevisionlink' )
-                       : Linker::link(
+                       : Linker::linkKnown(
                                $this->getTitle(),
                                wfMsgHtml( 'currentrevisionlink' ),
                                array(),
-                               $extraParams,
-                               array( 'known', 'noclasses' )
+                               $extraParams
                        );
                $curdiff = $current
                        ? wfMsgHtml( 'diff' )
-                       : Linker::link(
+                       : Linker::linkKnown(
                                $this->getTitle(),
                                wfMsgHtml( 'diff' ),
                                array(),
                                array(
                                        'diff' => 'cur',
                                        'oldid' => $oldid
-                               ) + $extraParams,
-                               array( 'known', 'noclasses' )
+                               ) + $extraParams
                        );
                $prev = $this->getTitle()->getPreviousRevisionID( $oldid ) ;
                $prevlink = $prev
-                       ? Linker::link(
+                       ? Linker::linkKnown(
                                $this->getTitle(),
                                wfMsgHtml( 'previousrevision' ),
                                array(),
                                array(
                                        'direction' => 'prev',
                                        'oldid' => $oldid
-                               ) + $extraParams,
-                               array( 'known', 'noclasses' )
+                               ) + $extraParams
                        )
                        : wfMsgHtml( 'previousrevision' );
                $prevdiff = $prev
-                       ? Linker::link(
+                       ? Linker::linkKnown(
                                $this->getTitle(),
                                wfMsgHtml( 'diff' ),
                                array(),
                                array(
                                        'diff' => 'prev',
                                        'oldid' => $oldid
-                               ) + $extraParams,
-                               array( 'known', 'noclasses' )
+                               ) + $extraParams
                        )
                        : wfMsgHtml( 'diff' );
                $nextlink = $current
                        ? wfMsgHtml( 'nextrevision' )
-                       : Linker::link(
+                       : Linker::linkKnown(
                                $this->getTitle(),
                                wfMsgHtml( 'nextrevision' ),
                                array(),
                                array(
                                        'direction' => 'next',
                                        'oldid' => $oldid
-                               ) + $extraParams,
-                               array( 'known', 'noclasses' )
+                               ) + $extraParams
                        );
                $nextdiff = $current
                        ? wfMsgHtml( 'diff' )
-                       : Linker::link(
+                       : Linker::linkKnown(
                                $this->getTitle(),
                                wfMsgHtml( 'diff' ),
                                array(),
                                array(
                                        'diff' => 'next',
                                        'oldid' => $oldid
-                               ) + $extraParams,
-                               array( 'known', 'noclasses' )
+                               ) + $extraParams
                        );
  
                $cdel = Linker::getRevDeleteLink( $user, $revision, $this->getTitle() );
                }
  
                # Better double-check that it hasn't been deleted yet!
-               $dbw = wfGetDB( DB_MASTER );
-               $conds = $title->pageCond();
-               $latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ );
-               if ( $latest === false ) {
+               $this->mPage->loadPageData( 'fromdbmaster' );
+               if ( !$this->mPage->exists() ) {
                        $outputPage = $this->getContext()->getOutput();
                        $outputPage->setPageTitle( wfMessage( 'cannotdelete-title', $title->getPrefixedText() ) );
                        $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
                // Generate deletion reason
                $hasHistory = false;
                if ( !$reason ) {
 -                      $reason = $this->generateReason( $hasHistory );
 +                      try {
 +                              $reason = $this->generateReason( $hasHistory );
 +                      } catch (MWException $e) {
 +                              # if a page is horribly broken, we still want to be able to delete it. so be lenient about errors here.
 +                              wfDebug("Error while building auto delete summary: $e");
 +                              $reason = '';
 +                      }
                }
  
                // If the page has a history, insert a warning
         * @return mixed
         */
        public function generateReason( &$hasHistory ) {
 -              return $this->mPage->getAutoDeleteReason( $hasHistory );
 +              $title = $this->mPage->getTitle();
 +              $handler = ContentHandler::getForTitle( $title );
 +              return $handler->getAutoDeleteReason( $title, $hasHistory );
        }
  
        // ****** B/C functions for static methods ( __callStatic is PHP>=5.3 ) ****** //
         * @param $newtext
         * @param $flags
         * @return string
 +       * @deprecated since 1.WD, use ContentHandler::getAutosummary() instead
         */
        public static function getAutosummary( $oldtext, $newtext, $flags ) {
                return WikiPage::getAutosummary( $oldtext, $newtext, $flags );
diff --combined includes/AutoLoader.php
@@@ -256,6 -256,7 +256,7 @@@ $wgAutoloadLocalClasses = array
        'UserArray' => 'includes/UserArray.php',
        'UserArrayFromResult' => 'includes/UserArray.php',
        'UserBlockedError' => 'includes/Exception.php',
+       'UserNotLoggedIn' => 'includes/Exception.php',
        'UserMailer' => 'includes/UserMailer.php',
        'UserRightsProxy' => 'includes/UserRightsProxy.php',
        'ViewCountUpdate' => 'includes/ViewCountUpdate.php',
        'ZipDirectoryReader' => 'includes/ZipDirectoryReader.php',
        'ZipDirectoryReaderError' => 'includes/ZipDirectoryReader.php',
  
 +      # content handler
 +      'Content' => 'includes/Content.php',
 +      'AbstractContent' => 'includes/Content.php',
 +      'ContentHandler' => 'includes/ContentHandler.php',
 +      'CssContent' => 'includes/Content.php',
 +      'CssContentHandler' => 'includes/ContentHandler.php',
 +      'JavaScriptContent' => 'includes/Content.php',
 +      'JavaScriptContentHandler' => 'includes/ContentHandler.php',
 +      'MessageContent' => 'includes/Content.php',
 +      'TextContent' => 'includes/Content.php',
 +      'WikitextContent' => 'includes/Content.php',
 +      'WikitextContentHandler' => 'includes/ContentHandler.php',
 +
        # includes/actions
        'CachedAction' => 'includes/actions/CachedAction.php',
        'CreditsAction' => 'includes/actions/CreditsAction.php',
        'ApiFormatDump' => 'includes/api/ApiFormatDump.php',
        'ApiFormatFeedWrapper' => 'includes/api/ApiFormatBase.php',
        'ApiFormatJson' => 'includes/api/ApiFormatJson.php',
 +      'ApiFormatNone' => 'includes/api/ApiFormatNone.php',
        'ApiFormatPhp' => 'includes/api/ApiFormatPhp.php',
        'ApiFormatRaw' => 'includes/api/ApiFormatRaw.php',
        'ApiFormatTxt' => 'includes/api/ApiFormatTxt.php',
        'FormatMetadata' => 'includes/media/FormatMetadata.php',
        'GIFHandler' => 'includes/media/GIF.php',
        'GIFMetadataExtractor' => 'includes/media/GIFMetadataExtractor.php',
-       'ImageHandler' => 'includes/media/Generic.php',
+       'ImageHandler' => 'includes/media/ImageHandler.php',
        'IPTC' => 'includes/media/IPTC.php',
        'JpegHandler' => 'includes/media/Jpeg.php',
        'JpegMetadataExtractor' => 'includes/media/JpegMetadataExtractor.php',
-       'MediaHandler' => 'includes/media/Generic.php',
+       'MediaHandler' => 'includes/media/MediaHandler.php',
        'MediaTransformError' => 'includes/media/MediaTransformOutput.php',
        'MediaTransformOutput' => 'includes/media/MediaTransformOutput.php',
        'PNGHandler' => 'includes/media/PNG.php',
        'TestFileIterator' => 'tests/testHelpers.inc',
        'TestRecorder' => 'tests/testHelpers.inc',
  
 +      # tests/phpunit
 +      'RevisionStorageTest' => 'tests/phpunit/includes/RevisionStorageTest.php',
 +      'WikiPageTest' => 'tests/phpunit/includes/WikiPageTest.php',
 +      'WikitextContentTest' => 'tests/phpunit/includes/WikitextContentTest.php',
 +      'JavascriptContentTest' => 'tests/phpunit/includes/JavascriptContentTest.php',
 +      'DummyContentHandlerForTesting' => 'tests/phpunit/includes/ContentHandlerTest.php',
 +      'DummyContentForTesting' => 'tests/phpunit/includes/ContentHandlerTest.php',
 +
        # tests/phpunit/includes/db
        'ORMRowTest' => 'tests/phpunit/includes/db/ORMRowTest.php',
  
@@@ -358,9 -358,11 +358,11 @@@ $wgImgAuthPublicTest = true
   *
   * For most core repos:
   *   - zones            Associative array of zone names that each map to an array with:
-  *                          container : backend container name the zone is in
-  *                          directory : root path within container for the zone
-  *                          url       : base URL to the root of the zone
+  *                          container  : backend container name the zone is in
+  *                          directory  : root path within container for the zone
+  *                          url        : base URL to the root of the zone
+  *                          handlerUrl : base script handled URL to the root of the zone
+  *                                       (see FileRepo::getZoneHandlerUrl() function)
   *                      Zones default to using "<repo name>-<zone name>" as the container name
   *                      and default to using the container root as the zone's root directory.
   *                      Nesting of zone locations within other zones should be avoided.
@@@ -724,16 -726,6 +726,16 @@@ $wgMediaHandlers = array
        'image/x-djvu'   => 'DjVuHandler', // compat
  );
  
 +/**
 + * Plugins for page content model handling.
 + * Each entry in the array maps a model id to a class name
 + */
 +$wgContentHandlers = array(
 +      CONTENT_MODEL_WIKITEXT => 'WikitextContentHandler', // the usual case
 +      CONTENT_MODEL_JAVASCRIPT => 'JavaScriptContentHandler', // dumb version, no syntax highlighting
 +      CONTENT_MODEL_CSS => 'CssContentHandler', // dumb version, no syntax highlighting
 +);
 +
  /**
   * Resizing can be done using PHP's internal image libraries or using
   * ImageMagick or another third-party converter, e.g. GraphicMagick.
@@@ -1594,17 -1586,10 +1596,10 @@@ $wgUseDumbLinkUpdate = false
  
  /**
   * Anti-lock flags - bitfield
-  *   - ALF_PRELOAD_LINKS:
-  *       Preload links during link update for save
-  *   - ALF_PRELOAD_EXISTENCE:
-  *       Preload cur_id during replaceLinkHolders
   *   - ALF_NO_LINK_LOCK:
   *       Don't use locking reads when updating the link table. This is
   *       necessary for wikis with a high edit rate for performance
   *       reasons, but may cause link table inconsistency
-  *   - ALF_NO_BLOCK_LOCK:
-  *       As for ALF_LINK_LOCK, this flag is a necessity for high-traffic
-  *       wikis.
   */
  $wgAntiLockFlags = 0;
  
@@@ -2700,6 -2685,14 +2695,14 @@@ $wgBetterDirectionality = true
   */
  $wgSend404Code = true;
  
+ /**
+  * The $wgShowRollbackEditCount variable is used to show how many edits will be
+  * rollback. The numeric value of the varible are the limit up to are counted.
+  * If the value is false or 0, the edits are not counted.
+  */
+ $wgShowRollbackEditCount = 10;
  /** @} */ # End of output format settings }
  
  /*************************************************************************//**
@@@ -5520,10 -5513,12 +5523,12 @@@ $wgLogActions = array
   * @see LogFormatter
   */
  $wgLogActionsHandlers = array(
-       // move, move_redir
-       'move/*'            => 'MoveLogFormatter',
-       // delete, restore, revision, event
-       'delete/*'          => 'DeleteLogFormatter',
+       'move/move'         => 'MoveLogFormatter',
+       'move/move_redir'  => 'MoveLogFormatter',
+       'delete/delete'     => 'DeleteLogFormatter',
+       'delete/restore'    => 'DeleteLogFormatter',
+       'delete/revision'   => 'DeleteLogFormatter',
+       'delete/event'      => 'DeleteLogFormatter',
        'suppress/revision' => 'DeleteLogFormatter',
        'suppress/event'    => 'DeleteLogFormatter',
        'suppress/delete'   => 'DeleteLogFormatter',
@@@ -6150,31 -6145,11 +6155,36 @@@ $wgSeleniumConfigFile = null
  $wgDBtestuser = ''; //db user that has permission to create and drop the test databases only
  $wgDBtestpassword = '';
  
 +/**
 + * Associative array mapping namespace IDs to the name of the content model pages in that namespace should have by
 + * default (use the CONTENT_MODEL_XXX constants). If no special content type is defined for a given namespace,
 + * pages in that namespace will  use the CONTENT_MODEL_WIKITEXT (except for the special case of JS and CS pages).
 + */
 +$wgNamespaceContentModels = array();
 +
 +/**
 + * How to react if a plain text version of a non-text Content object is requested using ContentHandler::getContentText():
 + *
 + * * 'ignore': return null
 + * * 'fail': throw an MWException
 + * * 'serializeContent': serializeContent to default format
 + */
 +$wgContentHandlerTextFallback = 'ignore';
 +
 +/**
 + * Compatibility switch for running ContentHandler code withoput a schema update.
 + * Set to false to disable use of the database fields introduced by the ContentHandler facility.
 + *
 + * @deprecated this is only here to allow code deployment without a database schema update on large sites.
 + *             get rid of it in the next version.
 + */
 +$wgContentHandlerUseDB = true;
 +
+ /**
+  * Whether the user must enter their password to change their e-mail address
+  */
+ $wgRequirePasswordforEmailChange = true;
  /**
   * For really cool vim folding this needs to be at the end:
   * vim: foldmarker=@{,@} foldmethod=marker
diff --combined includes/Defines.php
@@@ -144,8 -144,8 +144,8 @@@ define( 'AV_SCAN_FAILED', false );  #sc
   * Anti-lock flags
   * See DefaultSettings.php for a description
   */
- define( 'ALF_PRELOAD_LINKS', 1 );
- define( 'ALF_PRELOAD_EXISTENCE', 2 );
+ define( 'ALF_PRELOAD_LINKS', 1 ); // unused
+ define( 'ALF_PRELOAD_EXISTENCE', 2 ); // unused
  define( 'ALF_NO_LINK_LOCK', 4 );
  define( 'ALF_NO_BLOCK_LOCK', 8 );
  /**@}*/
@@@ -259,7 -259,7 +259,7 @@@ define( 'APCOND_BLOCKED', 8 )
  define( 'APCOND_ISBOT', 9 );
  /**@}*/
  
 -/**
 +/** @{
   * Protocol constants for wfExpandUrl()
   */
  define( 'PROTO_HTTP', 'http://' );
@@@ -268,34 -268,3 +268,34 @@@ define( 'PROTO_RELATIVE', '//' )
  define( 'PROTO_CURRENT', null );
  define( 'PROTO_CANONICAL', 1 );
  define( 'PROTO_INTERNAL', 2 );
 +/**@}*/
 +
 +/**@{
 + * Content model ids, used by Content and ContentHandler.
 + * These IDs will be exposed in the API and XML dumps.
 + *
 + * Extensions that define their own content model IDs should take
 + * care to avoid conflicts. Using the extension name as a prefix is recommended.
 + */
 +define( 'CONTENT_MODEL_WIKITEXT', 'wikitext' );
 +define( 'CONTENT_MODEL_JAVASCRIPT', 'javascript' );
 +define( 'CONTENT_MODEL_CSS', 'css' );
 +define( 'CONTENT_MODEL_TEXT', 'text' );
 +/**@}*/
 +
 +/**@{
 + * Content formats, used by Content and ContentHandler.
 + * These should be MIME types, and will be exposed in the API and XML dumps.
 + *
 + * Extensions are free to use the below formats, or define their own.
 + * It is recommended to stick with the conventions for MIME types.
 + */
 +define( 'CONTENT_FORMAT_WIKITEXT', 'text/x-wiki' ); // wikitext
 +define( 'CONTENT_FORMAT_JAVASCRIPT', 'text/javascript' ); // for js pages
 +define( 'CONTENT_FORMAT_CSS', 'text/css' );  // for css pages
 +define( 'CONTENT_FORMAT_TEXT', 'text/plain' ); // for future use, e.g. with some plain-html messages.
 +define( 'CONTENT_FORMAT_HTML', 'text/html' ); // for future use, e.g. with some plain-html messages.
 +define( 'CONTENT_FORMAT_SERIALIZED', 'application/vnd.php.serialized' ); // for future use with the api, and for use by extensions
 +define( 'CONTENT_FORMAT_JSON', 'application/json' ); // for future use with the api, and for use by extensions
 +define( 'CONTENT_FORMAT_XML', 'application/xml' ); // for future use with the api, and for use by extensions
 +/**@}*/
diff --combined includes/ImagePage.php
@@@ -157,9 -157,7 +157,9 @@@ class ImagePage extends Article 
                        $out->addHTML( Xml::openElement( 'div', array( 'id' => 'mw-imagepage-content',
                                'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
                                'class' => 'mw-content-'.$pageLang->getDir() ) ) );
 +
                        parent::view();
 +
                        $out->addHTML( Xml::closeElement( 'div' ) );
                } else {
                        # Just need to set the right headers
        }
  
        /**
 -       * Overloading Article's getContent method.
 +       * Overloading Article's getContentObject method.
         *
         * Omit noarticletext if sharedupload; text will be fetched from the
         * shared upload server if possible.
         * @return string
         */
 -      public function getContent() {
 +      public function getContentObject() {
                $this->loadFile();
                if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getID() ) {
 -                      return '';
 +                      return null;
                }
 -              return parent::getContent();
 +              return parent::getContentObject();
        }
  
        protected function openShowImage() {
@@@ -780,7 -778,7 +780,7 @@@ EO
                                        $link2 = Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
                                        $ul .= Html::rawElement(
                                                'li',
-                                               array( 'id' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
+                                               array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
                                                $link2
                                                ) . "\n";
                                }
                        }
                        $out->addHTML( Html::rawElement(
                                        'li',
-                                       array( 'id' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
+                                       array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
                                        $liContents
                                ) . "\n"
                        );
@@@ -946,18 -944,18 +946,18 @@@ class ImageHistoryList extends ContextS
         * @return string
         */
        public function beginImageHistoryList( $navLinks = '' ) {
-               return Xml::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) ) . "\n"
+               return Xml::element( 'h2', array( 'id' => 'filehistory' ), $this->msg( 'filehist' )->text() ) . "\n"
                        . "<div id=\"mw-imagepage-section-filehistory\">\n"
-                       . $this->getOutput()->parse( wfMsgNoTrans( 'filehist-help' ) )
+                       . $this->msg( 'filehist-help' )->parseAsBlock()
                        . $navLinks . "\n"
                        . Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n"
                        . '<tr><td></td>'
                        . ( $this->current->isLocal() && ( $this->getUser()->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '<td></td>' : '' )
-                       . '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
-                       . ( $this->showThumb ? '<th>' . wfMsgHtml( 'filehist-thumb' ) . '</th>' : '' )
-                       . '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
-                       . '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
-                       . '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
+                       . '<th>' . $this->msg( 'filehist-datetime' )->escaped() . '</th>'
+                       . ( $this->showThumb ? '<th>' . $this->msg( 'filehist-thumb' )->escaped() . '</th>' : '' )
+                       . '<th>' . $this->msg( 'filehist-dimensions' )->escaped() . '</th>'
+                       . '<th>' . $this->msg( 'filehist-user' )->escaped() . '</th>'
+                       . '<th>' . $this->msg( 'filehist-comment' )->escaped() . '</th>'
                        . "</tr>\n";
        }
  
                                }
                                $row .= Linker::linkKnown(
                                        $this->title,
-                                       wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ),
+                                       $this->msg( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' )->escaped(),
                                        array(), $q
                                );
                        }
                                        $row .= '<br />';
                                }
                                // If file is top revision or locked from this user, don't link
-                               if ( $iscur || !$file->userCan( File::DELETED_RESTRICTED ) ) {
+                               if ( $iscur || !$file->userCan( File::DELETED_RESTRICTED, $user ) ) {
                                        $del = Linker::revDeleteLinkDisabled( $canHide );
                                } else {
                                        list( $ts, ) = explode( '!', $img, 2 );
                // Reversion link/current indicator
                $row .= '<td>';
                if ( $iscur ) {
-                       $row .= wfMsgHtml( 'filehist-current' );
-               } elseif ( $local && $this->title->quickUserCan( 'edit' )
-                       && $this->title->quickUserCan( 'upload' )
+                       $row .= $this->msg( 'filehist-current' )->escaped();
+               } elseif ( $local && $this->title->quickUserCan( 'edit', $user )
+                       && $this->title->quickUserCan( 'upload', $user )
                ) {
                        if ( $file->isDeleted( File::DELETED_FILE ) ) {
-                               $row .= wfMsgHtml( 'filehist-revert' );
+                               $row .= $this->msg( 'filehist-revert' )->escaped();
                        } else {
                                $row .= Linker::linkKnown(
                                        $this->title,
-                                       wfMsgHtml( 'filehist-revert' ),
+                                       $this->msg( 'filehist-revert' )->escaped(),
                                        array(),
                                        array(
                                                'action' => 'revert',
                        $selected = "class='filehistory-selected'";
                }
                $row .= "<td $selected style='white-space: nowrap;'>";
-               if ( !$file->userCan( File::DELETED_FILE ) ) {
+               if ( !$file->userCan( File::DELETED_FILE, $user ) ) {
                        # Don't link to unviewable files
-                       $row .= '<span class="history-deleted">' . $lang->timeanddate( $timestamp, true ) . '</span>';
+                       $row .= '<span class="history-deleted">' . $lang->userTimeAndDate( $timestamp, $user ) . '</span>';
                } elseif ( $file->isDeleted( File::DELETED_FILE ) ) {
                        if ( $local ) {
                                $this->preventClickjacking();
                                # Make a link to review the image
                                $url = Linker::linkKnown(
                                        $revdel,
-                                       $lang->timeanddate( $timestamp, true ),
+                                       $lang->userTimeAndDate( $timestamp, $user ),
                                        array(),
                                        array(
                                                'target' => $this->title->getPrefixedText(),
                                        )
                                );
                        } else {
-                               $url = $lang->timeanddate( $timestamp, true );
+                               $url = $lang->userTimeAndDate( $timestamp, $user );
                        }
                        $row .= '<span class="history-deleted">' . $url . '</span>';
                } else {
                        $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img );
-                       $row .= Xml::element( 'a', array( 'href' => $url ), $lang->timeanddate( $timestamp, true ) );
+                       $row .= Xml::element( 'a', array( 'href' => $url ), $lang->userTimeAndDate( $timestamp, $user ) );
                }
                $row .= "</td>";
  
                // Image dimensions + size
                $row .= '<td>';
                $row .= htmlspecialchars( $file->getDimensionsString() );
-               $row .= $this->getContext()->msg( 'word-separator' )->plain();
+               $row .= $this->msg( 'word-separator' )->plain();
                $row .= '<span style="white-space: nowrap;">';
-               $row .= $this->getContext()->msg( 'parentheses' )->rawParams( Linker::formatSize( $file->getSize() ) )->plain();
+               $row .= $this->msg( 'parentheses' )->rawParams( Linker::formatSize( $file->getSize() ) )->plain();
                $row .= '</span>';
                $row .= '</td>';
  
                $row .= '<td>';
                // Hide deleted usernames
                if ( $file->isDeleted( File::DELETED_USER ) ) {
-                       $row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
+                       $row .= '<span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
                } else {
                        if ( $local ) {
                                $row .= Linker::userLink( $userId, $userText );
-                               $row .= $this->getContext()->msg( 'word-separator' )->plain();
+                               $row .= $this->msg( 'word-separator' )->plain();
                                $row .= '<span style="white-space: nowrap;">';
                                $row .= Linker::userToolLinks( $userId, $userText );
                                $row .= '</span>';
  
                // Don't show deleted descriptions
                if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
-                       $row .= '<td><span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span></td>';
+                       $row .= '<td><span class="history-deleted">' . $this->msg( 'rev-deleted-comment' )->escaped() . '</span></td>';
                } else {
                        $row .= '<td dir="' . $wgContLang->getDir() . '">' . Linker::formatComment( $description, $this->title ) . '</td>';
                }
         */
        protected function getThumbForLine( $file ) {
                $lang = $this->getLanguage();
-               if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE ) && !$file->isDeleted( File::DELETED_FILE ) ) {
+               $user = $this->getUser();
+               if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE,$user )
+                       && !$file->isDeleted( File::DELETED_FILE ) )
+               {
                        $params = array(
                                'width' => '120',
                                'height' => '120',
  
                        $thumbnail = $file->transform( $params );
                        $options = array(
-                               'alt' => wfMsg( 'filehist-thumbtext',
-                                       $lang->timeanddate( $timestamp, true ),
-                                       $lang->date( $timestamp, true ),
-                                       $lang->time( $timestamp, true ) ),
+                               'alt' => $this->msg( 'filehist-thumbtext',
+                                       $lang->userTimeAndDate( $timestamp, $user ),
+                                       $lang->userDate( $timestamp, $user ),
+                                       $lang->userTime( $timestamp, $user ) )->text(),
                                'file-link' => true,
                        );
  
                        if ( !$thumbnail ) {
-                               return wfMsgHtml( 'filehist-nothumb' );
+                               return $this->msg( 'filehist-nothumb' )->escaped();
                        }
  
                        return $thumbnail->toHtml( $options );
                } else {
-                       return wfMsgHtml( 'filehist-nothumb' );
+                       return $this->msg( 'filehist-nothumb' )->escaped();
                }
        }
  
diff --combined includes/OutputPage.php
@@@ -647,24 -647,16 +647,16 @@@ class OutputPage extends ContextSource 
                $maxModified = max( $modifiedTimes );
                $this->mLastModified = wfTimestamp( TS_RFC2822, $maxModified );
  
-               if( empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
+               $clientHeader = $this->getRequest()->getHeader( 'If-Modified-Since' );
+               if ( $clientHeader === false ) {
                        wfDebug( __METHOD__ . ": client did not send If-Modified-Since header\n", false );
                        return false;
                }
  
-               # Make debug info
-               $info = '';
-               foreach ( $modifiedTimes as $name => $value ) {
-                       if ( $info !== '' ) {
-                               $info .= ', ';
-                       }
-                       $info .= "$name=" . wfTimestamp( TS_ISO_8601, $value );
-               }
                # IE sends sizes after the date like this:
                # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
                # this breaks strtotime().
-               $clientHeader = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
+               $clientHeader = preg_replace( '/;.*$/', '', $clientHeader );
  
                wfSuppressWarnings(); // E_STRICT system time bitching
                $clientHeaderTime = strtotime( $clientHeader );
                }
                $clientHeaderTime = wfTimestamp( TS_MW, $clientHeaderTime );
  
+               # Make debug info
+               $info = '';
+               foreach ( $modifiedTimes as $name => $value ) {
+                       if ( $info !== '' ) {
+                               $info .= ', ';
+                       }
+                       $info .= "$name=" . wfTimestamp( TS_ISO_8601, $value );
+               }
                wfDebug( __METHOD__ . ": client sent If-Modified-Since: " .
                        wfTimestamp( TS_ISO_8601, $clientHeaderTime ) . "\n", false );
                wfDebug( __METHOD__ . ": effective Last-Modified: " .
                }
  
                $this->sendCacheControl();
 +
 +              wfRunHooks( 'AfterFinalPageOutput', array( &$this ) );
 +
                ob_end_flush();
 +
                wfProfileOut( __METHOD__ );
        }
  
diff --combined includes/WikiPage.php
@@@ -206,21 -206,7 +206,21 @@@ class WikiPage extends Page 
         * @return Array
         */
        public function getActionOverrides() {
 -              return array();
 +              $content_handler = $this->getContentHandler();
 +              return $content_handler->getActionOverrides();
 +      }
 +
 +      /**
 +       * Returns the ContentHandler instance to be used to deal with the content of this WikiPage.
 +       *
 +       * Shorthand for ContentHandler::getForModelID( $this->getContentModel() );
 +       *
 +       * @return ContentHandler
 +       *
 +       * @since 1.WD
 +       */
 +      public function getContentHandler() {
 +              return ContentHandler::getForModelID( $this->getContentModel() );
        }
  
        /**
         * @return array
         */
        public static function selectFields() {
 -              return array(
 +              global $wgContentHandlerUseDB;
 +
 +              $fields = array(
                        'page_id',
                        'page_namespace',
                        'page_title',
                        'page_latest',
                        'page_len',
                );
 +
 +              if ( $wgContentHandlerUseDB ) {
 +                      $fields[] = 'page_content_model';
 +              }
 +
 +              return $fields;
        }
  
        /**
        }
  
        /**
 -       * Tests if the article text represents a redirect
 +       * Tests if the article content represents a redirect
         *
 -       * @param $text mixed string containing article contents, or boolean
         * @return bool
         */
 -      public function isRedirect( $text = false ) {
 -              if ( $text === false ) {
 -                      if ( !$this->mDataLoaded ) {
 -                              $this->loadPageData();
 -                      }
 +      public function isRedirect( ) {
 +              $content = $this->getContent();
 +              if ( !$content ) return false;
  
 -                      return (bool)$this->mIsRedirect;
 -              } else {
 -                      return Title::newFromRedirect( $text ) !== null;
 +              return $content->isRedirect();
 +      }
 +
 +      /**
 +       * Returns the page's content model id (see the CONTENT_MODEL_XXX constants).
 +       *
 +       * Will use the revisions actual content model if the page exists,
 +       * and the page's default if the page doesn't exist yet.
 +       *
 +       * @return String
 +       *
 +       * @since 1.WD
 +       */
 +      public function getContentModel() {
 +              if ( $this->exists() ) {
 +                      # look at the revision's actual content model
 +                      $rev = $this->getRevision();
 +
 +                      if ( $rev !== null ) {
 +                              return $rev->getContentModel();
 +                      } else {
 +                              wfWarn( "Page exists but has no revision!" );
 +                      }
                }
 +
 +              # use the default model for this page
 +              return $this->mTitle->getContentModel();
        }
  
        /**
                return null;
        }
  
 +      /**
 +       * Get the content of the current revision. No side-effects...
 +       *
 +       * @param $audience Integer: one of:
 +       *      Revision::FOR_PUBLIC       to be displayed to all users
 +       *      Revision::FOR_THIS_USER    to be displayed to $wgUser
 +       *      Revision::RAW              get the text regardless of permissions
 +       * @return Content|null The content of the current revision
 +       *
 +       * @since 1.WD
 +       */
 +      public function getContent( $audience = Revision::FOR_PUBLIC ) {
 +              $this->loadLastEdit();
 +              if ( $this->mLastRevision ) {
 +                      return $this->mLastRevision->getContent( $audience );
 +              }
 +              return null;
 +      }
 +
        /**
         * Get the text of the current revision. No side-effects...
         *
         *      Revision::FOR_PUBLIC       to be displayed to all users
         *      Revision::FOR_THIS_USER    to be displayed to $wgUser
         *      Revision::RAW              get the text regardless of permissions
 -       * @return String|bool The text of the current revision. False on failure
 +       * @return String|false The text of the current revision
 +       * @deprecated as of 1.WD, getContent() should be used instead.
         */
 -      public function getText( $audience = Revision::FOR_PUBLIC ) {
 +      public function getText( $audience = Revision::FOR_PUBLIC ) { #@todo: deprecated, replace usage!
 +              wfDeprecated( __METHOD__, '1.WD' );
 +
                $this->loadLastEdit();
                if ( $this->mLastRevision ) {
                        return $this->mLastRevision->getText( $audience );
         * Get the text of the current revision. No side-effects...
         *
         * @return String|bool The text of the current revision. False on failure
 +       * @deprecated as of 1.WD, getContent() should be used instead.
         */
        public function getRawText() {
 -              $this->loadLastEdit();
 -              if ( $this->mLastRevision ) {
 -                      return $this->mLastRevision->getRawText();
 -              }
 -              return false;
 +              wfDeprecated( __METHOD__, '1.WD' );
 +
 +              return $this->getText( Revision::RAW );
        }
  
        /**
                        return false;
                }
  
 -              $text = $editInfo ? $editInfo->pst : false;
 +              if ( $editInfo ) {
 +                      $content = $editInfo->pstContent;
 +              } else {
 +                      $content = $this->getContent();
 +              }
  
 -              if ( $this->isRedirect( $text ) ) {
 +              if ( !$content || $content->isRedirect( ) ) {
                        return false;
                }
  
 -              switch ( $wgArticleCountMethod ) {
 -              case 'any':
 -                      return true;
 -              case 'comma':
 -                      if ( $text === false ) {
 -                              $text = $this->getRawText();
 -                      }
 -                      return strpos( $text,  ',' ) !== false;
 -              case 'link':
 +              $hasLinks = null;
 +
 +              if ( $wgArticleCountMethod === 'link' ) {
 +                      # nasty special case to avoid re-parsing to detect links
 +
                        if ( $editInfo ) {
                                // ParserOutput::getLinks() is a 2D array of page links, so
                                // to be really correct we would need to recurse in the array
                                // but the main array should only have items in it if there are
                                // links.
 -                              return (bool)count( $editInfo->output->getLinks() );
 +                              $hasLinks = (bool)count( $editInfo->output->getLinks() );
                        } else {
 -                              return (bool)wfGetDB( DB_SLAVE )->selectField( 'pagelinks', 1,
 +                              $hasLinks = (bool)wfGetDB( DB_SLAVE )->selectField( 'pagelinks', 1,
                                        array( 'pl_from' => $this->getId() ), __METHOD__ );
                        }
                }
 +
 +              return $content->isCountable( $hasLinks );
        }
  
        /**
         */
        public function insertRedirect() {
                // recurse through to only get the final target
 -              $retval = Title::newFromRedirectRecurse( $this->getRawText() );
 +              $content = $this->getContent();
 +              $retval = $content ? $content->getUltimateRedirectTarget() : null;
                if ( !$retval ) {
                        return null;
                }
                        && $parserOptions->getStubThreshold() == 0
                        && $this->mTitle->exists()
                        && ( $oldid === null || $oldid === 0 || $oldid === $this->getLatest() )
 -                      && $this->mTitle->isWikitextPage();
 +                      && $this->getContentHandler()->isParserCacheSupported();
        }
  
        /**
         * @param $parserOptions ParserOptions to use for the parse operation
         * @param $oldid Revision ID to get the text from, passing null or 0 will
         *               get the current revision (default value)
 +       *
         * @return ParserOutput or false if the revision was not found
         */
        public function getParserOutput( ParserOptions $parserOptions, $oldid = null ) {
                }
  
                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 +                      //@todo: move this logic to MessageCache
 +
                        if ( $this->mTitle->exists() ) {
 -                              $text = $this->getRawText();
 +                              // NOTE: use transclusion text for messages.
 +                              //       This is consistent with  MessageCache::getMsgFromNamespace()
 +
 +                              $content = $this->getContent();
 +                              $text = $content === null ? null : $content->getWikitextForTransclusion();
 +
 +                              if ( $text === null ) $text = false;
                        } else {
                                $text = false;
                        }
         * @private
         */
        public function updateRevisionOn( $dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null ) {
 +              global $wgContentHandlerUseDB;
 +
                wfProfileIn( __METHOD__ );
  
 -              $text = $revision->getText();
 -              $len = strlen( $text );
 -              $rt = Title::newFromRedirectRecurse( $text );
 +              $content = $revision->getContent();
 +              $len = $content->getSize();
 +              $rt = $content->getUltimateRedirectTarget();
  
                $conditions = array( 'page_id' => $this->getId() );
  
                }
  
                $now = wfTimestampNow();
 +              $row = array( /* SET */
 +                      'page_latest'      => $revision->getId(),
 +                      'page_touched'     => $dbw->timestamp( $now ),
 +                      'page_is_new'      => ( $lastRevision === 0 ) ? 1 : 0,
 +                      'page_is_redirect' => $rt !== null ? 1 : 0,
 +                      'page_len'         => $len,
 +              );
 +
 +              if ( $wgContentHandlerUseDB ) {
 +                      $row[ 'page_content_model' ] = $revision->getContentModel();
 +              }
 +
                $dbw->update( 'page',
 -                      array( /* SET */
 -                              'page_latest'      => $revision->getId(),
 -                              'page_touched'     => $dbw->timestamp( $now ),
 -                              'page_is_new'      => ( $lastRevision === 0 ) ? 1 : 0,
 -                              'page_is_redirect' => $rt !== null ? 1 : 0,
 -                              'page_len'         => $len,
 -                      ),
 +                      $row,
                        $conditions,
                        __METHOD__ );
  
                        $this->mLatest = $revision->getId();
                        $this->mIsRedirect = (bool)$rt;
                        # Update the LinkCache.
 -                      LinkCache::singleton()->addGoodLinkObj( $this->getId(), $this->mTitle, $len, $this->mIsRedirect, $this->mLatest );
 +                      LinkCache::singleton()->addGoodLinkObj( $this->getId(), $this->mTitle, $len, $this->mIsRedirect, $this->mLatest, $revision->getContentModel() );
                }
  
                wfProfileOut( __METHOD__ );
                return $ret;
        }
  
 +    /**
 +     * Get the content that needs to be saved in order to undo all revisions
 +     * between $undo and $undoafter. Revisions must belong to the same page,
 +     * must exist and must not be deleted
 +     * @param $undo Revision
 +     * @param $undoafter Revision Must be an earlier revision than $undo
 +     * @return mixed string on success, false on failure
 +     * @since 1.WD
 +     * Before we had the Content object, this was done in getUndoText
 +     */
 +    public function getUndoContent( Revision $undo, Revision $undoafter = null ) {
 +        $handler = $undo->getContentHandler();
 +        return $handler->getUndoContent( $this->getRevision(), $undo, $undoafter );
 +    }
 +
        /**
         * Get the text that needs to be saved in order to undo all revisions
         * between $undo and $undoafter. Revisions must belong to the same page,
         * @param $undo Revision
         * @param $undoafter Revision Must be an earlier revision than $undo
         * @return mixed string on success, false on failure
 +       * @deprecated since 1.WD: use ContentHandler::getUndoContent() instead.
         */
        public function getUndoText( Revision $undo, Revision $undoafter = null ) {
 -              $cur_text = $this->getRawText();
 -              if ( $cur_text === false ) {
 -                      return false; // no page
 -              }
 -              $undo_text = $undo->getText();
 -              $undoafter_text = $undoafter->getText();
 +              wfDeprecated( __METHOD__, '1.WD' );
  
 -              if ( $cur_text == $undo_text ) {
 -                      # No use doing a merge if it's just a straight revert.
 -                      return $undoafter_text;
 -              }
 +              $this->loadLastEdit();
  
 -              $undone_text = '';
 +              if ( $this->mLastRevision ) {
 +                      if ( is_null( $undoafter ) ) {
 +                              $undoafter = $undo->getPrevious();
 +                      }
  
 -              if ( !wfMerge( $undo_text, $undoafter_text, $cur_text, $undone_text ) ) {
 -                      return false;
 +                      $handler = $this->getContentHandler();
 +                      $undone = $handler->getUndoContent( $this->mLastRevision, $undo, $undoafter );
 +
 +                      if ( !$undone ) {
 +                              return false;
 +                      } else {
 +                              return ContentHandler::getContentText( $undone );
 +                      }
                }
  
 -              return $undone_text;
 +              return false;
        }
  
        /**
         * @param $text String: new text of the section
         * @param $sectionTitle String: new section's subject, only if $section is 'new'
         * @param $edittime String: revision timestamp or null to use the current revision
 -       * @return string Complete article text, or null if error
 +       * @return String new complete article text, or null if error
 +       *
 +       * @deprecated since 1.WD, use replaceSectionContent() instead
         */
        public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) {
 +              wfDeprecated( __METHOD__, '1.WD' );
 +
 +              if ( strval( $section ) == '' ) { //NOTE: keep condition in sync with condition in replaceSectionContent!
 +                      // Whole-page edit; let the whole text through
 +                      return $text;
 +              }
 +
 +              if ( !$this->supportsSections() ) {
 +                      throw new MWException( "sections not supported for content model " . $this->getContentHandler()->getModelID() );
 +              }
 +
 +              $sectionContent = ContentHandler::makeContent( $text, $this->getTitle() ); # could even make section title, but that's not required.
 +
 +              $newContent = $this->replaceSectionContent( $section, $sectionContent, $sectionTitle, $edittime );
 +
 +              return ContentHandler::getContentText( $newContent );
 +      }
 +
 +      /**
 +       * Returns true iff this page's content model supports sections.
 +       *
 +       * @return boolean whether sections are supported.
 +       *
 +       * @todo: the skin should check this and not offer section functionality if sections are not supported.
 +       * @todo: the EditPage should check this and not offer section functionality if sections are not supported.
 +       */
 +      public function supportsSections() {
 +              return $this->getContentHandler()->supportsSections();
 +      }
 +
 +      /**
 +       * @param $section null|bool|int or a section number (0, 1, 2, T1, T2...)
 +       * @param $content Content: new content of the section
 +       * @param $sectionTitle String: new section's subject, only if $section is 'new'
 +       * @param $edittime String: revision timestamp or null to use the current revision
 +       *
 +       * @return Content new complete article content, or null if error
 +       *
 +       * @since 1.WD
 +       */
 +      public function replaceSectionContent( $section, Content $sectionContent, $sectionTitle = '', $edittime = null ) {
                wfProfileIn( __METHOD__ );
  
                if ( strval( $section ) == '' ) {
                        // Whole-page edit; let the whole text through
 +                      $newContent = $sectionContent;
                } else {
 +                      if ( !$this->supportsSections() ) {
 +                              throw new MWException( "sections not supported for content model " . $this->getContentHandler()->getModelID() );
 +                      }
 +
                        // Bug 30711: always use current version when adding a new section
                        if ( is_null( $edittime ) || $section == 'new' ) {
 -                              $oldtext = $this->getRawText();
 -                              if ( $oldtext === false ) {
 +                              $oldContent = $this->getContent();
 +                              if ( ! $oldContent ) {
                                        wfDebug( __METHOD__ . ": no page text\n" );
                                        wfProfileOut( __METHOD__ );
                                        return null;
                                        return null;
                                }
  
 -                              $oldtext = $rev->getText();
 +                              $oldContent = $rev->getContent();
                        }
  
 -                      if ( $section == 'new' ) {
 -                              # Inserting a new section
 -                              $subject = $sectionTitle ? wfMsgForContent( 'newsectionheaderdefaultlevel', $sectionTitle ) . "\n\n" : '';
 -                              if ( wfRunHooks( 'PlaceNewSection', array( $this, $oldtext, $subject, &$text ) ) ) {
 -                                      $text = strlen( trim( $oldtext ) ) > 0
 -                                              ? "{$oldtext}\n\n{$subject}{$text}"
 -                                              : "{$subject}{$text}";
 -                              }
 -                      } else {
 -                              # Replacing an existing section; roll out the big guns
 -                              global $wgParser;
 -
 -                              $text = $wgParser->replaceSection( $oldtext, $section, $text );
 -                      }
 +                      $newContent = $oldContent->replaceSection( $section, $sectionContent, $sectionTitle );
                }
  
                wfProfileOut( __METHOD__ );
 -              return $text;
 +              return $newContent;
        }
  
        /**
         *     revision:                The revision object for the inserted revision, or null
         *
         *  Compatibility note: this function previously returned a boolean value indicating success/failure
 +       *
 +       * @deprecated since 1.WD: use doEditContent() instead.
 +       */
 +      public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) { #@todo: use doEditContent() instead
 +              wfDeprecated( __METHOD__, '1.WD' );
 +
 +              $content = ContentHandler::makeContent( $text, $this->getTitle() );
 +
 +              return $this->doEditContent( $content, $summary, $flags, $baseRevId, $user );
 +      }
 +
 +      /**
 +       * Change an existing article or create a new article. Updates RC and all necessary caches,
 +       * optionally via the deferred update array.
 +       *
 +       * @param $content Content: new content
 +       * @param $summary String: edit summary
 +       * @param $flags Integer bitfield:
 +       *      EDIT_NEW
 +       *          Article is known or assumed to be non-existent, create a new one
 +       *      EDIT_UPDATE
 +       *          Article is known or assumed to be pre-existing, update it
 +       *      EDIT_MINOR
 +       *          Mark this edit minor, if the user is allowed to do so
 +       *      EDIT_SUPPRESS_RC
 +       *          Do not log the change in recentchanges
 +       *      EDIT_FORCE_BOT
 +       *          Mark the edit a "bot" edit regardless of user rights
 +       *      EDIT_DEFER_UPDATES
 +       *          Defer some of the updates until the end of index.php
 +       *      EDIT_AUTOSUMMARY
 +       *          Fill in blank summaries with generated text where possible
 +       *
 +       * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the article will be detected.
 +       * If EDIT_UPDATE is specified and the article doesn't exist, the function will return an
 +       * edit-gone-missing error. If EDIT_NEW is specified and the article does exist, an
 +       * edit-already-exists error will be returned. These two conditions are also possible with
 +       * auto-detection due to MediaWiki's performance-optimised locking strategy.
 +       *
 +       * @param $baseRevId the revision ID this edit was based off, if any
 +       * @param $user User the user doing the edit
 +       * @param $serialisation_format String: format for storing the content in the database
 +       *
 +       * @return Status object. Possible errors:
 +       *     edit-hook-aborted:       The ArticleSave hook aborted the edit but didn't set the fatal flag of $status
 +       *     edit-gone-missing:       In update mode, but the article didn't exist
 +       *     edit-conflict:           In update mode, the article changed unexpectedly
 +       *     edit-no-change:          Warning that the text was the same as before
 +       *     edit-already-exists:     In creation mode, but the article already exists
 +       *
 +       *  Extensions may define additional errors.
 +       *
 +       *  $return->value will contain an associative array with members as follows:
 +       *     new:                     Boolean indicating if the function attempted to create a new article
 +       *     revision:                The revision object for the inserted revision, or null
 +       *
 +       * @since 1.WD
         */
 -      public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
 +      public function doEditContent( Content $content, $summary, $flags = 0, $baseRevId = false,
 +                                                                 User $user = null, $serialisation_format = null ) {
-               global $wgUser, $wgDBtransactions, $wgUseAutomaticEditSummaries;
+               global $wgUser, $wgUseAutomaticEditSummaries, $wgUseRCPatrol, $wgUseNPPatrol;
  
                # Low-level sanity check
                if ( $this->mTitle->getText() === '' ) {
  
                $flags = $this->checkFlags( $flags );
  
 -              if ( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text, &$summary,
 -                      $flags & EDIT_MINOR, null, null, &$flags, &$status ) ) )
 -              {
 -                      wfDebug( __METHOD__ . ": ArticleSave hook aborted save!\n" );
 +              # call legacy hook
 +              $hook_ok = wfRunHooks( 'ArticleContentSave', array( &$this, &$user, &$content, &$summary,
 +                      $flags & EDIT_MINOR, null, null, &$flags, &$status ) );
 +
 +              if ( $hook_ok && Hooks::isRegistered( 'ArticleSave' ) ) { # avoid serialization overhead if the hook isn't present
 +                      $content_text = $content->serialize();
 +                      $txt = $content_text; # clone
 +
 +                      $hook_ok = wfRunHooks( 'ArticleSave', array( &$this, &$user, &$txt, &$summary,
 +                              $flags & EDIT_MINOR, null, null, &$flags, &$status ) ); #TODO: survey extensions using this hook
 +
 +                      if ( $txt !== $content_text ) {
 +                              # if the text changed, unserialize the new version to create an updated Content object.
 +                              $content = $content->getContentHandler()->unserializeContent( $txt );
 +                      }
 +              }
 +
 +              if ( !$hook_ok ) {
 +                      wfDebug( __METHOD__ . ": ArticleSave or ArticleSaveContent hook aborted save!\n" );
  
                        if ( $status->isOK() ) {
                                $status->fatal( 'edit-hook-aborted' );
                $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed( 'minoredit' );
                $bot = $flags & EDIT_FORCE_BOT;
  
 -              $oldtext = $this->getRawText(); // current revision
 -              $oldsize = strlen( $oldtext );
 +              $old_content = $this->getContent( Revision::RAW ); // current revision's content
 +
 +              $oldsize = $old_content ? $old_content->getSize() : 0;
                $oldid = $this->getLatest();
                $oldIsRedirect = $this->isRedirect();
                $oldcountable = $this->isCountable();
  
 +              $handler = $content->getContentHandler();
 +
                # Provide autosummaries if one is not provided and autosummaries are enabled.
                if ( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) {
 -                      $summary = self::getAutosummary( $oldtext, $text, $flags );
 +                      if ( !$old_content ) $old_content = null;
 +                      $summary = $handler->getAutosummary( $old_content, $content, $flags );
                }
  
 -              $editInfo = $this->prepareTextForEdit( $text, null, $user );
 -              $text = $editInfo->pst;
 -              $newsize = strlen( $text );
 +              $editInfo = $this->prepareContentForEdit( $content, null, $user, $serialisation_format );
 +              $serialized = $editInfo->pst;
 +              $content = $editInfo->pstContent;
 +              $newsize =  $content->getSize();
  
                $dbw = wfGetDB( DB_MASTER );
                $now = wfTimestampNow();
  
                                wfProfileOut( __METHOD__ );
                                return $status;
 -                      } elseif ( $oldtext === false ) {
 +                      } elseif ( !$old_content ) {
                                # Sanity check for bug 37225
                                wfProfileOut( __METHOD__ );
                                throw new MWException( "Could not find text for current revision {$oldid}." );
                                'page'       => $this->getId(),
                                'comment'    => $summary,
                                'minor_edit' => $isminor,
 -                              'text'       => $text,
 +                              'text'       => $serialized,
 +                              'len'        => $newsize,
                                'parent_id'  => $oldid,
                                'user'       => $user->getId(),
                                'user_text'  => $user->getName(),
 -                              'timestamp'  => $now
 -                      ) );
 +                              'timestamp'  => $now,
 +                              'content_model' => $content->getModel(),
 +                              'content_format' => $serialisation_format,
 +                      ) ); #XXX: pass content object?!
 +
                        # Bug 37225: use accessor to get the text as Revision may trim it.
                        # After trimming, the text may be a duplicate of the current text.
 -                      $text = $revision->getText(); // sanity; EditPage should trim already
 +                      $content = $revision->getContent(); // sanity; EditPage should trim already
  
 -                      $changed = ( strcmp( $text, $oldtext ) != 0 );
 +                      $changed = !$content->equals( $old_content );
  
                        if ( $changed ) {
 +                              if ( !$content->isValid() ) {
 +                                      throw new MWException( "New content failed validity check!" );
 +                              }
 +
                                $dbw->begin( __METHOD__ );
 +
 +                              $prepStatus = $content->prepareSave( $this, $flags, $baseRevId, $user );
 +                              $status->merge( $prepStatus );
 +
 +                              if ( !$status->isOK() ) {
 +                                      $dbw->rollback();
 +
 +                                      wfProfileOut( __METHOD__ );
 +                                      return $status;
 +                              }
 +
                                $revisionId = $revision->insertOn( $dbw );
  
                                # Update page
                                $ok = $this->updateRevisionOn( $dbw, $revision, $oldid, $oldIsRedirect );
  
                                if ( !$ok ) {
-                                       /* Belated edit conflict! Run away!! */
+                                       # Belated edit conflict! Run away!!
                                        $status->fatal( 'edit-conflict' );
  
-                                       $revisionId = 0;
                                        $dbw->rollback( __METHOD__ );
-                               } else {
-                                       global $wgUseRCPatrol;
-                                       wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, $baseRevId, $user ) );
-                                       # Update recentchanges
-                                       if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
-                                               # Mark as patrolled if the user can do so
-                                               $patrolled = $wgUseRCPatrol && !count(
-                                                       $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) );
-                                               # Add RC row to the DB
-                                               $rc = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $user, $summary,
-                                                       $oldid, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
-                                                       $revisionId, $patrolled
-                                               );
-                                               # Log auto-patrolled edits
-                                               if ( $patrolled ) {
-                                                       PatrolLog::record( $rc, true, $user );
-                                               }
+                                       wfProfileOut( __METHOD__ );
+                                       return $status;
+                               }
+                               wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, $baseRevId, $user ) );
+                               # Update recentchanges
+                               if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
+                                       # Mark as patrolled if the user can do so
+                                       $patrolled = $wgUseRCPatrol && !count(
+                                               $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) );
+                                       # Add RC row to the DB
+                                       $rc = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $user, $summary,
+                                               $oldid, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
+                                               $revisionId, $patrolled
+                                       );
+                                       # Log auto-patrolled edits
+                                       if ( $patrolled ) {
+                                               PatrolLog::record( $rc, true, $user );
                                        }
-                                       $user->incEditCount();
-                                       $dbw->commit( __METHOD__ );
                                }
+                               $user->incEditCount();
+                               $dbw->commit( __METHOD__ );
                        } else {
                                // Bug 32948: revision ID must be set to page {{REVISIONID}} and
                                // related variables correctly
                                $revision->setId( $this->getLatest() );
                        }
  
-                       // Now that ignore_user_abort is restored, we can respond to fatal errors
-                       if ( !$status->isOK() ) {
-                               wfProfileOut( __METHOD__ );
-                               return $status;
-                       }
                        # Update links tables, site stats, etc.
 -                      $this->doEditUpdates( $revision, $user, array( 'changed' => $changed,
 -                              'oldcountable' => $oldcountable ) );
 +                      $this->doEditUpdates(
 +                              $revision,
 +                              $user,
 +                              array(
 +                                      'changed' => $changed,
 +                                      'oldcountable' => $oldcountable
 +                              )
 +                      );
  
                        if ( !$changed ) {
                                $status->warning( 'edit-no-change' );
  
                        $dbw->begin( __METHOD__ );
  
 +                      $prepStatus = $content->prepareSave( $this, $flags, $baseRevId, $user );
 +                      $status->merge( $prepStatus );
 +
 +                      if ( !$status->isOK() ) {
 +                              $dbw->rollback();
 +
 +                              wfProfileOut( __METHOD__ );
 +                              return $status;
 +                      }
 +
 +                      $status->merge( $prepStatus );
 +
                        # Add the page record; stake our claim on this title!
                        # This will return false if the article already exists
                        $newid = $this->insertOn( $dbw );
                                'page'       => $newid,
                                'comment'    => $summary,
                                'minor_edit' => $isminor,
 -                              'text'       => $text,
 +                              'text'       => $serialized,
 +                              'len'        => $newsize,
                                'user'       => $user->getId(),
                                'user_text'  => $user->getName(),
 -                              'timestamp'  => $now
 +                              'timestamp'  => $now,
 +                              'content_model' => $content->getModel(),
 +                              'content_format' => $serialisation_format,
                        ) );
                        $revisionId = $revision->insertOn( $dbw );
  
                        # Bug 37225: use accessor to get the text as Revision may trim it
 -                      $text = $revision->getText(); // sanity; EditPage should trim already
 +                      $content = $revision->getContent(); // sanity; get normalized version
  
                        # Update the page record with revision data
                        $this->updateRevisionOn( $dbw, $revision, 0 );
  
                        # Update recentchanges
                        if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
-                               global $wgUseRCPatrol, $wgUseNPPatrol;
                                # Mark as patrolled if the user can do so
                                $patrolled = ( $wgUseRCPatrol || $wgUseNPPatrol ) && !count(
                                        $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) );
                                # Add RC row to the DB
                                $rc = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $user, $summary, $bot,
 -                                      '', strlen( $text ), $revisionId, $patrolled );
 +                                      '', $content->getSize(), $revisionId, $patrolled );
  
                                # Log auto-patrolled edits
                                if ( $patrolled ) {
                        # Update links, etc.
                        $this->doEditUpdates( $revision, $user, array( 'created' => true ) );
  
 -                      wfRunHooks( 'ArticleInsertComplete', array( &$this, &$user, $text, $summary,
 +                      wfRunHooks( 'ArticleInsertComplete', array( &$this, &$user, $serialized, $summary,
 +                              $flags & EDIT_MINOR, null, null, &$flags, $revision ) );
 +
 +                      wfRunHooks( 'ArticleContentInsertComplete', array( &$this, &$user, $content, $summary,
                                $flags & EDIT_MINOR, null, null, &$flags, $revision ) );
                }
  
                // Return the new revision (or null) to the caller
                $status->value['revision'] = $revision;
  
 -              wfRunHooks( 'ArticleSaveComplete', array( &$this, &$user, $text, $summary,
 +              wfRunHooks( 'ArticleSaveComplete', array( &$this, &$user, $serialized, $summary,
 +                      $flags & EDIT_MINOR, null, null, &$flags, $revision, &$status, $baseRevId ) );
 +
 +              wfRunHooks( 'ArticleContentSaveComplete', array( &$this, &$user, $content, $summary,
                        $flags & EDIT_MINOR, null, null, &$flags, $revision, &$status, $baseRevId ) );
  
                # Promote user to any groups they meet the criteria for
        /**
         * Prepare text which is about to be saved.
         * Returns a stdclass with source, pst and output members
 -       * @return bool|object
 +       *
 +       * @deprecated in 1.WD: use prepareContentForEdit instead.
         */
        public function prepareTextForEdit( $text, $revid = null, User $user = null ) {
 +              wfDeprecated( __METHOD__, '1.WD' );
 +              $content = ContentHandler::makeContent( $text, $this->getTitle() );
 +              return $this->prepareContentForEdit( $content, $revid , $user );
 +      }
 +
 +      /**
 +       * Prepare content which is about to be saved.
 +       * Returns a stdclass with source, pst and output members
 +       *
 +       * @param \Content $content
 +       * @param null $revid
 +       * @param null|\User $user
 +       * @param null $serialization_format
 +       *
 +       * @return bool|object
 +       *
 +       * @since 1.WD
 +       */
 +      public function prepareContentForEdit( Content $content, $revid = null, User $user = null, $serialization_format = null ) {
                global $wgParser, $wgContLang, $wgUser;
                $user = is_null( $user ) ? $wgUser : $user;
                // @TODO fixme: check $user->getId() here???
 +
                if ( $this->mPreparedEdit
 -                      && $this->mPreparedEdit->newText == $text
 +                      && $this->mPreparedEdit->newContent
 +                      && $this->mPreparedEdit->newContent->equals( $content )
                        && $this->mPreparedEdit->revid == $revid
 +                      && $this->mPreparedEdit->format == $serialization_format
 +                      #XXX: also check $user here?
                ) {
                        // Already prepared
                        return $this->mPreparedEdit;
  
                $edit = (object)array();
                $edit->revid = $revid;
 -              $edit->newText = $text;
 -              $edit->pst = $wgParser->preSaveTransform( $text, $this->mTitle, $user, $popts );
 +
 +              $edit->pstContent = $content->preSaveTransform( $this->mTitle, $user, $popts );
 +              $edit->pst = $edit->pstContent->serialize( $serialization_format ); #XXX: do we need this??
 +              $edit->format = $serialization_format;
 +
                $edit->popts = $this->makeParserOptions( 'canonical' );
 -              $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid );
 -              $edit->oldText = $this->getRawText();
 +
 +              $edit->output = $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts );
 +
 +              $edit->newContent = $content;
 +              $edit->oldContent = $this->getContent( Revision::RAW );
 +
 +              #NOTE: B/C for hooks! don't use these fields!
 +              $edit->newText = ContentHandler::getContentText( $edit->newContent );
 +              $edit->oldText = $edit->oldContent ? ContentHandler::getContentText( $edit->oldContent ) : '';
  
                $this->mPreparedEdit = $edit;
  
         * Purges pages that include this page if the text was changed here.
         * Every 100th edit, prune the recent changes table.
         *
 -       * @private
         * @param $revision Revision object
         * @param $user User object that did the revision
         * @param $options Array of options, following indexes are used:
                wfProfileIn( __METHOD__ );
  
                $options += array( 'changed' => true, 'created' => false, 'oldcountable' => null );
 -              $text = $revision->getText();
 +              $content = $revision->getContent();
  
                # Parse the text
                # Be careful not to double-PST: $text is usually already PST-ed once
                if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) {
                        wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" );
 -                      $editInfo = $this->prepareTextForEdit( $text, $revision->getId(), $user );
 +                      $editInfo = $this->prepareContentForEdit( $content, $revision->getId(), $user );
                } else {
                        wfDebug( __METHOD__ . ": No vary-revision, using prepared edit...\n" );
                        $editInfo = $this->mPreparedEdit;
                }
  
                # Update the links tables and other secondary data
 -              $updates = $editInfo->output->getSecondaryDataUpdates( $this->mTitle );
 +              $updates = $content->getSecondaryDataUpdates( $this->getTitle(), null, true, $editInfo->output );
                DataUpdate::runUpdates( $updates );
  
                wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $options['changed'] ) );
                }
  
                DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, $good, $total ) );
 -              DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $text ) );
 +              DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content->getTextForSearchIndex() ) ); #TODO: let the search engine decide what to do with the content object
  
                # If this is another user's talk page, update newtalk.
                # Don't do this if $options['changed'] = false (null-edits) nor if
                }
  
                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 -                      MessageCache::singleton()->replace( $shortTitle, $text );
 +                      $msgtext = $content->getWikitextForTransclusion(); #XXX: could skip pseudo-messages like js/css here, based on content model.
 +                      if ( $msgtext === false || $msgtext === null ) $msgtext = '';
 +
 +                      MessageCache::singleton()->replace( $shortTitle, $msgtext );
                }
  
                if( $options['created'] ) {
         * @param $user User The relevant user
         * @param $comment String: comment submitted
         * @param $minor Boolean: whereas it's a minor modification
 +       *
 +       * @deprecated since 1.WD, use doEditContent() instead.
         */
        public function doQuickEdit( $text, User $user, $comment = '', $minor = 0 ) {
 +              wfDeprecated( __METHOD__, "1.WD" );
 +
 +              $content = ContentHandler::makeContent( $text, $this->getTitle() );
 +              return $this->doQuickEditContent( $content, $user, $comment , $minor );
 +      }
 +
 +      /**
 +       * Edit an article without doing all that other stuff
 +       * The article must already exist; link tables etc
 +       * are not updated, caches are not flushed.
 +       *
 +       * @param $content Content: content submitted
 +       * @param $user User The relevant user
 +       * @param $comment String: comment submitted
 +       * @param $serialisation_format String: format for storing the content in the database
 +       * @param $minor Boolean: whereas it's a minor modification
 +       */
 +      public function doQuickEditContent( Content $content, User $user, $comment = '', $minor = 0, $serialisation_format = null ) {
                wfProfileIn( __METHOD__ );
  
 +              $serialized = $content->serialize( $serialisation_format );
 +
                $dbw = wfGetDB( DB_MASTER );
                $revision = new Revision( array(
                        'page'       => $this->getId(),
 -                      'text'       => $text,
 +                      'text'       => $serialized,
 +                      'length'     => $content->getSize(),
                        'comment'    => $comment,
                        'minor_edit' => $minor ? 1 : 0,
 -              ) );
 +              ) ); #XXX: set the content object?
                $revision->insertOn( $dbw );
                $this->updateRevisionOn( $dbw, $revision );
  
        public function doDeleteArticleReal(
                $reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null
        ) {
 -              global $wgUser;
 +              global $wgUser, $wgContentHandlerUseDB;
  
                wfDebug( __METHOD__ . "\n" );
  
                        $bitfield = 'rev_deleted';
                }
  
 +              // we need to remember the old content so we can use it to generate all deletion updates.
 +              $content = $this->getContent( Revision::RAW );
 +
                $dbw = wfGetDB( DB_MASTER );
                $dbw->begin( __METHOD__ );
                // For now, shunt the revision data into the archive table.
                //
                // In the future, we may keep revisions and mark them with
                // the rev_deleted field, which is reserved for this purpose.
 +
 +              $row = array(
 +                      'ar_namespace'  => 'page_namespace',
 +                      'ar_title'      => 'page_title',
 +                      'ar_comment'    => 'rev_comment',
 +                      'ar_user'       => 'rev_user',
 +                      'ar_user_text'  => 'rev_user_text',
 +                      'ar_timestamp'  => 'rev_timestamp',
 +                      'ar_minor_edit' => 'rev_minor_edit',
 +                      'ar_rev_id'     => 'rev_id',
 +                      'ar_parent_id'  => 'rev_parent_id',
 +                      'ar_text_id'    => 'rev_text_id',
 +                      'ar_text'       => '\'\'', // Be explicit to appease
 +                      'ar_flags'      => '\'\'', // MySQL's "strict mode"...
 +                      'ar_len'        => 'rev_len',
 +                      'ar_page_id'    => 'page_id',
 +                      'ar_deleted'    => $bitfield,
 +                      'ar_sha1'       => 'rev_sha1',
 +              );
 +
 +              if ( $wgContentHandlerUseDB ) {
 +                      $row[ 'ar_content_model' ] = 'rev_content_model';
 +                      $row[ 'ar_content_format' ] = 'rev_content_format';
 +              }
 +
                $dbw->insertSelect( 'archive', array( 'page', 'revision' ),
 +                      $row,
                        array(
 -                              'ar_namespace'  => 'page_namespace',
 -                              'ar_title'      => 'page_title',
 -                              'ar_comment'    => 'rev_comment',
 -                              'ar_user'       => 'rev_user',
 -                              'ar_user_text'  => 'rev_user_text',
 -                              'ar_timestamp'  => 'rev_timestamp',
 -                              'ar_minor_edit' => 'rev_minor_edit',
 -                              'ar_rev_id'     => 'rev_id',
 -                              'ar_parent_id'  => 'rev_parent_id',
 -                              'ar_text_id'    => 'rev_text_id',
 -                              'ar_text'       => '\'\'', // Be explicit to appease
 -                              'ar_flags'      => '\'\'', // MySQL's "strict mode"...
 -                              'ar_len'        => 'rev_len',
 -                              'ar_page_id'    => 'page_id',
 -                              'ar_deleted'    => $bitfield,
 -                              'ar_sha1'       => 'rev_sha1'
 -                      ), array(
                                'page_id' => $id,
                                'page_id = rev_page'
                        ), __METHOD__
                        return $status;
                }
  
 -              $this->doDeleteUpdates( $id );
 +              $this->doDeleteUpdates( $id, $content );
  
                # Log the deletion, if the page was suppressed, log it at Oversight instead
                $logtype = $suppress ? 'suppress' : 'delete';
         * Do some database updates after deletion
         *
         * @param $id Int: page_id value of the page being deleted (B/C, currently unused)
 +       * @param $content Content: optional page content to be used when determining the required updates.
 +       *        This may be needed because $this->getContent() may already return null when the page proper was deleted.
         */
 -      public function doDeleteUpdates( $id ) {
 +      public function doDeleteUpdates( $id, Content $content = null ) {
                # update site status
                DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, - (int)$this->isCountable(), -1 ) );
  
                # remove secondary indexes, etc
 -              $updates = $this->getDeletionUpdates( );
 +              $updates = $this->getDeletionUpdates( $content );
                DataUpdate::runUpdates( $updates );
  
                # Clear caches
                $this->mTitle->resetArticleID( 0 );
        }
  
 -      public function getDeletionUpdates() {
 -              $updates = array(
 -                      new LinksDeletionUpdate( $this ),
 -              );
 -
 -              //@todo: make a hook to add update objects
 -              //NOTE: deletion updates will be determined by the ContentHandler in the future
 -              return $updates;
 -      }
 -
        /**
         * Roll back the most recent consecutive set of edits to a page
         * from the same user; fails if there are no eligible edits to
                }
  
                # Actually store the edit
 -              $status = $this->doEdit( $target->getText(), $summary, $flags, $target->getId(), $guser );
 +              $status = $this->doEditContent( $target->getContent(), $summary, $flags, $target->getId(), $guser );
                if ( !empty( $status->value['revision'] ) ) {
                        $revId = $status->value['revision']->getId();
                } else {
  
        /**
        * Return an applicable autosummary if one exists for the given edit.
 -      * @param $oldtext String: the previous text of the page.
 -      * @param $newtext String: The submitted text of the page.
 +      * @param $oldtext String|null: the previous text of the page.
 +      * @param $newtext String|null: The submitted text of the page.
        * @param $flags Int bitmask: a bitmask of flags submitted for the edit.
        * @return string An appropriate autosummary, or an empty string.
 +      *
 +      * @deprecated since 1.WD, use ContentHandler::getAutosummary() instead
        */
        public static function getAutosummary( $oldtext, $newtext, $flags ) {
 -              global $wgContLang;
 +              # NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't.
  
 -              # Decide what kind of autosummary is needed.
 +              wfDeprecated( __METHOD__, '1.WD' );
  
 -              # Redirect autosummaries
 -              $ot = Title::newFromRedirect( $oldtext );
 -              $rt = Title::newFromRedirect( $newtext );
 -
 -              if ( is_object( $rt ) && ( !is_object( $ot ) || !$rt->equals( $ot ) || $ot->getFragment() != $rt->getFragment() ) ) {
 -                      $truncatedtext = $wgContLang->truncate(
 -                              str_replace( "\n", ' ', $newtext ),
 -                              max( 0, 255
 -                                      - strlen( wfMsgForContent( 'autoredircomment' ) )
 -                                      - strlen( $rt->getFullText() )
 -                              ) );
 -                      return wfMsgForContent( 'autoredircomment', $rt->getFullText(), $truncatedtext );
 -              }
 -
 -              # New page autosummaries
 -              if ( $flags & EDIT_NEW && strlen( $newtext ) ) {
 -                      # If they're making a new article, give its text, truncated, in the summary.
 -
 -                      $truncatedtext = $wgContLang->truncate(
 -                              str_replace( "\n", ' ', $newtext ),
 -                              max( 0, 200 - strlen( wfMsgForContent( 'autosumm-new' ) ) ) );
 -
 -                      return wfMsgForContent( 'autosumm-new', $truncatedtext );
 -              }
 +              $handler = ContentHandler::getForModelID( CONTENT_MODEL_WIKITEXT );
 +              $oldContent = is_null( $oldtext ) ? null : $handler->unserializeContent( $oldtext );
 +              $newContent = is_null( $newtext ) ? null : $handler->unserializeContent( $newtext );
  
 -              # Blanking autosummaries
 -              if ( $oldtext != '' && $newtext == '' ) {
 -                      return wfMsgForContent( 'autosumm-blank' );
 -              } elseif ( strlen( $oldtext ) > 10 * strlen( $newtext ) && strlen( $newtext ) < 500 ) {
 -                      # Removing more than 90% of the article
 -
 -                      $truncatedtext = $wgContLang->truncate(
 -                              $newtext,
 -                              max( 0, 200 - strlen( wfMsgForContent( 'autosumm-replace' ) ) ) );
 -
 -                      return wfMsgForContent( 'autosumm-replace', $truncatedtext );
 -              }
 -
 -              # If we reach this point, there's no applicable autosummary for our case, so our
 -              # autosummary is empty.
 -              return '';
 +              return $handler->getAutosummary( $oldContent, $newContent, $flags );
        }
  
        /**
         *    if no revision occurred
         */
        public function getAutoDeleteReason( &$hasHistory ) {
 -              global $wgContLang;
 -
 -              // Get the last revision
 -              $rev = $this->getRevision();
 -
 -              if ( is_null( $rev ) ) {
 -                      return false;
 -              }
 -
 -              // Get the article's contents
 -              $contents = $rev->getText();
 -              $blank = false;
 -
 -              // If the page is blank, use the text from the previous revision,
 -              // which can only be blank if there's a move/import/protect dummy revision involved
 -              if ( $contents == '' ) {
 -                      $prev = $rev->getPrevious();
 -
 -                      if ( $prev )    {
 -                              $contents = $prev->getText();
 -                              $blank = true;
 -                      }
 -              }
 -
 -              $dbw = wfGetDB( DB_MASTER );
 -
 -              // Find out if there was only one contributor
 -              // Only scan the last 20 revisions
 -              $res = $dbw->select( 'revision', 'rev_user_text',
 -                      array( 'rev_page' => $this->getID(), $dbw->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' ),
 -                      __METHOD__,
 -                      array( 'LIMIT' => 20 )
 -              );
 -
 -              if ( $res === false ) {
 -                      // This page has no revisions, which is very weird
 -                      return false;
 -              }
 -
 -              $hasHistory = ( $res->numRows() > 1 );
 -              $row = $dbw->fetchObject( $res );
 -
 -              if ( $row ) { // $row is false if the only contributor is hidden
 -                      $onlyAuthor = $row->rev_user_text;
 -                      // Try to find a second contributor
 -                      foreach ( $res as $row ) {
 -                              if ( $row->rev_user_text != $onlyAuthor ) { // Bug 22999
 -                                      $onlyAuthor = false;
 -                                      break;
 -                              }
 -                      }
 -              } else {
 -                      $onlyAuthor = false;
 -              }
 -
 -              // Generate the summary with a '$1' placeholder
 -              if ( $blank ) {
 -                      // The current revision is blank and the one before is also
 -                      // blank. It's just not our lucky day
 -                      $reason = wfMsgForContent( 'exbeforeblank', '$1' );
 -              } else {
 -                      if ( $onlyAuthor ) {
 -                              $reason = wfMsgForContent( 'excontentauthor', '$1', $onlyAuthor );
 -                      } else {
 -                              $reason = wfMsgForContent( 'excontent', '$1' );
 -                      }
 -              }
 -
 -              if ( $reason == '-' ) {
 -                      // Allow these UI messages to be blanked out cleanly
 -                      return '';
 -              }
 -
 -              // Replace newlines with spaces to prevent uglyness
 -              $contents = preg_replace( "/[\n\r]/", ' ', $contents );
 -              // Calculate the maximum amount of chars to get
 -              // Max content length = max comment length - length of the comment (excl. $1)
 -              $maxLength = 255 - ( strlen( $reason ) - 2 );
 -              $contents = $wgContLang->truncate( $contents, $maxLength );
 -              // Remove possible unfinished links
 -              $contents = preg_replace( '/\[\[([^\]]*)\]?$/', '$1', $contents );
 -              // Now replace the '$1' placeholder
 -              $reason = str_replace( '$1', $contents, $reason );
 -
 -              return $reason;
 +              return $this->getContentHandler()->getAutoDeleteReason( $this->getTitle(), $hasHistory );
        }
  
        /**
                global $wgUser;
                return $this->isParserCacheUsed( ParserOptions::newFromUser( $wgUser ), $oldid );
        }
 +
 +      /**
 +       * Returns a list of updates to be performed when this page is deleted. The updates should remove any information
 +       * about this page from secondary data stores such as links tables.
 +       *
 +       * @param Content|null $content optional Content object for determining the necessary updates
 +       * @return Array an array of DataUpdates objects
 +       */
 +      public function getDeletionUpdates( Content $content = null ) {
 +              if ( !$content ) {
 +                      // load content object, which may be used to determine the necessary updates
 +                      // XXX: the content may not be needed to determine the updates, then this would be overhead.
 +                      $content = $this->getContent( Revision::RAW );
 +              }
 +
 +              if ( !$content ) {
 +                      $updates = array();
 +              } else {
 +                      $updates = $content->getDeletionUpdates( $this->mTitle );
 +              }
 +
 +              wfRunHooks( 'WikiPageDeletionUpdates', array( $this, $content, &$updates ) );
 +              return $updates;
 +      }
 +
  }
  
  class PoolWorkArticleView extends PoolCounterWork {
        private $parserOptions;
  
        /**
 -       * @var string|null
 +       * @var Content|null
         */
 -      private $text;
 +      private $content = null;
  
        /**
         * @var ParserOutput|bool
         * @param $revid Integer: ID of the revision being parsed
         * @param $useParserCache Boolean: whether to use the parser cache
         * @param $parserOptions parserOptions to use for the parse operation
 -       * @param $text String: text to parse or null to load it
 +       * @param $content Content|String: content to parse or null to load it; may also be given as a wikitext string, for BC
         */
 -      function __construct( Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $text = null ) {
 +      function __construct( Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $content = null ) {
 +              if ( is_string($content) ) { #BC: old style call
 +                      $modelId = $page->getRevision()->getContentModel();
 +                      $format = $page->getRevision()->getContentFormat();
 +                      $content = ContentHandler::makeContent( $content, $page->getTitle(), $modelId, $format );
 +              }
 +
                $this->page = $page;
                $this->revid = $revid;
                $this->cacheable = $useParserCache;
                $this->parserOptions = $parserOptions;
 -              $this->text = $text;
 +              $this->content = $content;
                $this->cacheKey = ParserCache::singleton()->getKey( $page, $parserOptions );
                parent::__construct( 'ArticleView', $this->cacheKey . ':revid:' . $revid );
        }
         * @return bool
         */
        function doWork() {
 -              global $wgParser, $wgUseFileCache;
 +              global $wgUseFileCache;
 +
 +              // @todo: several of the methods called on $this->page are not declared in Page, but present in WikiPage and delegated by Article.
  
                $isCurrent = $this->revid === $this->page->getLatest();
  
 -              if ( $this->text !== null ) {
 -                      $text = $this->text;
 +              if ( $this->content !== null ) {
 +                      $content = $this->content;
                } elseif ( $isCurrent ) {
 -                      $text = $this->page->getRawText();
 +                      $content = $this->page->getContent( Revision::RAW ); #XXX: why use RAW audience here, and PUBLIC (default) below?
                } else {
                        $rev = Revision::newFromTitle( $this->page->getTitle(), $this->revid );
                        if ( $rev === null ) {
                                return false;
                        }
 -                      $text = $rev->getText();
 +                      $content = $rev->getContent(); #XXX: why use PUBLIC audience here (default), and RAW above?
                }
  
                $time = - microtime( true );
 -              $this->parserOutput = $wgParser->parse( $text, $this->page->getTitle(),
 -                      $this->parserOptions, true, true, $this->revid );
 +              $this->parserOutput = $content->getParserOutput( $this->page->getTitle(), $this->revid, $this->parserOptions );
                $time += microtime( true );
  
                # Timing hack
                return false;
        }
  }
 +
@@@ -38,7 -38,7 +38,7 @@@ class DifferenceEngine extends ContextS
         * @private
         */
        var $mOldid, $mNewid;
 -      var $mOldtext, $mNewtext;
 +      var $mOldContent, $mNewContent;
        protected $mDiffLang;
  
        /**
                # If external diffs are enabled both globally and for the user,
                # we'll use the application/x-external-editor interface to call
                # an external diff tool like kompare, kdiff3, etc.
 -              if ( ExternalEdit::useExternalEngine( $this->getContext(), 'diff' ) ) {
 +              if ( ExternalEdit::useExternalEngine( $this->getContext(), 'diff' ) ) { #FIXME: how to handle this for non-text content?
                        $urls = array(
                                'File' => array( 'Extension' => 'wiki', 'URL' =>
                                        # This should be mOldPage, but it may not be set, see below.
                        $out->setRevisionTimestamp( $this->mNewRev->getTimestamp() );
                        $out->setArticleFlag( true );
  
 -                      if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) {
 +                      if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) { #NOTE: only needed for B/C: custom rendering of JS/CSS via hook
                                // Stolen from Article::view --AG 2007-10-11
                                // Give hooks a chance to customise the output
                                // @TODO: standardize this crap into one function
 -                              if ( wfRunHooks( 'ShowRawCssJs', array( $this->mNewtext, $this->mNewPage, $out ) ) ) {
 -                                      // Wrap the whole lot in a <pre> and don't parse
 -                                      $m = array();
 -                                      preg_match( '!\.(css|js)$!u', $this->mNewPage->getText(), $m );
 -                                      $out->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
 -                                      $out->addHTML( htmlspecialchars( $this->mNewtext ) );
 -                                      $out->addHTML( "\n</pre>\n" );
 +                              if ( !Hook::isRegistered( 'ShowRawCssJs' )
 +                                      || wfRunHooks( 'ShowRawCssJs', array( ContentHandler::getContentText( $this->mNewContent ), $this->mNewPage, $out ) ) ) { #NOTE: deperecated hook, B/C only
 +                                      // use the content object's own rendering
 +                                      $po = $this->mContentObject->getParserOutput();
 +                                      $out->addHTML( $po->getText() );
                                }
 -                      } elseif ( !wfRunHooks( 'ArticleViewCustom', array( $this->mNewtext, $this->mNewPage, $out ) ) ) {
 +                      } elseif( !wfRunHooks( 'ArticleContentViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
 +                              // Handled by extension
 +                      } elseif( Hooks::isRegistered( 'ArticleViewCustom' )
 +                                      && !wfRunHooks( 'ArticleViewCustom', array( ContentHandler::getContentText( $this->mNewContent ), $this->mNewPage, $out ) ) ) { #NOTE: deperecated hook, B/C only
                                // Handled by extension
                        } else {
                                // Normal page
                                        $wikiPage = WikiPage::factory( $this->mNewPage );
                                }
  
 -                              $parserOptions = ParserOptions::newFromContext( $this->getContext() );
 -                              $parserOptions->enableLimitReport();
 -                              $parserOptions->setTidy( true );
 -
 -                              if ( !$this->mNewRev->isCurrent() ) {
 -                                      $parserOptions->setEditSection( false );
 -                              }
 -
 -                              $parserOutput = $wikiPage->getParserOutput( $parserOptions, $this->mNewid );
 +                              $parserOutput = $this->getParserOutput( $wikiPage, $this->mNewRev );
  
                                # WikiPage::getParserOutput() should not return false, but just in case
                                if( $parserOutput ) {
                wfProfileOut( __METHOD__ );
        }
  
 +      protected function getParserOutput( WikiPage $page, Revision $rev ) {
 +              $parserOptions = ParserOptions::newFromContext( $this->getContext() );
 +              $parserOptions->enableLimitReport();
 +              $parserOptions->setTidy( true );
 +
 +              if ( !$rev->isCurrent() || !$rev->getTitle()->quickUserCan( "edit" ) ) {
 +                      $parserOptions->setEditSection( false );
 +              }
 +
 +              $parserOutput = $page->getParserOutput( $parserOptions, $rev->getId() );
 +              return $parserOutput;
 +      }
 +
        /**
         * Get the diff text, send it to the OutputPage object
         * Returns false if the diff could not be generated, otherwise returns true
                        return false;
                }
  
 -              $difftext = $this->generateDiffBody( $this->mOldtext, $this->mNewtext );
 +              $difftext = $this->generateContentDiffBody( $this->mOldContent, $this->mNewContent );
  
                // Save to cache for 7 days
                if ( !wfRunHooks( 'AbortDiffCache', array( &$this ) ) ) {
                }
        }
  
 +      /**
 +       * Generate a diff, no caching.
 +       *
 +       * Subclasses may override this to provide a
 +       *
 +       * @param $old Content: old content
 +       * @param $new Content: new content
 +       *
 +       * @since 1.WD
 +       */
 +      function generateContentDiffBody( Content $old, Content $new ) {
 +              #XXX: generate a warning if $old or $new are not instances of TextContent?
 +              #XXX: fail if $old and $new don't have the same content model? or what?
 +
 +              $otext = $old->serialize();
 +              $ntext = $new->serialize();
 +
 +              #XXX: text should be "already segmented". what does that mean?
 +              return $this->generateTextDiffBody( $otext, $ntext );
 +      }
 +
        /**
         * Generate a diff, no caching
         *
         * @param $otext String: old text, must be already segmented
         * @param $ntext String: new text, must be already segmented
 -       * @return bool|string
 +       * @deprecated since 1.WD, use generateContentDiffBody() instead!
         */
        function generateDiffBody( $otext, $ntext ) {
 +              wfDeprecated( __METHOD__, "1.WD" );
 +
 +              return $this->generateTextDiffBody( $otext, $ntext );
 +      }
 +
 +      /**
 +       * Generate a diff, no caching
 +       *
 +       * @todo move this to TextDifferenceEngine, make DifferenceEngine abstract. At some point.
 +       *
 +       * @param $otext String: old text, must be already segmented
 +       * @param $ntext String: new text, must be already segmented
 +       * @return bool|string
 +       */
 +      function generateTextDiffBody( $otext, $ntext ) {
                global $wgExternalDiffEngine, $wgContLang;
  
                wfProfileIn( __METHOD__ );
         *        the visibility of the revision and a link to edit the page.
         * @return String HTML fragment
         */
 -      private function getRevisionHeader( Revision $rev, $complete = '' ) {
 +      protected function getRevisionHeader( Revision $rev, $complete = '' ) {
                $lang = $this->getLanguage();
                $user = $this->getUser();
                $revtimestamp = $rev->getTimestamp();
                        }
  
                        $msg = $this->msg( $title->quickUserCan( 'edit', $user ) ? 'editold' : 'viewsourceold' )->escaped();
-                       $header .= ' (' . Linker::linkKnown( $title, $msg, array(), $editQuery ) . ')';
+                       $header .= ' ' . $this->msg( 'parentheses' )->rawParams(
+                               Linker::linkKnown( $title, $msg, array(), $editQuery ) )->plain();
                        if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
                                $header = Html::rawElement( 'span', array( 'class' => 'history-deleted' ), $header );
                        }
  
        /**
         * Use specified text instead of loading from the database
 +       * @deprecated since 1.WD
         */
 -      function setText( $oldText, $newText ) {
 -              $this->mOldtext = $oldText;
 -              $this->mNewtext = $newText;
 +      function setText( $oldText, $newText ) { #FIXME: no longer use this, use setContent()!
 +              wfDeprecated( __METHOD__, "1.WD" );
 +
 +              $oldContent = ContentHandler::makeContent( $oldText, $this->getTitle() );
 +              $newContent = ContentHandler::makeContent( $newText, $this->getTitle() );
 +
 +              $this->setContent( $oldContent, $newContent );
 +      }
 +
 +      /**
 +       * Use specified text instead of loading from the database
 +       * @since 1.WD
 +       */
 +      function setContent( Content $oldContent, Content $newContent ) {
 +              $this->mOldContent = $oldContent;
 +              $this->mNewContent = $newContent;
 +
                $this->mTextLoaded = 2;
                $this->mRevisionsLoaded = true;
        }
                        return false;
                }
                if ( $this->mOldRev ) {
 -                      $this->mOldtext = $this->mOldRev->getText( Revision::FOR_THIS_USER );
 -                      if ( $this->mOldtext === false ) {
 +                      $this->mOldContent = $this->mOldRev->getContent( Revision::FOR_THIS_USER );
 +                      if ( $this->mOldContent === false ) {
                                return false;
                        }
                }
                if ( $this->mNewRev ) {
 -                      $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER );
 -                      if ( $this->mNewtext === false ) {
 +                      $this->mNewContent = $this->mNewRev->getContent( Revision::FOR_THIS_USER );
 +                      if ( $this->mNewContent === false ) {
                                return false;
                        }
                }
                if ( !$this->loadRevisionData() ) {
                        return false;
                }
 -              $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER );
 +              $this->mNewContent = $this->mNewRev->getContent( Revision::FOR_THIS_USER );
                return true;
        }
  }
@@@ -55,28 -55,22 +55,29 @@@ class OracleUpdater extends DatabaseUpd
  
                        //1.19
                        array( 'addIndex', 'logging',       'i05',      'patch-logging_type_action_index.sql'),
-                       array( 'addTable', 'globaltemplatelinks', 'patch-globaltemplatelinks.sql' ),
-                       array( 'addTable', 'globalnamespaces', 'patch-globalnamespaces.sql' ),
-                       array( 'addTable', 'globalinterwiki', 'patch-globalinterwiki.sql' ),
                        array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1_field.sql' ),
                        array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1_field.sql' ),
                        array( 'doRemoveNotNullEmptyDefaults2' ),
                        array( 'addIndex', 'page', 'i03', 'patch-page_redirect_namespace_len.sql' ),
-                       array( 'modifyField', 'user', 'ug_group', 'patch-ug_group-length-increase.sql' ),
+                       array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase.sql' ),
                        array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-us_chunk_inx_field.sql' ),
                        array( 'addField', 'job', 'job_timestamp', 'patch-job_timestamp_field.sql' ),
                        array( 'addIndex', 'job', 'i02', 'patch-job_timestamp_index.sql' ),
+                       array( 'doPageRestrictionsPKUKFix' ),
+                       array( 'modifyField', 'user_former_groups', 'ufg_group', 'patch-ufg_group-length-increase.sql' ),
  
                        //1.20
                        array( 'addTable', 'config', 'patch-config.sql' ),
+                       array( 'addIndex', 'ipblocks', 'i05', 'patch-ipblocks_i05_index.sql' ),
+                       array( 'addIndex', 'revision', 'i05', 'patch-revision_i05_index.sql' ),
  
 +                      //1.WD
 +                      array( 'addField',      'revision',     'rev_content_format',           'patch-revision-rev_content_format.sql' ),
 +                      array( 'addField',      'revision',     'rev_content_model',            'patch-revision-rev_content_model.sql' ),
 +                      array( 'addField',      'archive',      'ar_content_format',            'patch-archive-ar_content_format.sql' ),
 +                      array( 'addField',      'archive',      'ar_content_model',                 'patch-archive-ar_content_model.sql' ),
 +                      array( 'addField',      'page',     'page_content_model',               'patch-page-page_content_model.sql' ),
 +
                        // KEEP THIS AT THE BOTTOM!!
                        array( 'doRebuildDuplicateFunction' ),
  
                $this->output( "ok\n" );
        }
  
+       /**
+        * Fixed wrong PK, UK definition
+        */
+       protected function doPageRestrictionsPKUKFix() {
+               $this->output( "Altering PAGE_RESTRICTIONS keys ... " );
+               $meta = $this->db->query( 'SELECT column_name FROM all_cons_columns WHERE owner = \''.strtoupper($this->db->getDBname()).'\' AND constraint_name = \'MW_PAGE_RESTRICTIONS_PK\' AND rownum = 1' );
+               $row = $meta->fetchRow();
+               if ( $row['column_name'] == 'PR_ID' ) {
+                       $this->output( "seems to be up to date.\n" );
+                       return;
+               }
+               $this->applyPatch( 'patch-page_restrictions_pkuk_fix.sql', false );
+               $this->output( "ok\n" );
+       }
        /**
         * rebuilding of the function that duplicates tables for tests
         */
@@@ -3573,13 -3573,7 +3573,13 @@@ class Parser 
                        }
  
                        if ( $rev ) {
 -                              $text = $rev->getText();
 +                              $content = $rev->getContent();
 +                              $text = $content->getWikitextForTransclusion();
 +
 +                              if ( $text === false || $text === null ) {
 +                                      $text = false;
 +                                      break;
 +                              }
                        } elseif ( $title->getNamespace() == NS_MEDIAWIKI ) {
                                global $wgContLang;
                                $message = wfMessage( $wgContLang->lcfirst( $title->getText() ) )->inContentLanguage();
                                        $text = false;
                                        break;
                                }
 +                              $content = $message->content();
                                $text = $message->plain();
                        } else {
                                break;
                        }
 -                      if ( $text === false ) {
 +                      if ( !$content ) {
                                break;
                        }
                        # Redirect?
                        $finalTitle = $title;
 -                      $title = Title::newFromRedirect( $text );
 +                      $title = $content->getRedirectTarget();
                }
                return array(
                        'text' => $text,
  
                                # Special case; width and height come in one variable together
                                if ( $type === 'handler' && $paramName === 'width' ) {
-                                       $m = array();
-                                       # (bug 13500) In both cases (width/height and width only),
-                                       # permit trailing "px" for backward compatibility.
-                                       if ( preg_match( '/^([0-9]*)x([0-9]*)\s*(?:px)?\s*$/', $value, $m ) ) {
-                                               $width = intval( $m[1] );
-                                               $height = intval( $m[2] );
+                                       $parsedWidthParam = $this->parseWidthParam( $value );
+                                       if( isset( $parsedWidthParam['width'] ) ) {
+                                               $width = $parsedWidthParam['width'];
                                                if ( $handler->validateParam( 'width', $width ) ) {
                                                        $params[$type]['width'] = $width;
                                                        $validated = true;
                                                }
+                                       }
+                                       if( isset( $parsedWidthParam['height'] ) ) {
+                                               $height = $parsedWidthParam['height'];
                                                if ( $handler->validateParam( 'height', $height ) ) {
                                                        $params[$type]['height'] = $height;
                                                        $validated = true;
                                                }
-                                       } elseif ( preg_match( '/^[0-9]*\s*(?:px)?\s*$/', $value ) ) {
-                                               $width = intval( $value );
-                                               if ( $handler->validateParam( 'width', $width ) ) {
-                                                       $params[$type]['width'] = $width;
-                                                       $validated = true;
-                                               }
-                                       } # else no validation -- bug 13436
+                                       }
+                                       # else no validation -- bug 13436
                                } else {
                                        if ( $type === 'handler' ) {
                                                # Validate handler parameter
        function isValidHalfParsedText( $data ) {
                return isset( $data['version'] ) && $data['version'] == self::HALF_PARSED_VERSION;
        }
+       /**
+        * Parsed a width param of imagelink like 300px or 200x300px
+        *
+        * @param $value String
+        *
+        * @return array
+        * @since 1.20
+        */
+       public function parseWidthParam( $value ) {
+               $parsedWidthParam = array();
+               if( $value === '' ) {
+                       return $parsedWidthParam;
+               }
+               $m = array();
+               # (bug 13500) In both cases (width/height and width only),
+               # permit trailing "px" for backward compatibility.
+               if ( preg_match( '/^([0-9]*)x([0-9]*)\s*(?:px)?\s*$/', $value, $m ) ) {
+                       $width = intval( $m[1] );
+                       $height = intval( $m[2] );
+                       $parsedWidthParam['width'] = $width;
+                       $parsedWidthParam['height'] = $height;
+               } elseif ( preg_match( '/^[0-9]*\s*(?:px)?\s*$/', $value ) ) {
+                       $width = intval( $value );
+                       $parsedWidthParam['width'] = $width;
+               }
+               return $parsedWidthParam;
+       }
  }
diff --combined languages/Language.php
@@@ -419,16 -419,6 +419,16 @@@ class Language 
         */
        public function setNamespaces( array $namespaces ) {
                $this->namespaceNames = $namespaces;
 +              $this->mNamespaceIds = null;
 +      }
 +
 +      /**
 +       * Resets all of the namespace caches. Mainly used for testing
 +       */
 +      public function resetNamespaces( ) {
 +              $this->namespaceNames = null;
 +              $this->mNamespaceIds = null;
 +              $this->namespaceAliases = null;
        }
  
        /**
         *
         * @param $opposite Boolean Get the direction mark opposite to your language
         * @return string
+        * @since 1.20
         */
        function getDirMarkEntity( $opposite = false ) {
                if ( $opposite ) { return $this->isRTL() ? '&lrm;' : '&rlm;'; }
         * Take a list of strings and build a locale-friendly comma-separated
         * list, using the local comma-separator message.
         * The last two strings are chained with an "and".
+        * NOTE: This function will only work with standard numeric array keys (0, 1, 2…)
         *
         * @param $l Array
         * @return string
        function listToText( array $l ) {
                $s = '';
                $m = count( $l ) - 1;
-               if ( $m == 1 ) {
+               
+               if ( $m === 0 ) {
+                       return $l[0];
+               } elseif ( $m === 1 ) {
                        return $l[0] . $this->getMessageFromDB( 'and' ) . $this->getMessageFromDB( 'word-separator' ) . $l[1];
                } else {
                        for ( $i = $m; $i >= 0; $i-- ) {
         * @param $format Bool|Int true to process using language functions, or TS_ constant
         *     to return the expiry in a given timestamp
         * @return String
+        * @since 1.18
         */
        public function formatExpiry( $expiry, $format = true ) {
                static $infinity, $infinityMsg;
   * @maintainers fdcn <fdcn64@gmail.com>, shinjiman <shinjiman@gmail.com>, PhiLiP <philip.npc@gmail.com>
   */
  class LanguageConverter {
+       /**
+        * languages supporting variants
+        * @since 1.20
+        * @var array
+        */
+       static public $languagesWithVariants = array(
+               'gan',
+               'iu',
+               'kk',
+               'ku',
+               'shi',
+               'sr',
+               'tg',
+               'zh',
+       );
        var $mMainLanguageCode;
        var $mVariants, $mVariantFallbacks, $mVariantNames;
        var $mTablesLoaded = false;
                        if ( $title && $title->exists() ) {
                                $revision = Revision::newFromTitle( $title );
                                if ( $revision ) {
 -                                      $txt = $revision->getRawText();
 +                                      if ( $revision->getContentModel() == CONTENT_MODEL_WIKITEXT ) {
 +                                              $txt = $revision->getContent( Revision::RAW )->getNativeData();
 +                                      }
 +
 +                                      //@todo: in the future, use a specialized content model, perhaps based on json!
                                }
                        }
                }
@@@ -200,162 -200,166 +200,166 @@@ $bookstoreList = array
   * This array can be modified at runtime with the LanguageGetMagic hook
   */
  $magicWords = array(
- #   ID                                 CASE  SYNONYMS
-       'redirect'               => array( 0,    '#REDIRECT'              ),
-       'notoc'                  => array( 0,    '__NOTOC__'              ),
-       'nogallery'              => array( 0,    '__NOGALLERY__'          ),
-       'forcetoc'               => array( 0,    '__FORCETOC__'           ),
-       'toc'                    => array( 0,    '__TOC__'                ),
-       'noeditsection'          => array( 0,    '__NOEDITSECTION__'      ),
-       'noheader'               => array( 0,    '__NOHEADER__'           ),
-       'currentmonth'           => array( 1,    'CURRENTMONTH', 'CURRENTMONTH2' ),
-       'currentmonth1'          => array( 1,    'CURRENTMONTH1'          ),
-       'currentmonthname'       => array( 1,    'CURRENTMONTHNAME'       ),
-       'currentmonthnamegen'    => array( 1,    'CURRENTMONTHNAMEGEN'    ),
-       'currentmonthabbrev'     => array( 1,    'CURRENTMONTHABBREV'     ),
-       'currentday'             => array( 1,    'CURRENTDAY'             ),
-       'currentday2'            => array( 1,    'CURRENTDAY2'            ),
-       'currentdayname'         => array( 1,    'CURRENTDAYNAME'         ),
-       'currentyear'            => array( 1,    'CURRENTYEAR'            ),
-       'currenttime'            => array( 1,    'CURRENTTIME'            ),
-       'currenthour'            => array( 1,    'CURRENTHOUR'            ),
-       'localmonth'             => array( 1,    'LOCALMONTH', 'LOCALMONTH2' ),
-       'localmonth1'            => array( 1,    'LOCALMONTH1'             ),
-       'localmonthname'         => array( 1,    'LOCALMONTHNAME'         ),
-       'localmonthnamegen'      => array( 1,    'LOCALMONTHNAMEGEN'      ),
-       'localmonthabbrev'       => array( 1,    'LOCALMONTHABBREV'       ),
-       'localday'               => array( 1,    'LOCALDAY'               ),
-       'localday2'              => array( 1,    'LOCALDAY2'              ),
-       'localdayname'           => array( 1,    'LOCALDAYNAME'           ),
-       'localyear'              => array( 1,    'LOCALYEAR'              ),
-       'localtime'              => array( 1,    'LOCALTIME'              ),
-       'localhour'              => array( 1,    'LOCALHOUR'              ),
-       'numberofpages'          => array( 1,    'NUMBEROFPAGES'          ),
-       'numberofarticles'       => array( 1,    'NUMBEROFARTICLES'       ),
-       'numberoffiles'          => array( 1,    'NUMBEROFFILES'          ),
-       'numberofusers'          => array( 1,    'NUMBEROFUSERS'          ),
-       'numberofactiveusers'    => array( 1,    'NUMBEROFACTIVEUSERS'    ),
-       'numberofedits'          => array( 1,    'NUMBEROFEDITS'          ),
-       'numberofviews'          => array( 1,    'NUMBEROFVIEWS'          ),
-       'pagename'               => array( 1,    'PAGENAME'               ),
-       'pagenamee'              => array( 1,    'PAGENAMEE'              ),
-       'namespace'              => array( 1,    'NAMESPACE'              ),
-       'namespacee'             => array( 1,    'NAMESPACEE'             ),
-       'namespacenumber'        => array( 1,    'NAMESPACENUMBER'        ),
-       'talkspace'              => array( 1,    'TALKSPACE'              ),
-       'talkspacee'             => array( 1,    'TALKSPACEE'              ),
-       'subjectspace'           => array( 1,    'SUBJECTSPACE', 'ARTICLESPACE' ),
-       'subjectspacee'          => array( 1,    'SUBJECTSPACEE', 'ARTICLESPACEE' ),
-       'fullpagename'           => array( 1,    'FULLPAGENAME'           ),
-       'fullpagenamee'          => array( 1,    'FULLPAGENAMEE'          ),
-       'subpagename'            => array( 1,    'SUBPAGENAME'            ),
-       'subpagenamee'           => array( 1,    'SUBPAGENAMEE'           ),
-       'basepagename'           => array( 1,    'BASEPAGENAME'           ),
-       'basepagenamee'          => array( 1,    'BASEPAGENAMEE'          ),
-       'talkpagename'           => array( 1,    'TALKPAGENAME'           ),
-       'talkpagenamee'          => array( 1,    'TALKPAGENAMEE'          ),
-       'subjectpagename'        => array( 1,    'SUBJECTPAGENAME', 'ARTICLEPAGENAME' ),
-       'subjectpagenamee'       => array( 1,    'SUBJECTPAGENAMEE', 'ARTICLEPAGENAMEE' ),
-       'msg'                    => array( 0,    'MSG:'                   ),
-       'subst'                  => array( 0,    'SUBST:'                 ),
-       'safesubst'              => array( 0,    'SAFESUBST:'             ),
-       'msgnw'                  => array( 0,    'MSGNW:'                 ),
-       'img_thumbnail'          => array( 1,    'thumbnail', 'thumb'     ),
-       'img_manualthumb'        => array( 1,    'thumbnail=$1', 'thumb=$1' ),
-       'img_right'              => array( 1,    'right'                  ),
-       'img_left'               => array( 1,    'left'                   ),
-       'img_none'               => array( 1,    'none'                   ),
-       'img_width'              => array( 1,    '$1px'                   ),
-       'img_center'             => array( 1,    'center', 'centre'       ),
-       'img_framed'             => array( 1,    'framed', 'enframed', 'frame' ),
-       'img_frameless'          => array( 1,    'frameless'              ),
-       'img_page'               => array( 1,    'page=$1', 'page $1'     ),
-       'img_upright'            => array( 1,    'upright', 'upright=$1', 'upright $1'  ),
-       'img_border'             => array( 1,    'border'                 ),
-       'img_baseline'           => array( 1,    'baseline'               ),
-       'img_sub'                => array( 1,    'sub'                    ),
-       'img_super'              => array( 1,    'super', 'sup'           ),
-       'img_top'                => array( 1,    'top'                    ),
-       'img_text_top'           => array( 1,    'text-top'               ),
-       'img_middle'             => array( 1,    'middle'                 ),
-       'img_bottom'             => array( 1,    'bottom'                 ),
-       'img_text_bottom'        => array( 1,    'text-bottom'            ),
-       'img_link'               => array( 1,    'link=$1'                ),
-       'img_alt'                => array( 1,    'alt=$1'                 ),
-       'int'                    => array( 0,    'INT:'                   ),
-       'sitename'               => array( 1,    'SITENAME'               ),
-       'ns'                     => array( 0,    'NS:'                    ),
-       'nse'                    => array( 0,    'NSE:'                   ),
-       'localurl'               => array( 0,    'LOCALURL:'              ),
-       'localurle'              => array( 0,    'LOCALURLE:'             ),
-       'articlepath'            => array( 0,    'ARTICLEPATH'            ),
-       'pageid'                 => array( 0,    'PAGEID'                 ),
-       'server'                 => array( 0,    'SERVER'                 ),
-       'servername'             => array( 0,    'SERVERNAME'             ),
-       'scriptpath'             => array( 0,    'SCRIPTPATH'             ),
-       'stylepath'              => array( 0,    'STYLEPATH'              ),
-       'grammar'                => array( 0,    'GRAMMAR:'               ),
-       'gender'                 => array( 0,    'GENDER:'                ),
-       'notitleconvert'         => array( 0,    '__NOTITLECONVERT__', '__NOTC__' ),
-       'nocontentconvert'       => array( 0,    '__NOCONTENTCONVERT__', '__NOCC__' ),
-       'currentweek'            => array( 1,    'CURRENTWEEK'            ),
-       'currentdow'             => array( 1,    'CURRENTDOW'             ),
-       'localweek'              => array( 1,    'LOCALWEEK'              ),
-       'localdow'               => array( 1,    'LOCALDOW'               ),
-       'revisionid'             => array( 1,    'REVISIONID'             ),
-       'revisionday'            => array( 1,    'REVISIONDAY'            ),
-       'revisionday2'           => array( 1,    'REVISIONDAY2'           ),
-       'revisionmonth'          => array( 1,    'REVISIONMONTH'          ),
-       'revisionmonth1'         => array( 1,    'REVISIONMONTH1'         ),
-       'revisionyear'           => array( 1,    'REVISIONYEAR'           ),
-       'revisiontimestamp'      => array( 1,    'REVISIONTIMESTAMP'      ),
-       'revisionuser'           => array( 1,    'REVISIONUSER'           ),
-       'plural'                 => array( 0,    'PLURAL:'                ),
-       'fullurl'                => array( 0,    'FULLURL:'               ),
-       'fullurle'               => array( 0,    'FULLURLE:'              ),
-       'canonicalurl'           => array( 0,    'CANONICALURL:'          ),
-       'canonicalurle'          => array( 0,    'CANONICALURLE:'         ),
-       'lcfirst'                => array( 0,    'LCFIRST:'               ),
-       'ucfirst'                => array( 0,    'UCFIRST:'               ),
-       'lc'                     => array( 0,    'LC:'                    ),
-       'uc'                     => array( 0,    'UC:'                    ),
-       'raw'                    => array( 0,    'RAW:'                   ),
-       'displaytitle'           => array( 1,    'DISPLAYTITLE'           ),
-       'rawsuffix'              => array( 1,    'R'                      ),
-       'newsectionlink'         => array( 1,    '__NEWSECTIONLINK__'     ),
-       'nonewsectionlink'       => array( 1,    '__NONEWSECTIONLINK__'   ),
-       'currentversion'         => array( 1,    'CURRENTVERSION'         ),
-       'urlencode'              => array( 0,    'URLENCODE:'             ),
-       'anchorencode'           => array( 0,    'ANCHORENCODE'           ),
-       'currenttimestamp'       => array( 1,    'CURRENTTIMESTAMP'       ),
-       'localtimestamp'         => array( 1,    'LOCALTIMESTAMP'         ),
-       'directionmark'          => array( 1,    'DIRECTIONMARK', 'DIRMARK' ),
-       'language'               => array( 0,    '#LANGUAGE:'             ),
-       'contentlanguage'        => array( 1,    'CONTENTLANGUAGE', 'CONTENTLANG' ),
-       'pagesinnamespace'       => array( 1,    'PAGESINNAMESPACE:', 'PAGESINNS:' ),
-       'numberofadmins'         => array( 1,    'NUMBEROFADMINS'         ),
-       'formatnum'              => array( 0,    'FORMATNUM'              ),
-       'padleft'                => array( 0,    'PADLEFT'                ),
-       'padright'               => array( 0,    'PADRIGHT'               ),
-       'special'                => array( 0,    'special',               ),
-       'speciale'               => array( 0,    'speciale',              ),
-       'defaultsort'            => array( 1,    'DEFAULTSORT:', 'DEFAULTSORTKEY:', 'DEFAULTCATEGORYSORT:' ),
-       'filepath'               => array( 0,    'FILEPATH:'              ),
-       'tag'                    => array( 0,    'tag'                    ),
-       'hiddencat'              => array( 1,    '__HIDDENCAT__'          ),
-       'pagesincategory'        => array( 1,    'PAGESINCATEGORY', 'PAGESINCAT' ),
-       'pagesize'               => array( 1,    'PAGESIZE'               ),
-       'index'                  => array( 1,    '__INDEX__'              ),
-       'noindex'                => array( 1,    '__NOINDEX__'            ),
-       'numberingroup'          => array( 1,    'NUMBERINGROUP', 'NUMINGROUP' ),
-       'staticredirect'         => array( 1,    '__STATICREDIRECT__'     ),
-       'protectionlevel'        => array( 1,    'PROTECTIONLEVEL'        ),
-       'formatdate'             => array( 0,    'formatdate', 'dateformat' ),
-       'url_path'               => array( 0,    'PATH' ),
-       'url_wiki'               => array( 0,    'WIKI' ),
-       'url_query'              => array( 0,    'QUERY' ),
-       'defaultsort_noerror'    => array( 0,    'noerror' ),
-       'defaultsort_noreplace'  => array( 0,    'noreplace' ),
+ #   ID                                  CASE  SYNONYMS
+       'redirect'                => array( 0,    '#REDIRECT' ),
+       'notoc'                   => array( 0,    '__NOTOC__' ),
+       'nogallery'               => array( 0,    '__NOGALLERY__' ),
+       'forcetoc'                => array( 0,    '__FORCETOC__' ),
+       'toc'                     => array( 0,    '__TOC__' ),
+       'noeditsection'           => array( 0,    '__NOEDITSECTION__' ),
+       'noheader'                => array( 0,    '__NOHEADER__' ),
+       'currentmonth'            => array( 1,    'CURRENTMONTH', 'CURRENTMONTH2' ),
+       'currentmonth1'           => array( 1,    'CURRENTMONTH1' ),
+       'currentmonthname'        => array( 1,    'CURRENTMONTHNAME' ),
+       'currentmonthnamegen'     => array( 1,    'CURRENTMONTHNAMEGEN' ),
+       'currentmonthabbrev'      => array( 1,    'CURRENTMONTHABBREV' ),
+       'currentday'              => array( 1,    'CURRENTDAY' ),
+       'currentday2'             => array( 1,    'CURRENTDAY2' ),
+       'currentdayname'          => array( 1,    'CURRENTDAYNAME' ),
+       'currentyear'             => array( 1,    'CURRENTYEAR' ),
+       'currenttime'             => array( 1,    'CURRENTTIME' ),
+       'currenthour'             => array( 1,    'CURRENTHOUR' ),
+       'localmonth'              => array( 1,    'LOCALMONTH', 'LOCALMONTH2' ),
+       'localmonth1'             => array( 1,    'LOCALMONTH1' ),
+       'localmonthname'          => array( 1,    'LOCALMONTHNAME' ),
+       'localmonthnamegen'       => array( 1,    'LOCALMONTHNAMEGEN' ),
+       'localmonthabbrev'        => array( 1,    'LOCALMONTHABBREV' ),
+       'localday'                => array( 1,    'LOCALDAY' ),
+       'localday2'               => array( 1,    'LOCALDAY2' ),
+       'localdayname'            => array( 1,    'LOCALDAYNAME' ),
+       'localyear'               => array( 1,    'LOCALYEAR' ),
+       'localtime'               => array( 1,    'LOCALTIME' ),
+       'localhour'               => array( 1,    'LOCALHOUR' ),
+       'numberofpages'           => array( 1,    'NUMBEROFPAGES' ),
+       'numberofarticles'        => array( 1,    'NUMBEROFARTICLES' ),
+       'numberoffiles'           => array( 1,    'NUMBEROFFILES' ),
+       'numberofusers'           => array( 1,    'NUMBEROFUSERS' ),
+       'numberofactiveusers'     => array( 1,    'NUMBEROFACTIVEUSERS' ),
+       'numberofedits'           => array( 1,    'NUMBEROFEDITS' ),
+       'numberofviews'           => array( 1,    'NUMBEROFVIEWS' ),
+       'pagename'                => array( 1,    'PAGENAME' ),
+       'pagenamee'               => array( 1,    'PAGENAMEE' ),
+       'namespace'               => array( 1,    'NAMESPACE' ),
+       'namespacee'              => array( 1,    'NAMESPACEE' ),
+       'namespacenumber'         => array( 1,    'NAMESPACENUMBER' ),
+       'talkspace'               => array( 1,    'TALKSPACE' ),
+       'talkspacee'              => array( 1,    'TALKSPACEE' ),
+       'subjectspace'            => array( 1,    'SUBJECTSPACE', 'ARTICLESPACE' ),
+       'subjectspacee'           => array( 1,    'SUBJECTSPACEE', 'ARTICLESPACEE' ),
+       'fullpagename'            => array( 1,    'FULLPAGENAME' ),
+       'fullpagenamee'           => array( 1,    'FULLPAGENAMEE' ),
+       'subpagename'             => array( 1,    'SUBPAGENAME' ),
+       'subpagenamee'            => array( 1,    'SUBPAGENAMEE' ),
+       'basepagename'            => array( 1,    'BASEPAGENAME' ),
+       'basepagenamee'           => array( 1,    'BASEPAGENAMEE' ),
+       'talkpagename'            => array( 1,    'TALKPAGENAME' ),
+       'talkpagenamee'           => array( 1,    'TALKPAGENAMEE' ),
+       'subjectpagename'         => array( 1,    'SUBJECTPAGENAME', 'ARTICLEPAGENAME' ),
+       'subjectpagenamee'        => array( 1,    'SUBJECTPAGENAMEE', 'ARTICLEPAGENAMEE' ),
+       'msg'                     => array( 0,    'MSG:' ),
+       'subst'                   => array( 0,    'SUBST:' ),
+       'safesubst'               => array( 0,    'SAFESUBST:' ),
+       'msgnw'                   => array( 0,    'MSGNW:' ),
+       'img_thumbnail'           => array( 1,    'thumbnail', 'thumb' ),
+       'img_manualthumb'         => array( 1,    'thumbnail=$1', 'thumb=$1' ),
+       'img_right'               => array( 1,    'right' ),
+       'img_left'                => array( 1,    'left' ),
+       'img_none'                => array( 1,    'none' ),
+       'img_width'               => array( 1,    '$1px' ),
+       'img_center'              => array( 1,    'center', 'centre' ),
+       'img_framed'              => array( 1,    'framed', 'enframed', 'frame' ),
+       'img_frameless'           => array( 1,    'frameless' ),
+       'img_page'                => array( 1,    'page=$1', 'page $1' ),
+       'img_upright'             => array( 1,    'upright', 'upright=$1', 'upright $1' ),
+       'img_border'              => array( 1,    'border' ),
+       'img_baseline'            => array( 1,    'baseline' ),
+       'img_sub'                 => array( 1,    'sub' ),
+       'img_super'               => array( 1,    'super', 'sup' ),
+       'img_top'                 => array( 1,    'top' ),
+       'img_text_top'            => array( 1,    'text-top' ),
+       'img_middle'              => array( 1,    'middle' ),
+       'img_bottom'              => array( 1,    'bottom' ),
+       'img_text_bottom'         => array( 1,    'text-bottom' ),
+       'img_link'                => array( 1,    'link=$1' ),
+       'img_alt'                 => array( 1,    'alt=$1' ),
+       'int'                     => array( 0,    'INT:' ),
+       'sitename'                => array( 1,    'SITENAME' ),
+       'ns'                      => array( 0,    'NS:' ),
+       'nse'                     => array( 0,    'NSE:' ),
+       'localurl'                => array( 0,    'LOCALURL:' ),
+       'localurle'               => array( 0,    'LOCALURLE:' ),
+       'articlepath'             => array( 0,    'ARTICLEPATH' ),
+       'pageid'                  => array( 0,    'PAGEID' ),
+       'server'                  => array( 0,    'SERVER' ),
+       'servername'              => array( 0,    'SERVERNAME' ),
+       'scriptpath'              => array( 0,    'SCRIPTPATH' ),
+       'stylepath'               => array( 0,    'STYLEPATH' ),
+       'grammar'                 => array( 0,    'GRAMMAR:' ),
+       'gender'                  => array( 0,    'GENDER:' ),
+       'notitleconvert'          => array( 0,    '__NOTITLECONVERT__', '__NOTC__' ),
+       'nocontentconvert'        => array( 0,    '__NOCONTENTCONVERT__', '__NOCC__' ),
+       'currentweek'             => array( 1,    'CURRENTWEEK' ),
+       'currentdow'              => array( 1,    'CURRENTDOW' ),
+       'localweek'               => array( 1,    'LOCALWEEK' ),
+       'localdow'                => array( 1,    'LOCALDOW' ),
+       'revisionid'              => array( 1,    'REVISIONID' ),
+       'revisionday'             => array( 1,    'REVISIONDAY' ),
+       'revisionday2'            => array( 1,    'REVISIONDAY2' ),
+       'revisionmonth'           => array( 1,    'REVISIONMONTH' ),
+       'revisionmonth1'          => array( 1,    'REVISIONMONTH1' ),
+       'revisionyear'            => array( 1,    'REVISIONYEAR' ),
+       'revisiontimestamp'       => array( 1,    'REVISIONTIMESTAMP' ),
+       'revisionuser'            => array( 1,    'REVISIONUSER' ),
+       'plural'                  => array( 0,    'PLURAL:' ),
+       'fullurl'                 => array( 0,    'FULLURL:' ),
+       'fullurle'                => array( 0,    'FULLURLE:' ),
+       'canonicalurl'            => array( 0,    'CANONICALURL:' ),
+       'canonicalurle'           => array( 0,    'CANONICALURLE:' ),
+       'lcfirst'                 => array( 0,    'LCFIRST:' ),
+       'ucfirst'                 => array( 0,    'UCFIRST:' ),
+       'lc'                      => array( 0,    'LC:' ),
+       'uc'                      => array( 0,    'UC:' ),
+       'raw'                     => array( 0,    'RAW:' ),
+       'displaytitle'            => array( 1,    'DISPLAYTITLE' ),
+       'rawsuffix'               => array( 1,    'R' ),
+       'newsectionlink'          => array( 1,    '__NEWSECTIONLINK__' ),
+       'nonewsectionlink'        => array( 1,    '__NONEWSECTIONLINK__' ),
+       'currentversion'          => array( 1,    'CURRENTVERSION' ),
+       'urlencode'               => array( 0,    'URLENCODE:' ),
+       'anchorencode'            => array( 0,    'ANCHORENCODE' ),
+       'currenttimestamp'        => array( 1,    'CURRENTTIMESTAMP' ),
+       'localtimestamp'          => array( 1,    'LOCALTIMESTAMP' ),
+       'directionmark'           => array( 1,    'DIRECTIONMARK', 'DIRMARK' ),
+       'language'                => array( 0,    '#LANGUAGE:' ),
+       'contentlanguage'         => array( 1,    'CONTENTLANGUAGE', 'CONTENTLANG' ),
+       'pagesinnamespace'        => array( 1,    'PAGESINNAMESPACE:', 'PAGESINNS:' ),
+       'numberofadmins'          => array( 1,    'NUMBEROFADMINS' ),
+       'formatnum'               => array( 0,    'FORMATNUM' ),
+       'padleft'                 => array( 0,    'PADLEFT' ),
+       'padright'                => array( 0,    'PADRIGHT' ),
+       'special'                 => array( 0,    'special' ),
+       'speciale'                => array( 0,    'speciale' ),
+       'defaultsort'             => array( 1,    'DEFAULTSORT:', 'DEFAULTSORTKEY:', 'DEFAULTCATEGORYSORT:' ),
+       'filepath'                => array( 0,    'FILEPATH:' ),
+       'tag'                     => array( 0,    'tag' ),
+       'hiddencat'               => array( 1,    '__HIDDENCAT__' ),
+       'pagesincategory'         => array( 1,    'PAGESINCATEGORY', 'PAGESINCAT' ),
+       'pagesize'                => array( 1,    'PAGESIZE' ),
+       'index'                   => array( 1,    '__INDEX__' ),
+       'noindex'                 => array( 1,    '__NOINDEX__' ),
+       'numberingroup'           => array( 1,    'NUMBERINGROUP', 'NUMINGROUP' ),
+       'staticredirect'          => array( 1,    '__STATICREDIRECT__' ),
+       'protectionlevel'         => array( 1,    'PROTECTIONLEVEL' ),
+       'formatdate'              => array( 0,    'formatdate', 'dateformat' ),
+       'url_path'                => array( 0,    'PATH' ),
+       'url_wiki'                => array( 0,    'WIKI' ),
+       'url_query'               => array( 0,    'QUERY' ),
+       'defaultsort_noerror'     => array( 0,    'noerror' ),
+       'defaultsort_noreplace'   => array( 0,    'noreplace' ),
+       'pagesincategory_all'     => array( 0,    'all' ),
+       'pagesincategory_pages'   => array( 0,    'pages' ),
+       'pagesincategory_subcats' => array( 0,    'subcats' ),
+       'pagesincategory_files'   => array( 0,    'files' ),
  );
  
  /**
@@@ -890,7 -894,6 +894,7 @@@ $1'
  'portal-url'           => 'Project:Community portal',
  'privacy'              => 'Privacy policy',
  'privacypage'          => 'Project:Privacy policy',
 +'content-failed-to-parse' => "Failed to parse $2 content for $1 model: $3",
  
  'badaccess'        => 'Permission error',
  'badaccess-group0' => 'You are not allowed to execute the action you have requested.',
@@@ -1417,7 -1420,7 +1421,7 @@@ If you save it, any changes made since 
  'yourdiff'                         => 'Differences',
  'copyrightwarning'                 => "Please note that all contributions to {{SITENAME}} are considered to be released under the $2 (see $1 for details).
  If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.<br />
 -You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
 +You are also promising us that you wrote this yourself, or copied editpageit from a public domain or similar free resource.
  '''Do not submit copyrighted work without permission!'''",
  'copyrightwarning2'                => "Please note that all contributions to {{SITENAME}} may be edited, altered, or removed by other contributors.
  If you do not want your writing to be edited mercilessly, then do not submit it here.<br />
@@@ -1473,7 -1476,6 +1477,7 @@@ It already exists.'
  'addsection-preload'               => '', # do not translate or duplicate this message to other languages
  'addsection-editintro'             => '', # do not translate or duplicate this message to other languages
  'defaultmessagetext'               => 'Default message text',
 +'invalid-content-data'             => 'Invalid content data',
  
  # Parser/template warnings
  'expensive-parserfunction-warning'        => "'''Warning:''' This page contains too many expensive parser function calls.
@@@ -2925,6 -2927,8 +2929,8 @@@ proceed with caution.'
  'rollback'          => 'Roll back edits',
  'rollback_short'    => 'Rollback',
  'rollbacklink'      => 'rollback',
+ 'rollbacklinkcount' => 'rollback $1 {{PLURAL:$1|edit|edits}}',
+ 'rollbacklinkcount-morethan' => 'rollback more than $1 {{PLURAL:$1|edit|edits}}',
  'rollbackfailed'    => 'Rollback failed',
  'cantrollback'      => 'Cannot revert edit;
  last contributor is only author of this page.',
@@@ -4887,10 -4891,4 +4893,10 @@@ Otherwise, you can use the easy form be
  'duration-centuries' => '$1 {{PLURAL:$1|century|centuries}}',
  'duration-millennia' => '$1 {{PLURAL:$1|millennium|millennia}}',
  
 +# Content model IDs for the ContentHandler facility; used by ContentHandler::getContentModel()
 +'content-model-wikitext' => 'wikitext',
 +'content-model-javascript' => 'JavaScript',
 +'content-model-css' => 'CSS',
 +'content-model-text' => 'plain text',
 +
  );
@@@ -12,6 -12,7 +12,7 @@@
   * @author Ahonc
   * @author Aleator
   * @author AlexSm
+  * @author Amahoney
   * @author Amire80
   * @author AnakngAraw
   * @author Ans
@@@ -744,6 -745,7 +745,7 @@@ It is also used on the top of the page 
  'gotaccountlink' => 'Text of the link to the log in form. Before that link, the message [[MediaWiki:Gotaccount/{{SUBPAGENAME}}]] appears.
  
  {{Identical|Log in}}',
+ 'userlogin-resetlink' => 'Used on the login page.',
  'createaccountmail' => 'Button text for creating a new account and sending the new password to the specified e-mail address directly, as used on [[Special:UserLogin/signup]] if creating accounts by e-mail is allowed.',
  'createaccountreason' => '{{Identical|Reason}}',
  'createaccounterror' => 'Parameters:
@@@ -836,7 -838,10 +838,10 @@@ Used on [[Special:ResetPass]]'
  {{Identical|Reset password}}',
  'passwordreset-text' => 'Text on [[Special:PasswordReset]]',
  'passwordreset-legend' => '{{Identical|Reset password}}',
- 'passwordreset-pretext' => 'Parameters:
+ 'passwordreset-pretext' => 'These instructions are shown on the password reset dialogue, which can, in principle, take the user\'s email address as well as, or instead of, their username. This text displays above one or more fields, at least one of which needs to be completed, and the message does not know which routes are available, so it needs to refer to some vague noun rather than specifically "username". 
+ "One of the pieces of data" means "an info"/"a datum" (probably to be translatea with a singular noun in your language if available).
+ Parameters:
  * $1 is the number of password reset routes. This is never 1, but always two or more. Thus, the first plural option is empty in English.',
  'passwordreset-username' => '{{Identical|Username}}',
  'passwordreset-domain' => 'A domain like used in Domain Name System (DNS) or more specifically like a domain component in the Lightweight Directory Access Protocol (LDAP)',
@@@ -1027,7 -1032,6 +1032,7 @@@ Please report at [[Support]] if you ar
  'moveddeleted-notice' => 'Shown on top of a deleted page in normal view modus ([http://translatewiki.net/wiki/Test example]).',
  'edit-conflict' => "An 'Edit conflict' happens when more than one edit is being made to a page at the same time. This would usually be caused by separate individuals working on the same page. However, if the system is slow, several edits from one individual could back up and attempt to apply simultaneously - causing the conflict.",
  'defaultmessagetext' => 'Caption above the default message text shown on the left-hand side of a diff displayed after clicking “Show changes” when creating a new page in the MediaWiki: namespace',
 +'invalid-content-data'             => 'Error message indicating that the page\'s content can not be saved because it is invalid. This may occurr for some non-text content types.',
  
  # Parser/template warnings
  'expensive-parserfunction-warning' => 'On some (expensive) [[MetaWikipedia:Help:ParserFunctions|parser functions]] (e.g. <code><nowiki>{{#ifexist:}}</nowiki></code>) there is a limit of how many times it may be used. This is an error message shown when the limit is exceeded.
@@@ -2694,6 -2698,9 +2699,9 @@@ $1 is the <b>approximate</b> number of 
  'rollback_short' => '{{Identical|Rollback}}',
  'rollbacklink' => '{{Identical|Rollback}}
  This message has a tooltip {{msg-mw|tooltip-rollback}}',
+ 'rollbacklinkcount' => '* $1: the number of edit that will be rollbacked
+ If $1 is over the value of $wgShowRollbackEditCount (default: 10) [[MediaWiki:Rollbacklinkcount-morethan/en|rollbacklinkcount-morethan]] is used',
+ 'rollbacklinkcount-morethan' => 'Similar to [[MediaWiki:Rollbacklinkcount/en|rollbacklinkcount]] but with prefix more than',
  'rollbackfailed' => '{{Identical|Rollback}}',
  'cantrollback' => '{{Identical|Revert}}
  {{Identical|Rollback}}',
@@@ -4771,10 -4778,4 +4779,10 @@@ $4 is the gender of the target user.'
  'api-error-uploaddisabled' => 'API error message that can be used for client side localisation of API errors.',
  'api-error-verification-error' => 'The word "extension" refers to the part behind the last dot in a file name, that by convention gives a hint about the kind of data format which a files contents are in.',
  
 +# Content model IDs for the ContentHandler facility; used by ContentHandler::getContentModel()
 +'content-model-wikitext' => 'Name for the wikitext content model, used when decribing what type of content a page contains.',
 +'content-model-javascript' => 'Name for the JavaScript content model, used when decribing what type of content a page contains.',
 +'content-model-css' => 'Name for the CSS content model, used when decribing what type of content a page contains.',
 +'content-model-text' => 'Name for the plain text content model, used when decribing what type of content a page contains.',
 +
  );