Merge "Drop archive.ar_text and ar_flags"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 23 Apr 2018 20:15:26 +0000 (20:15 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 23 Apr 2018 20:15:26 +0000 (20:15 +0000)
1  2 
RELEASE-NOTES-1.31
includes/Revision.php
includes/Storage/RevisionStore.php
includes/installer/DatabaseUpdater.php
includes/page/WikiPage.php
maintenance/mssql/tables.sql
maintenance/oracle/tables.sql
maintenance/postgres/tables.sql
maintenance/tables.sql
tests/phpunit/includes/RevisionTest.php

diff --combined RELEASE-NOTES-1.31
@@@ -5,6 -5,14 +5,14 @@@ THIS IS NOT A RELEASE YE
  MediaWiki 1.31 is an alpha-quality branch and is not recommended for use in
  production.
  
+ === Important pre-upgrade notes for 1.31 ===
+ * If you're using MySQL, SQLite, or MSSQL, are not using update.php to apply
+   schema changes, and cannot have downtime to run migrateArchiveText.php and
+   apply patch-drop-ar_text.sql manually, you'll have to apply a default value
+   to the ar_text and ar_flags columns of the archive table or make those
+   columns nullable before upgrading to MediaWiki 1.31.
+   maintenance/archives/patch-nullable-ar_text.sql shows how to do this for MySQL.
  === Configuration changes in 1.31 ===
  * $wgEnableAPI and $wgEnableWriteAPI are now deprecated and will be removed in
    a future version. The API is now considered to be stable, secure and
  * (T188472) The 'comma' value for $wgArticleCountMethod is no longer supported for
    performance reasons, and installations with this setting will now work as if it
    was configured with 'any'.
 +* (T185753) MediaWiki now defaults to using RemexHtml to tidy up user input, rather than
 +  being off by default. If you wish to disable HTML tidying entirely, set $wgTidyConfig
 +  to null; if you wish to use the old, deprecated Tidy external binary, both
 +  set $wgTidyConfig to null and also set $wgUseTidy to true.
 +* $wgLogAutopatrol now defaults to false instead of true.
 +* $wgValidateAllHtml was removed and will be ignored.
 +* $wgScriptExtension was removed (deprecated and ignored since 1.25).
 +  See 1.25 release notes for more information.
 +* $wgUseAjax is now marked as deprecated, just like the deprecated AJAX
 +  framework that it enables. Some extensions mistakenly used this to check
 +  whether any AJAX functionality at all should be enabled, further making this
 +  problematic to retain.
  
  === New features in 1.31 ===
  * (T76554) User sub-pages named ….json are now protected in the same way that ….js
    and non-MySQL ::replace() and ::upsert() no longer roll back the whole
    transaction on failure.
  * (T189785) Added a monthly heartbeat ping to the pingback feature.
 +* The CLI installer (maintenance/install.php) learned to detect and include
 +  extensions. Pass --with-extensions to enable that feature.
 +* (T184791) rc_patrolled now has three states: "0" for unpatrolled,
 +  "1" for manually patrolled and "2" for autopatrolled actions.
 +* Extensions can now set their type to "editor" if they provide an editor
 +  or enhance the editing experience.
 +* Extensions can use a PSR-4 autoloader by setting an "AutoloadNamespaces" property
 +  in extension.json. See
 +  <https://www.mediawiki.org/wiki/Manual:Extension.json/Schema#AutoloadNamespaces>
 +  for more details and an example.
  
  === External library changes in 1.31 ===
  
  * Updated wikimedia/running-stat from 1.1.0 to 1.2.0.
  * Updated wikimedia/wrappedstring from 2.2.0 to 2.3.0.
  * Updated mediawiki/at-ease from 1.1.0 to 1.2.0.
 -* Updated wikimedia/php-session-serializer from 1.0.4 to 1.0.5.
 +* Updated wikimedia/php-session-serializer from 1.0.4 to 1.0.6.
  * Updated wikimedia/remex-html from 1.0.2 to 1.0.3.
  * …
  
    'mediawiki.viewport' module instead.
  * The deprecated 'mediawiki.widgets.CategorySelector' module alias was removed.
    Use the 'mediawiki.widgets.CategoryMultiselectWidget' module directly instead.
 +* mediawiki/at-ease was replaced with wikimedia/at-ease.
  
  === Bug fixes in 1.31 ===
 -* (T90902) Non-breaking space in header ID breaks anchor
 +* (T90902) Non-breaking space in header ID breaks anchor.
 +* (T189375) CSSMin now allows quoted urls in `url()` syntax to start with a space.
  
  === Action API changes in 1.31 ===
  * (T185058) The 'name' value to tgprop for action=query&list=tags has been
    removed. It has never made a difference in the output, the name was always
    returned regardless.
 +* The 'watch' and 'unwatch' parameters for action=move have been removed.  They
 +  were deprecated and also accidentally nonfunctional since 1.17 in 2010.  Use
 +  'watchlist' instead.
  
  === Action API internal changes in 1.31 ===
 -* …
 +* ApiBase::getProfileDBTime was removed (deprecated since 1.25)
 +* ApiBase::getModuleProfileName was removed (deprecated since 1.25)
 +* ApiBase::getProfileTime was removed (deprecated since 1.25)
  
  === Languages updated in 1.31 ===
  MediaWiki supports over 350 languages. Many localisations are updated
@@@ -158,13 -137,21 +166,13 @@@ changes to languages because of Phabric
  * (T186647) New language support: Kumyk [къумукъ] (kum).
  * (T187750) New language support: Spanish formal address (es-formal).
  * (T187824) New language support: Hungarian formal address (hu-formal).
 +* (T189127) New language support: Gorontalo (gor).
  
 -=== Other changes in 1.31 ===
 -* Browser support for Internet Explorer 10 was lowered from Grade A to Grade C.
 -* Introducing multi-content-revision capability into the storage layer. For details,
 -  see <https://www.mediawiki.org/wiki/Requests_for_comment/Multi-Content_Revisions>.
 -* The Revision class was deprecated in favor of RevisionStore, BlobStore, and
 -  RevisionRecord and its subclasses.
 +=== Breaking changes in 1.31 ===
  * MessageBlobStore::insertMessageBlob() (deprecated in 1.27) was removed.
 -* The global function wfBCP47 was renamed to LanguageCode::bcp47.
 -* The global function wfBCP47 is now deprecated.
 -* The global function wfCountDown() is now deprecated in favor of
 -  Maintenance::countDown()
  * The OutputPage class constructor now requires a context parameter,
    (instantiating without context was deprecated in 1.18)
 -* mw.page (deprecated in 1.30) was removed.
 +* The mw.page JavaScript singleton (deprecated in 1.30) was removed.
  * Article::getLastPurgeTimestamp(), WikiPage::getLastPurgeTimestamp(), and the
    related WikiPage::PURGE_* constants, deprecated in 1.29, were removed.
  * The Article::selectFields(), Article::onArticleCreate(),
    in 1.24, were removed.
  * Installer::locateExecutable() and Installer::locateExecutableInDefaultPaths()
    were removed, use ExecutableFinder::findInDefaultPaths() instead.
 +* The deprecated MW_DIFF_VERSION constant was removed.
 +  DifferenceEngine::MW_DIFF_VERSION should be used instead.
 +* Due to significant refactoring, method ContribsPager::getUserCond() that had
 +  no access restriction has been removed.
 +* The Block class will no longer accept usable-but-missing usernames for
 +  'byText' or ->setBlocker(). Callers should either ensure the blocker exists
 +  locally or use a new interwiki-format username like "iw>Example".
 +* The following methods and constants from the WatchedItem class, which were deprecated in
 +  1.27, have been removed.
 +  * WatchedItem::getTitle()
 +  * WatchedItem::fromUserTitle()
 +  * WatchedItem::addWatch()
 +  * WatchedItem::removeWatch()
 +  * WatchedItem::isWatched()
 +  * WatchedItem::duplicateEntries()
 +  * WatchedItem::IGNORE_USER_RIGHTS
 +  * WatchedItem::CHECK_USER_RIGHTS
 +  * WatchedItem::DEPRECATED_USAGE_TIMESTAMP
 +* The $statementsOnOwnLine parameter of JavaScriptMinifier::minify was removed.
 +  The corresponding configuration variable ($wgResourceLoaderMinifierStatementsOnOwnLine)
 +  has been deprecated since 1.27 and was removed as well.
 +* The $maxLineLength parameter of JavaScriptMinifier::minify was removed.
 +  The corresponding configuration variable ($wgResourceLoaderMinifierMaxLineLength)
 +  has been deprecated since 1.27 and was removed as well.
 +* The HtmlFormatter class was removed (deprecated in 1.27). The namespaced
 +  HtmlFormatter\HtmlFormatter class should be used instead.
 +* The driver 'mysql' for MySQL, deprecated in MediaWiki 1.30, has been removed.
 +  The driver has been deprecated since PHP 5.5 and was removed in PHP 7.0. The
 +  default driver for MySQL has been 'mysqli' since MediaWiki 1.22.
 +* The following properties of PreparedEdit were deprecated in 1.21 and have been removed:
 +  * PreparedEdit->newText
 +  * PreparedEdit->oldText
 +  * PreparedEdit->pst
 +* ParserOutput objects generated using a non-default value for
 +  ParserOptions::setWrapOutputClass() can no longer be added to the parser cache.
 +* The following deprecated methods from the OutputPage class have been removed:
 +  * OutputPage::addExtensionStyle(); deprecated in 1.27
 +  * OutputPage::getExtStyle(); deprecated in 1.27
 +  * OutputPage::setETag(); deprecated in 1.28 (obsolete no-op)
 +  * OutputPage::setSquidMaxage(); deprecated in 1.27
 +  * OutputPage::readOnlyPage(); deprecated in 1.25
 +  * OutputPage::rateLimited(); deprecated in 1.25
 +  * Additionally, the protected OutputPage::$mExtStyles array, only accessed through
 +    the above and with no known uses, was removed.
 +* The no-op method Skin::showIPinHeader(), deprecated in 1.27, was removed.
 +* The following variables and methods in EditPage, deprecated in MediaWiki 1.30, were removed:
 +  * $isCssJsSubpage — use ::isUserConfigPage()
 +  * $isCssSubpage — use ::isUserCssConfigPage()
 +  * $isJsSubpage — use ::isUserJsConfigPage()
 +  * $isWrongCaseCssJsPage – use ::isWrongCaseUserConfigPage()
 +  * ::getSummaryInput() – use ::getSummaryInputWidget()
 +  * ::getSummaryInputOOUI() – use ::getSummaryInputWidget()
 +  * ::getCheckboxes() – use ::getCheckboxesWidget() or ::getCheckboxesDefinition()
 +  * ::getCheckboxesOOUI() – use ::getCheckboxesWidget() or ::getCheckboxesDefinition()
 +* The method ResourceLoaderModule::getPosition(), deprecated in 1.29, has been removed.
 +* In User, the cookie-related methods which were wrappers for the functions on the response
 +  object, and were deprecated in 1.27, have been removed:
 +  * ::setCookie()
 +  * ::clearCookie()
 +  * ::setExtendedLoginCookie()
 +  Note that User::setCookies() remains, and is not deprecated.
 +* Also in User, some auth-related methods which were deprecated in 1.27, have been removed:
 +  * ::getEditTokenTimestamp() – use MediaWiki\Session\Token::getTimestamp()
 +  * ::getPasswordFactory() – create a PasswordFactory directly
 +  * ::passwordChangeInputAttribs()
 +* The global functions wfProfileIn and wfProfileOut, deprecated in 1.25, have been removed.
 +* SpecialPageFactory::getList(), deprecated in 1.24, has been removed. You can
 +  use ::getNames() instead.
 +* OpenSearch::getOpenSearchTemplate(), deprecated in 1.25, has been removed. You
 +  can use ApiOpenSearch::getOpenSearchTemplate() instead.
 +* The global function wfBaseConvert, deprecated in 1.27, has been removed. Use
 +  Wikimedia\base_convert() directly.
 +* Calling Database::begin() explicitly during an implicit transaction or when DBO_TRX
 +  is set results in an exception. Calling Database::commit() explicitly for an implicit
 +  transaction also results in an exception. Previously these were logged as errors.
 +  The startAtomic() and endAtomic() methods, or AtomicSectionUpdate should be used
 +  instead.
 +* The global function wfOutputHandler() was removed, use the its replacement
 +  MediaWiki\OutputHandler::handle() instead. The global function was only sometimes defined.
 +  Its replacement is always available via the autoloader.
 +* ChangeTags::listExtensionActivatedTags and ::listExtensionDefinedTags, deprecated
 +  in 1.28, have been removed.  Use ::listSoftwareActivatedTags() and
 +  ::listSoftwareDefinedTags() instead.
 +* Title::getTitleInvalidRegex(), deprecated in 1.25, has been removed. You
 +  can use MediaWikiTitleCodec::getTitleInvalidRegex() instead.
 +* HTMLForm & VFormHTMLForm::isVForm(), deprecated in 1.25, have been removed.
 +* The ProfileSection class, deprecated in 1.25 and unused, has been removed.
 +* The ResourceLoaderGetLessVars hook, deprecated in 1.30, has been removed.
 +  Use ResourceLoaderModule::getLessVars() to expose local variables instead
 +  of global ones.
 +* As part of work to modernise user-generated content clean-up, a config option and some
 +  methods related to HTML validity were removed without deprecation. The public methods
 +  MWTidy::checkErrors() and its callee TidyDriverBase::validate() are removed, as are
 +  MediaWikiTestCase::assertValidHtmlSnippet() and ::assertValidHtmlDocument(). The
 +  $wgValidateAllHtml configuration option is removed and will be ignored.
 +* Execution of external programs using MediaWiki\Shell\Command now applies RESTRICT_DEFAULT
 +  Firejail restriction by default.
 +* The ResourceLoaderModule::getHashMtime() and ::getDefinitionMtime() methods,
 +  deprecated in 1.26, were removed.
 +
 +=== Deprecations in 1.31 ===
 +* The Revision class was deprecated in favor of RevisionStore, BlobStore, and
 +  RevisionRecord and its subclasses.
 +* The global function wfBCP47 is deprecated in favour of LanguageCode::bcp47.
 +* The global function wfCountDown is now deprecated in favor of Maintenance::countDown.
  * Several methods for returning lists of fields to select from the database
    have been deprecated in favor of similar methods that also return the tables
    to select from and the join conditions for those tables.
    * Revision::selectArchiveFields() → Revision::getArchiveQueryInfo()
    * User::selectFields() → User::getQueryInfo()
    * WikiPage::selectFields() → WikiPage::getQueryInfo()
 -* Due to significant refactoring, method ContribsPager::getUserCond() that had
 -  no access restriction has been removed.
  * Revision::setUserIdAndName() was deprecated.
  * Access to TitleValue class properties was deprecated, the relevant getters
    should be used instead.
  * DifferenceEngine::getDiffBodyCacheKey() is deprecated. Subclasses should
    override DifferenceEngine::getDiffBodyCacheKeyParams() instead.
 -* The deprecated MW_DIFF_VERSION constant was removed.
 -  DifferenceEngine::MW_DIFF_VERSION should be used instead.
  * Use of Maintenance::error( $err, $die ) to exit script was deprecated. Use
    Maintenance::fatalError() instead.
  * Passing a ParserOptions object to OutputPage::parserOptions() is deprecated.
 -* Browser support for Opera 12 and older was removed.
 -  Opera 15+ continues at Grade A support.
 -* The Block class will no longer accept usable-but-missing usernames for
 -  'byText' or ->setBlocker(). Callers should either ensure the blocker exists
 -  locally or use a new interwiki-format username like "iw>Example".
  * The RevisionInsertComplete hook is now deprecated, use RevisionRecordInserted instead.
    RevisionInsertComplete is still called, but the second and third parameter will always be null.
    Hard deprecation is scheduled for 1.32.
    * OutputPage::enableSectionEditLinks()
    * OutputPage::sectionEditLinksEnabled()
    * The public ParserOutput state fields $mTOCEnabled and $mEditSectionTokens are also deprecated.
 -* The following methods and constants from the WatchedItem class were deprecated in
 -  1.27 have been removed.
 -  * WatchedItem::getTitle()
 -  * WatchedItem::fromUserTitle()
 -  * WatchedItem::addWatch()
 -  * WatchedItem::removeWatch()
 -  * WatchedItem::isWatched()
 -  * WatchedItem::duplicateEntries()
 -  * WatchedItem::IGNORE_USER_RIGHTS
 -  * WatchedItem::CHECK_USER_RIGHTS
 -  * WatchedItem::DEPRECATED_USAGE_TIMESTAMP
 -* The $statementsOnOwnLine parameter of JavaScriptMinifier::minify was removed.
 -  The corresponding configuration variable ($wgResourceLoaderMinifierStatementsOnOwnLine)
 -  has been deprecated since 1.27 and was removed as well.
 -* The $maxLineLength parameter of JavaScriptMinifier::minify was removed.
 -  The corresponding configuration variable ($wgResourceLoaderMinifierMaxLineLength)
 -  has been deprecated since 1.27 and was removed as well.
 -* The HtmlFormatter class was removed (deprecated in 1.27). The namespaced
 -  HtmlFormatter\HtmlFormatter class should be used instead.
  * License::getLicenses has been deprecated; use License::getLines instead.
 -* The driver 'mysql' for MySQL, deprecated in MediaWiki 1.30, has been removed.
 -  The driver has been deprecated since PHP 5.5 and was removed in PHP 7.0. The
 -  default driver for MySQL has been 'mysqli' since MediaWiki 1.22.
 -* The following properties of PreparedEdit were deprecated in 1.21 and have been removed:
 -  * PreparedEdit->newText
 -  * PreparedEdit->oldText
 -  * PreparedEdit->pst
  * QuickTemplate::setRef() was deprecated in favour of QuickTemplate::set().
    Setting template variables by reference allowed violating the principle of data being
    immutable once added to the skin template. In practice, this method was not being
  * MediaWikiI18N::translate() was deprecated in favour of Skin::msg() or wfMessage().
  * Passing false to ParserOptions::setWrapOutputClass() is deprecated. Use the
    'unwrap' transform to ParserOutput::getText() instead.
 -* ParserOutput objects generated using a non-default value for
 -  ParserOptions::setWrapOutputClass() can no longer be added to the parser
 -  cache.
 -* The following deprecated methods from the OutputPage class have been removed:
 -  * OutputPage::addExtensionStyle(); deprecated in 1.27
 -  * OutputPage::getExtStyle(); deprecated in 1.27
 -  * OutputPage::setETag(); deprecated in 1.28 (obsolete no-op)
 -  * OutputPage::setSquidMaxage(); deprecated in 1.27
 -  * OutputPage::readOnlyPage(); deprecated in 1.25
 -  * OutputPage::rateLimited(); deprecated in 1.25
 -  * Additionally, the protected OutputPage::$mExtStyles array, only accessed through
 -    the above and with no known uses, was removed.
 -* The no-op method Skin::showIPinHeader(), deprecated in 1.27, was removed.
  * \ObjectFactory (no namespace) is deprecated, the namespaced \Wikimedia\ObjectFactory
    from the wikimedia/object-factory library should be used instead.
  * CommentStore::newKey is deprecated. Get an instance from MediaWikiServices instead.
    * Title::isCssJsSubpage – use ::isUserConfigPage
    * Title::isCssSubpage – use ::isUserCssConfigPage
    * Title::isJsSubpage – use ::isUserJsConfigPage
 -* The following variables and methods in EditPage, deprecated in MediaWiki 1.30, were removed:
 -  * $isCssJsSubpage — use ::isUserConfigPage()
 -  * $isCssSubpage — use ::isUserCssConfigPage()
 -  * $isJsSubpage — use ::isUserJsConfigPage()
 -  * $isWrongCaseCssJsPage – use ::isWrongCaseUserConfigPage()
 -  * ::getSummaryInput() – use ::getSummaryInputWidget()
 -  * ::getSummaryInputOOUI() – use ::getSummaryInputWidget()
 -  * ::getCheckboxes() – use ::getCheckboxesWidget() or ::getCheckboxesDefinition()
 -  * ::getCheckboxesOOUI() – use ::getCheckboxesWidget() or ::getCheckboxesDefinition()
 -* The method ResourceLoaderModule::getPosition(), deprecated in 1.29, has been removed.
 -* The DeferredStringifier class is deprecated, use Message::listParam() instead.
 -* The type string for the parameter $lang of DateFormatter::getInstance is
 -  deprecated.
 -* In User, the cookie-related methods which were wrappers for the functions on the response
 -  object, and were deprecated in 1.27, have been removed:
 -  * ::setCookie()
 -  * ::clearCookie()
 -  * ::setExtendedLoginCookie()
 -  Note that User::setCookies() remains, and is not deprecated.
 -* The global functions wfProfileIn and wfProfileOut, deprecated in 1.25, have been removed.
  * The following methods related to caching of half-parsed HTML were deprecated:
    * Parser::serializeHalfParsedText()
    * Parser::unserializeHalfParsedText()
    * Parser::isValidHalfParsedText()
    * StripState::getSubState()
    * StripState::merge()
 +* The DeferredStringifier class is deprecated, use Message::listParam() instead.
 +* The type string for the parameter $lang of DateFormatter::getInstance is
 +  deprecated.
 +* Wikimedia\Rdbms\SavepointPostgres is deprecated.
 +* The DO_MAINTENANCE constant is deprecated. RUN_MAINTENANCE_IF_MAIN should be
 +  used instead.
 +* The function wfShellWikiCmd() has been deprecated, use
 +  MediaWiki\Shell::makeScriptCommand().
 +
 +=== Other changes in 1.31 ===
 +* Browser support for Internet Explorer 10 was lowered from Grade A to Grade C.
 +* Browser support for Opera 12 and older was removed. Opera 15+ continues at Grade A.
 +* Introducing multi-content-revision capability into the storage layer. For details,
 +  see <https://www.mediawiki.org/wiki/Requests_for_comment/Multi-Content_Revisions>.
  * The "free" CSS class is now only applied to unbracketed URLs in wikitext. Links
    written using square brackets will get the class "text" not "free".
 -* SpecialPageFactory::getList(), deprecated in 1.24, has been removed. You can
 -  use ::getNames() instead.
 -* OpenSearch::getOpenSearchTemplate(), deprecated in 1.25, has been removed. You
 -  can use ApiOpenSearch::getOpenSearchTemplate() instead.
 -* The global function wfBaseConvert, deprecated in 1.27, has been removed. Use
 -  Wikimedia\base_convert() directly.
  * RFC 157418: Whitespace is trimmed from wikitext headings, wikitext list items,
    wikitext table captions, wikitext table headings, wikitext table cells. HTML
    headings, HTML list items, HTML table captions, HTML table headings, HTML table cells
    will not have this trimming behavior.
 -* Calling Database::begin() explicitly during an implicit transaction or when DBO_TRX
 -  is set results in an exception. Calling Database::commit() explicitly for an implicit
 -  transaction also results in an exception. Previously these were logged as errors.
 -  The startAtomic() and endAtomic() methods, or AtomicSectionUpdate should be used
 -  instead.
 -* The global function wfOutputHandler() was removed, use the its replacement
 -  MediaWiki\OutputHandler::handle() instead. The global function was only sometimes defined.
 -  Its replacement is always available via the autoloader.
 -* ChangeTags::listExtensionActivatedTags and ::listExtensionDefinedTags, deprecated
 -  in 1.28, have been removed.  Use ::listSoftwareActivatedTags() and
 -  ::listSoftwareDefinedTags() instead.
 -* Title::getTitleInvalidRegex(), deprecated in 1.25, has been removed. You
 -  can use MediaWikiTitleCodec::getTitleInvalidRegex() instead.
 -* HTMLForm & VFormHTMLForm::isVForm(), deprecated in 1.25, have been removed.
 -* The ProfileSection class, deprecated in 1.25 and unused, has been removed.
  
  == Compatibility ==
  MediaWiki 1.31 requires PHP 5.5.9 or later. Although HHVM 3.18.5 or later is supported,
@@@ -384,7 -341,7 +392,7 @@@ Oracle and Microsoft SQL Server
  
  The supported versions are:
  
 -* MySQL 5.0.3 or later
 +* MySQL 5.5.8 or later
  * PostgreSQL 9.2 or later
  * SQLite 3.3.7 or later
  * Oracle 9.0.1 or later
diff --combined includes/Revision.php
@@@ -413,7 -413,6 +413,6 @@@ class Revision implements IDBAccessObje
                        'ar_id',
                        'ar_page_id',
                        'ar_rev_id',
-                       'ar_text',
                        'ar_text_id',
                        'ar_timestamp',
                        'ar_user_text',
                        return false;
                }
  
 -              $cacheKey = isset( $row->old_id ) ? ( 'tt:' . $row->old_id ) : null;
 +              $cacheKey = isset( $row->old_id )
 +                      ? SqlBlobStore::makeAddressFromTextId( $row->old_id )
 +                      : null;
  
                return self::getBlobStore( $wiki )->expandBlob( $text, $flags, $cacheKey );
        }
@@@ -391,7 -391,7 +391,7 @@@ class RevisionStor
  
                // getTextIdFromAddress() is free to insert something into the text table, so $textId
                // may be a new value, not anything already contained in $blobAddress.
 -              $blobAddress = 'tt:' . $textId;
 +              $blobAddress = SqlBlobStore::makeAddressFromTextId( $textId );
  
                $comment = $this->failOnNull( $rev->getComment( RevisionRecord::RAW ), 'comment' );
                $user = $this->failOnNull( $rev->getUser( RevisionRecord::RAW ), 'user' );
         */
        public function getRcIdIfUnpatrolled( RevisionRecord $rev ) {
                $rc = $this->getRecentChange( $rev );
 -              if ( $rc && $rc->getAttribute( 'rc_patrolled' ) == 0 ) {
 +              if ( $rc && $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_UNPATROLLED ) {
                        return $rc->getAttribute( 'rc_id' );
                } else {
                        return 0;
                        'ar_content_model'  => 'rev_content_model',
                ];
  
-               if ( empty( $archiveRow->ar_text_id ) ) {
-                       $fieldMap['ar_text'] = 'old_text';
-                       $fieldMap['ar_flags'] = 'old_flags';
-               }
                $revRow = new stdClass();
                foreach ( $fieldMap as $arKey => $revKey ) {
                        if ( property_exists( $archiveRow, $arKey ) ) {
  
                        if ( isset( $row->rev_text_id ) && $row->rev_text_id > 0 ) {
                                $mainSlotRow->slot_content_id = $row->rev_text_id;
 -                              $mainSlotRow->content_address = 'tt:' . $row->rev_text_id;
 +                              $mainSlotRow->content_address = SqlBlobStore::makeAddressFromTextId(
 +                                      $row->rev_text_id
 +                              );
                        }
  
                        // This is used by null-revisions
                                ? intval( $row['slot_origin'] )
                                : null;
                        $mainSlotRow->content_address = isset( $row['text_id'] )
 -                              ? 'tt:' . intval( $row['text_id'] )
 +                              ? SqlBlobStore::makeAddressFromTextId( intval( $row['text_id'] ) )
                                : null;
                        $mainSlotRow->content_size = isset( $row['len'] ) ? intval( $row['len'] ) : null;
                        $mainSlotRow->content_sha1 = isset( $row['sha1'] ) ? strval( $row['sha1'] ) : null;
                                        'ar_namespace',
                                        'ar_title',
                                        'ar_rev_id',
-                                       'ar_text',
                                        'ar_text_id',
                                        'ar_timestamp',
                                        'ar_minor_edit',
@@@ -136,7 -136,7 +136,7 @@@ abstract class DatabaseUpdater 
                        $wgExtPGAlteredFields, $wgExtNewIndexes, $wgExtModifiedFields;
  
                # For extensions only, should be populated via hooks
 -              # $wgDBtype should be checked to specifiy the proper file
 +              # $wgDBtype should be checked to specify the proper file
                $wgExtNewTables = []; // table, dir
                $wgExtNewFields = []; // table, column, dir
                $wgExtPGNewFields = []; // table, column, column attributes; for PostgreSQL
         * LoadExtensionSchemaUpdates hook.
         */
        private function loadExtensions() {
 -              if ( !defined( 'MEDIAWIKI_INSTALL' ) ) {
 +              if ( !defined( 'MEDIAWIKI_INSTALL' ) || defined( 'MW_EXTENSIONS_LOADED' ) ) {
                        return; // already loaded
                }
                $vars = Installer::getExistingLocalSettings();
  
                // This will automatically add "AutoloadClasses" to $wgAutoloadClasses
                $data = $registry->readFromQueue( $queue );
 -              $hooks = [ 'wgHooks' => [ 'LoadExtensionSchemaUpdates' => [] ] ];
 +              $hooks = [];
                if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
                        $hooks = $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'];
                }
         * @since 1.31
         */
        protected function migrateArchiveText() {
-               $this->output( "Migrating archive ar_text to modern storage.\n" );
-               $task = $this->maintenance->runChild( MigrateArchiveText::class, 'migrateArchiveText.php' );
-               $task->execute();
-               $this->output( "done.\n" );
+               if ( $this->db->fieldExists( 'archive', 'ar_text', __METHOD__ ) ) {
+                       $this->output( "Migrating archive ar_text to modern storage.\n" );
+                       $task = $this->maintenance->runChild( MigrateArchiveText::class, 'migrateArchiveText.php' );
+                       $task->setForce();
+                       if ( $task->execute() ) {
+                               $this->applyPatch( 'patch-drop-ar_text.sql', false,
+                                       'Dropping ar_text and ar_flags columns' );
+                       }
+               }
        }
  
        /**
@@@ -1781,7 -1781,7 +1781,7 @@@ class WikiPage implements Page, IDBAcce
                        // Update recentchanges
                        if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
                                // Mark as patrolled if the user can do so
 -                              $patrolled = $wgUseRCPatrol && !count(
 +                              $autopatrolled = $wgUseRCPatrol && !count(
                                                $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) );
                                // Add RC row to the DB
                                RecentChange::notifyEdit(
                                        $oldContent ? $oldContent->getSize() : 0,
                                        $newsize,
                                        $revisionId,
 -                                      $patrolled,
 +                                      $autopatrolled ? RecentChange::PRC_AUTOPATROLLED :
 +                                              RecentChange::PRC_UNPATROLLED,
                                        $tags
                                );
                        }
                                        : DB_REPLICA; // T154554
  
                                $edit->popts->setSpeculativeRevIdCallback( function () use ( $dbIndex ) {
 -                                      return 1 + (int)wfGetDB( $dbIndex )->selectField(
 +                                      $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
 +                                      // Use a fresh connection in order to see the latest data, by avoiding
 +                                      // stale data from REPEATABLE-READ snapshots.
 +                                      $db = $lb->getConnectionRef( $dbIndex, [], false, $lb::CONN_TRX_AUTO );
 +
 +                                      return 1 + (int)$db->selectField(
                                                'revision',
                                                'MAX(rev_id)',
                                                [],
                // In the future, we may keep revisions and mark them with
                // the rev_deleted field, which is reserved for this purpose.
  
 +              // Lock rows in `revision` and its temp tables, but not any others.
 +              // Note array_intersect() preserves keys from the first arg, and we're
 +              // assuming $revQuery has `revision` primary and isn't using subtables
 +              // for anything we care about.
 +              $res = $dbw->select(
 +                      array_intersect(
 +                              $revQuery['tables'],
 +                              [ 'revision', 'revision_comment_temp', 'revision_actor_temp' ]
 +                      ),
 +                      '1',
 +                      [ 'rev_page' => $id ],
 +                      __METHOD__,
 +                      'FOR UPDATE',
 +                      $revQuery['joins']
 +              );
 +              foreach ( $res as $row ) {
 +                      // Fetch all rows in case the DB needs that to properly lock them.
 +              }
 +
                // Get all of the page revisions
                $res = $dbw->select(
                        $revQuery['tables'],
                        $revQuery['fields'],
                        [ 'rev_page' => $id ],
                        __METHOD__,
 -                      'FOR UPDATE',
 +                      [],
                        $revQuery['joins']
                );
  
                                'ar_rev_id'     => $row->rev_id,
                                'ar_parent_id'  => $row->rev_parent_id,
                                'ar_text_id'    => $row->rev_text_id,
-                               'ar_text'       => '',
-                               'ar_flags'      => '',
                                'ar_len'        => $row->rev_len,
                                'ar_page_id'    => $id,
                                'ar_deleted'    => $suppress ? $bitfield : $row->rev_deleted,
  
                if ( $wgUseRCPatrol ) {
                        // Mark all reverted edits as patrolled
 -                      $set['rc_patrolled'] = 1;
 +                      $set['rc_patrolled'] = RecentChange::PRC_PATROLLED;
                }
  
                if ( count( $set ) ) {
                        Hooks::run( 'CategoryAfterPageRemoved', [ $cat, $this, $id ] );
                }
  
 -              // Refresh counts on categories that should be empty now, to
 -              // trigger possible deletion. Check master for the most
 -              // up-to-date cat_pages.
 +              // Refresh counts on categories that should be empty now
                if ( count( $deleted ) ) {
                        $rows = $dbw->select(
                                'category',
                                [ 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ],
 -                              [ 'cat_title' => $deleted, 'cat_pages <= 0' ],
 +                              [ 'cat_title' => $deleted, 'cat_pages <= 100' ],
                                __METHOD__
                        );
                        foreach ( $rows as $row ) {
@@@ -270,7 -270,6 +270,6 @@@ CREATE TABLE /*_*/archive 
     ar_id int NOT NULL PRIMARY KEY IDENTITY,
     ar_namespace SMALLINT NOT NULL DEFAULT 0,
     ar_title NVARCHAR(255) NOT NULL DEFAULT '',
-    ar_text NVARCHAR(MAX) NOT NULL,
     ar_comment NVARCHAR(255) NOT NULL CONSTRAINT DF_ar_comment DEFAULT '',
     ar_comment_id bigint unsigned NOT NULL CONSTRAINT DF_ar_comment_id DEFAULT 0 CONSTRAINT FK_ar_comment_id FOREIGN KEY REFERENCES /*_*/comment(comment_id),
     ar_user INT CONSTRAINT ar_user__user_id__fk FOREIGN KEY REFERENCES /*_*/mwuser(user_id),
     ar_actor bigint unsigned NOT NULL CONSTRAINT DF_ar_actor DEFAULT 0,
     ar_timestamp varchar(14) NOT NULL default '',
     ar_minor_edit BIT NOT NULL DEFAULT 0,
-    ar_flags NVARCHAR(255) NOT NULL,
     ar_rev_id INT NOT NULL, -- NOT a FK, the row gets deleted from revision and moved here
-    ar_text_id INT CONSTRAINT ar_text_id__old_id__fk FOREIGN KEY REFERENCES /*_*/text(old_id) ON DELETE CASCADE,
+    ar_text_id INT NOT NULL CONSTRAINT DF_ar_text_id DEFAULT 0 CONSTRAINT ar_text_id__old_id__fk FOREIGN KEY REFERENCES /*_*/text(old_id) ON DELETE CASCADE,
     ar_deleted TINYINT NOT NULL DEFAULT 0,
     ar_len INT,
     ar_page_id INT NULL, -- NOT a FK, the row gets deleted from page and moved here
@@@ -1001,9 -999,8 +999,9 @@@ CREATE TABLE /*_*/recentchanges 
    -- If the Recent Changes Patrol option is enabled,
    -- users may mark edits as having been reviewed to
    -- remove a warning flag on the RC list.
 -  -- A value of 1 indicates the page has been reviewed.
 -  rc_patrolled bit NOT NULL default 0,
 +  -- A value of 1 indicates the page has been reviewed manually.
 +  -- A value of 2 indicates the page has been automatically reviewed.
 +  rc_patrolled tinyint NOT NULL CONSTRAINT DF_rc_patrolled DEFAULT 0
  
    -- Recorded IP address the edit was made from, if the
    -- $wgPutIPinRC option is enabled.
  );
  
  CREATE INDEX /*i*/rc_timestamp ON /*_*/recentchanges (rc_timestamp);
 -CREATE INDEX /*i*/rc_namespace_title ON /*_*/recentchanges (rc_namespace, rc_title);
 +CREATE INDEX /*i*/rc_namespace_title_timestamp ON /*_*/recentchanges (rc_namespace, rc_title, rc_timestamp);
  CREATE INDEX /*i*/rc_cur_id ON /*_*/recentchanges (rc_cur_id);
  CREATE INDEX /*i*/new_name_timestamp ON /*_*/recentchanges (rc_new,rc_namespace,rc_timestamp);
  CREATE INDEX /*i*/rc_ip ON /*_*/recentchanges (rc_ip);
@@@ -248,7 -248,6 +248,6 @@@ CREATE TABLE &mw_prefix.archive 
    ar_id          NUMBER NOT NULL,
    ar_namespace   NUMBER    DEFAULT 0 NOT NULL,
    ar_title       VARCHAR2(255)         NOT NULL,
-   ar_text        CLOB,
    ar_comment     VARCHAR2(255),
    ar_comment_id  NUMBER DEFAULT 0 NOT NULL,
    ar_user        NUMBER          DEFAULT 0 NOT NULL,
    ar_actor       NUMBER          DEFAULT 0 NOT NULL,
    ar_timestamp   TIMESTAMP(6) WITH TIME ZONE  NOT NULL,
    ar_minor_edit  CHAR(1)         DEFAULT '0' NOT NULL,
-   ar_flags       VARCHAR2(255),
    ar_rev_id      NUMBER NOT NULL,
-   ar_text_id     NUMBER,
+   ar_text_id     NUMBER DEFAULT 0 NOT NULL,
    ar_deleted     CHAR(1)      DEFAULT '0' NOT NULL,
    ar_len         NUMBER,
    ar_page_id     NUMBER,
@@@ -688,7 -686,7 +686,7 @@@ ALTER TABLE &mw_prefix.recentchanges AD
  ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk2 FOREIGN KEY (rc_cur_id) REFERENCES &mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
  ALTER TABLE &mw_prefix.recentchanges ADD CONSTRAINT &mw_prefix.recentchanges_fk3 FOREIGN KEY (rc_comment_id) REFERENCES &mw_prefix."COMMENT"(comment_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
  CREATE INDEX &mw_prefix.recentchanges_i01 ON &mw_prefix.recentchanges (rc_timestamp);
 -CREATE INDEX &mw_prefix.recentchanges_i02 ON &mw_prefix.recentchanges (rc_namespace, rc_title);
 +CREATE INDEX &mw_prefix.recentchanges_i09 ON &mw_prefix.recentchanges (rc_namespace, rc_title, rc_timestamp);
  CREATE INDEX &mw_prefix.recentchanges_i03 ON &mw_prefix.recentchanges (rc_cur_id);
  CREATE INDEX &mw_prefix.recentchanges_i04 ON &mw_prefix.recentchanges (rc_new,rc_namespace,rc_timestamp);
  CREATE INDEX &mw_prefix.recentchanges_i05 ON &mw_prefix.recentchanges (rc_ip);
@@@ -53,7 -53,6 +53,7 @@@ CREATE TABLE mwuser ( -- replace reserv
    user_editcount            INTEGER,
    user_password_expires     TIMESTAMPTZ NULL
  );
 +ALTER SEQUENCE user_user_id_seq OWNED BY mwuser.user_id;
  CREATE INDEX user_email_token_idx ON mwuser (user_email_token);
  
  -- Create a dummy user to satisfy fk contraints especially with revisions
@@@ -66,7 -65,6 +66,7 @@@ CREATE TABLE actor 
    actor_user INTEGER,
    actor_name    TEXT     NOT NULL
  );
 +ALTER SEQUENCE actor_actor_id_seq OWNED BY actor.actor_id;
  CREATE UNIQUE INDEX actor_user ON actor (actor_user);
  CREATE UNIQUE INDEX actor_name ON actor (actor_name);
  
@@@ -119,7 -117,6 +119,7 @@@ CREATE TABLE page 
    page_content_model TEXT,
    page_lang          TEXT                     DEFAULT NULL
  );
 +ALTER SEQUENCE page_page_id_seq OWNED BY page.page_id;
  CREATE UNIQUE INDEX page_unique_name ON page (page_namespace, page_title);
  CREATE INDEX page_main_title         ON page (page_title text_pattern_ops) WHERE page_namespace = 0;
  CREATE INDEX page_talk_title         ON page (page_title text_pattern_ops) WHERE page_namespace = 1;
@@@ -158,7 -155,6 +158,7 @@@ CREATE TABLE revision 
    rev_content_model  TEXT,
    rev_content_format TEXT
  );
 +ALTER SEQUENCE revision_rev_id_seq OWNED BY revision.rev_id;
  CREATE UNIQUE INDEX revision_unique ON revision (rev_page, rev_id);
  CREATE INDEX rev_text_id_idx        ON revision (rev_text_id);
  CREATE INDEX rev_timestamp_idx      ON revision (rev_timestamp);
@@@ -184,12 -180,13 +184,12 @@@ CREATE INDEX rev_actor_timestamp ON rev
  CREATE INDEX rev_page_actor_timestamp ON revision_actor_temp (revactor_page,revactor_actor,revactor_timestamp);
  
  CREATE SEQUENCE ip_changes_ipc_rev_id_seq;
 -
  CREATE TABLE ip_changes (
    ipc_rev_id        INTEGER PRIMARY KEY NOT NULL DEFAULT nextval('ip_changes_ipc_rev_id_seq'),
    ipc_rev_timestamp TIMESTAMPTZ NOT NULL,
    ipc_hex           BYTEA NOT NULL DEFAULT ''
  );
 -
 +ALTER SEQUENCE ip_changes_ipc_rev_id_seq OWNED BY ip_changes.ipc_rev_id;
  CREATE INDEX ipc_rev_timestamp ON ip_changes (ipc_rev_timestamp);
  CREATE INDEX ipc_hex_time ON ip_changes (ipc_hex,ipc_rev_timestamp);
  
@@@ -199,7 -196,6 +199,7 @@@ CREATE TABLE pagecontent ( -- replaces 
    old_text   TEXT,
    old_flags  TEXT
  );
 +ALTER SEQUENCE text_old_id_seq OWNED BY pagecontent.old_id;
  
  
  CREATE SEQUENCE comment_comment_id_seq;
@@@ -209,7 -205,6 +209,7 @@@ CREATE TABLE comment 
    comment_text TEXT    NOT NULL,
    comment_data TEXT
  );
 +ALTER SEQUENCE comment_comment_id_seq OWNED BY comment.comment_id;
  CREATE INDEX comment_hash ON comment (comment_hash);
  
  
@@@ -223,7 -218,6 +223,7 @@@ CREATE TABLE page_restrictions 
    pr_user    INTEGER          NULL,
    pr_expiry  TIMESTAMPTZ      NULL
  );
 +ALTER SEQUENCE page_restrictions_pr_id_seq OWNED BY page_restrictions.pr_id;
  ALTER TABLE page_restrictions ADD CONSTRAINT page_restrictions_pk PRIMARY KEY (pr_page,pr_type);
  
  CREATE TABLE page_props (
@@@ -242,7 -236,6 +242,6 @@@ CREATE TABLE archive 
    ar_id             INTEGER      NOT NULL  PRIMARY KEY DEFAULT nextval('archive_ar_id_seq'),
    ar_namespace      SMALLINT     NOT NULL,
    ar_title          TEXT         NOT NULL,
-   ar_text           TEXT, -- technically should be bytea, but not used anymore
    ar_page_id        INTEGER          NULL,
    ar_parent_id      INTEGER          NULL,
    ar_sha1           TEXT         NOT NULL DEFAULT '',
    ar_actor          INTEGER      NOT NULL DEFAULT 0,
    ar_timestamp      TIMESTAMPTZ  NOT NULL,
    ar_minor_edit     SMALLINT     NOT NULL  DEFAULT 0,
-   ar_flags          TEXT,
    ar_rev_id         INTEGER      NOT NULL,
-   ar_text_id        INTEGER,
+   ar_text_id        INTEGER      NOT NULL  DEFAULT 0,
    ar_deleted        SMALLINT     NOT NULL  DEFAULT 0,
    ar_len            INTEGER          NULL,
    ar_content_model  TEXT,
    ar_content_format TEXT
  );
 +ALTER SEQUENCE archive_ar_id_seq OWNED BY archive.ar_id;
  CREATE INDEX archive_name_title_timestamp ON archive (ar_namespace,ar_title,ar_timestamp);
  CREATE INDEX archive_user_text            ON archive (ar_user_text);
  CREATE INDEX archive_actor                ON archive (ar_actor);
@@@ -286,7 -277,6 +284,7 @@@ CREATE TABLE content 
    content_model   SMALLINT  NOT NULL,
    content_address TEXT      NOT NULL
  );
 +ALTER SEQUENCE content_content_id_seq OWNED BY content.content_id;
  
  
  CREATE SEQUENCE slot_roles_role_id_seq;
@@@ -294,7 -284,6 +292,7 @@@ CREATE TABLE slot_roles 
    role_id    SMALLINT  NOT NULL PRIMARY KEY DEFAULT nextval('slot_roles_role_id_seq'),
    role_name  TEXT      NOT NULL
  );
 +ALTER SEQUENCE slot_roles_role_id_seq OWNED BY slot_roles.role_id;
  
  CREATE UNIQUE INDEX role_name ON slot_roles (role_name);
  
@@@ -304,7 -293,6 +302,7 @@@ CREATE TABLE content_models 
    model_id    SMALLINT  NOT NULL PRIMARY KEY DEFAULT nextval('content_models_model_id_seq'),
    model_name  TEXT      NOT NULL
  );
 +ALTER SEQUENCE content_models_model_id_seq OWNED BY content_models.model_id;
  
  CREATE UNIQUE INDEX model_name ON content_models (model_name);
  
@@@ -364,7 -352,6 +362,7 @@@ CREATE TABLE externallinks 
    el_index    TEXT        NOT NULL,
    el_index_60 BYTEA       NOT NULL  DEFAULT ''
  );
 +ALTER SEQUENCE externallinks_el_id_seq OWNED BY externallinks.el_id;
  CREATE INDEX externallinks_from_to ON externallinks (el_from,el_to);
  CREATE INDEX externallinks_index   ON externallinks (el_index);
  CREATE INDEX el_index_60           ON externallinks (el_index_60, el_id);
@@@ -413,8 -400,8 +411,8 @@@ CREATE TABLE ipblocks 
    ipb_block_email       SMALLINT     NOT NULL  DEFAULT 0,
    ipb_allow_usertalk    SMALLINT     NOT NULL  DEFAULT 0,
    ipb_parent_block_id             INTEGER          NULL  REFERENCES ipblocks(ipb_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED
 -
  );
 +ALTER SEQUENCE ipblocks_ipb_id_seq OWNED BY ipblocks.ipb_id;
  CREATE UNIQUE INDEX ipb_address_unique ON ipblocks (ipb_address,ipb_user,ipb_auto,ipb_anon_only);
  CREATE INDEX ipb_user    ON ipblocks (ipb_user);
  CREATE INDEX ipb_range   ON ipblocks (ipb_range_start,ipb_range_end);
@@@ -504,7 -491,6 +502,7 @@@ CREATE TABLE filearchive 
    fa_deleted            SMALLINT     NOT NULL DEFAULT 0,
    fa_sha1               TEXT         NOT NULL DEFAULT ''
  );
 +ALTER SEQUENCE filearchive_fa_id_seq OWNED BY filearchive.fa_id;
  CREATE INDEX fa_name_time ON filearchive (fa_name, fa_timestamp);
  CREATE INDEX fa_dupe      ON filearchive (fa_storage_group, fa_storage_key);
  CREATE INDEX fa_notime    ON filearchive (fa_deleted_timestamp);
@@@ -513,6 -499,7 +511,6 @@@ CREATE INDEX fa_sha1      ON filearchiv
  
  CREATE SEQUENCE uploadstash_us_id_seq;
  CREATE TYPE media_type AS ENUM ('UNKNOWN','BITMAP','DRAWING','AUDIO','VIDEO','MULTIMEDIA','OFFICE','TEXT','EXECUTABLE','ARCHIVE','3D');
 -
  CREATE TABLE uploadstash (
    us_id           INTEGER PRIMARY KEY NOT NULL DEFAULT nextval('uploadstash_us_id_seq'),
    us_user         INTEGER,
    us_image_height INTEGER,
    us_image_bits   SMALLINT
  );
 +ALTER SEQUENCE uploadstash_us_id_seq OWNED BY uploadstash.us_id;
  
  CREATE INDEX us_user_idx ON uploadstash (us_user);
  CREATE UNIQUE INDEX us_key_idx ON uploadstash (us_key);
@@@ -569,10 -555,9 +567,10 @@@ CREATE TABLE recentchanges 
    rc_log_action      TEXT,
    rc_params          TEXT
  );
 +ALTER SEQUENCE recentchanges_rc_id_seq OWNED BY recentchanges.rc_id;
  CREATE INDEX rc_timestamp       ON recentchanges (rc_timestamp);
  CREATE INDEX rc_timestamp_bot   ON recentchanges (rc_timestamp) WHERE rc_bot = 0;
 -CREATE INDEX rc_namespace_title ON recentchanges (rc_namespace, rc_title);
 +CREATE INDEX rc_namespace_title_timestamp ON recentchanges (rc_namespace, rc_title, rc_timestamp);
  CREATE INDEX rc_cur_id          ON recentchanges (rc_cur_id);
  CREATE INDEX new_name_timestamp ON recentchanges (rc_new, rc_namespace, rc_timestamp);
  CREATE INDEX rc_ip              ON recentchanges (rc_ip);
@@@ -587,7 -572,6 +585,7 @@@ CREATE TABLE watchlist 
    wl_title                  TEXT        NOT NULL,
    wl_notificationtimestamp  TIMESTAMPTZ
  );
 +ALTER SEQUENCE watchlist_wl_id_seq OWNED BY watchlist.wl_id;
  CREATE UNIQUE INDEX wl_user_namespace_title ON watchlist (wl_namespace, wl_title, wl_user);
  CREATE INDEX wl_user ON watchlist (wl_user);
  CREATE INDEX wl_user_notificationtimestamp ON watchlist (wl_user, wl_notificationtimestamp);
@@@ -659,7 -643,6 +657,7 @@@ CREATE TABLE logging 
    log_user_text   TEXT         NOT NULL DEFAULT '',
    log_page        INTEGER
  );
 +ALTER SEQUENCE logging_log_id_seq OWNED BY logging.log_id;
  CREATE INDEX logging_type_name ON logging (log_type, log_timestamp);
  CREATE INDEX logging_user_time ON logging (log_timestamp, log_user);
  CREATE INDEX logging_actor_time_backwards ON logging (log_timestamp, log_actor);
@@@ -695,7 -678,6 +693,7 @@@ CREATE TABLE job 
    job_token_timestamp TIMESTAMPTZ,
    job_sha1            TEXT NOT NULL DEFAULT ''
  );
 +ALTER SEQUENCE job_job_id_seq OWNED BY job.job_id;
  CREATE INDEX job_sha1 ON job (job_sha1);
  CREATE INDEX job_cmd_token ON job (job_cmd, job_token, job_random);
  CREATE INDEX job_cmd_token_id ON job (job_cmd, job_token, job_id);
@@@ -703,6 -685,7 +701,6 @@@ CREATE INDEX job_cmd_namespace_title O
  CREATE INDEX job_timestamp_idx ON job (job_timestamp);
  
  -- Tsearch2 2 stuff. Will fail if we don't have proper access to the tsearch2 tables
 --- Version 8.3 or higher only. Previous versions would need another parmeter for to_tsvector.
  -- Make sure you also change patch-tsearch2funcs.sql if the funcs below change.
  
  ALTER TABLE page ADD titlevector tsvector;
@@@ -738,6 -721,9 +736,6 @@@ $mw$
  CREATE TRIGGER ts2_page_text BEFORE INSERT OR UPDATE ON pagecontent
    FOR EACH ROW EXECUTE PROCEDURE ts2_page_text();
  
 --- These are added by the setup script due to version compatibility issues
 --- If using 8.1, we switch from "gin" to "gist"
 -
  CREATE INDEX ts2_page_title ON page USING gin(titlevector);
  CREATE INDEX ts2_page_text ON pagecontent USING gin(textvector);
  
@@@ -785,7 -771,6 +783,7 @@@ CREATE TABLE category 
    cat_files    INTEGER  NOT NULL  DEFAULT 0,
    cat_hidden   SMALLINT NOT NULL  DEFAULT 0
  );
 +ALTER SEQUENCE category_cat_id_seq OWNED BY category.cat_id;
  CREATE UNIQUE INDEX category_title ON category(cat_title);
  CREATE INDEX category_pages ON category(cat_pages);
  
@@@ -798,7 -783,6 +796,7 @@@ CREATE TABLE change_tag 
    ct_tag     TEXT     NOT NULL,
    ct_params  TEXT         NULL
  );
 +ALTER SEQUENCE change_tag_ct_id_seq OWNED BY change_tag.ct_id;
  CREATE UNIQUE INDEX change_tag_rc_tag ON change_tag(ct_rc_id,ct_tag);
  CREATE UNIQUE INDEX change_tag_log_tag ON change_tag(ct_log_id,ct_tag);
  CREATE UNIQUE INDEX change_tag_rev_tag ON change_tag(ct_rev_id,ct_tag);
@@@ -812,7 -796,6 +810,7 @@@ CREATE TABLE tag_summary 
    ts_rev_id  INTEGER      NULL,
    ts_tags    TEXT     NOT NULL
  );
 +ALTER SEQUENCE tag_summary_ts_id_seq OWNED BY tag_summary.ts_id;
  CREATE UNIQUE INDEX tag_summary_rc_id ON tag_summary(ts_rc_id);
  CREATE UNIQUE INDEX tag_summary_log_id ON tag_summary(ts_log_id);
  CREATE UNIQUE INDEX tag_summary_rev_id ON tag_summary(ts_rev_id);
@@@ -866,7 -849,6 +864,7 @@@ CREATE TABLE sites 
    site_forward      SMALLINT    NOT NULL,
    site_config       TEXT        NOT NULL
  );
 +ALTER SEQUENCE sites_site_id_seq OWNED BY sites.site_id;
  CREATE UNIQUE INDEX site_global_key ON sites (site_global_key);
  CREATE INDEX site_type ON sites (site_type);
  CREATE INDEX site_group ON sites (site_group);
diff --combined maintenance/tables.sql
@@@ -592,14 -592,6 +592,6 @@@ CREATE TABLE /*_*/archive 
    -- Copied from page_title
    ar_title varchar(255) binary NOT NULL default '',
  
-   -- Copied from text.old_text, for pages deleted before MediaWiki 1.5.
-   -- This row may contain the raw revision text, possibly compressed.
-   -- Newer MediaWiki versions use ar_text_id instead.
-   -- This field is retained for backwards compatibility, so that
-   -- old archived pages will remain accessible.
-   -- See migrateArchiveText.php for migrating values to text storage.
-   ar_text mediumblob NOT NULL,
    -- Basic revision stuff...
    ar_comment varbinary(767) NOT NULL default '', -- Deprecated in favor of ar_comment_id
    ar_comment_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that ar_comment should be used)
    ar_timestamp binary(14) NOT NULL default '',
    ar_minor_edit tinyint NOT NULL default 0,
  
-   -- Copied from text.old_flags, for pages deleted before MediaWiki 1.5.
-   -- Otherwise empty string.
-   -- See also note for ar_text.
-   ar_flags tinyblob NOT NULL,
    -- Copied from rev_id.
    --
    -- @since 1.5 Entries from 1.4 will be NULL here. When restoring
    -- text storage. Instead, it is merely hidden from public view, by removal
    -- of the page and revision entries.
    --
-   -- @since 1.5 Entries from 1.2-1.4 will have NULL here. When restoring
-   -- archive rows without this, ar_text and ar_flags are used instead.
    -- @deprecated since 1.31. If rows in the slots table with slot_revision_id = ar_rev_id
-   -- exist, this field should be ignored (and may be NULL or 0) in favor of the
+   -- exist, this field should be ignored (and may be 0) in favor of the
    -- corresponding data from the slots and content tables
-   ar_text_id int unsigned,
+   ar_text_id int unsigned NOT NULL DEFAULT 0,
  
    -- Copied from rev_deleted. Although this may be raised during deletion.
    -- Users with the "suppressrevision" right may "archive" and "suppress"
@@@ -1464,7 -1449,7 +1449,7 @@@ CREATE TABLE /*_*/recentchanges 
  CREATE INDEX /*i*/rc_timestamp ON /*_*/recentchanges (rc_timestamp);
  
  -- Special:Watchlist
 -CREATE INDEX /*i*/rc_namespace_title ON /*_*/recentchanges (rc_namespace, rc_title);
 +CREATE INDEX /*i*/rc_namespace_title_timestamp ON /*_*/recentchanges (rc_namespace, rc_title, rc_timestamp);
  
  -- Special:Recentchangeslinked when finding changes in pages linked from a page
  CREATE INDEX /*i*/rc_cur_id ON /*_*/recentchanges (rc_cur_id);
@@@ -54,7 -54,7 +54,7 @@@ class RevisionTest extends MediaWikiTes
                        ->method( 'getArticleID' )
                        ->will( $this->returnValue( 23 ) );
                $mock->expects( $this->any() )
 -                      ->method( 'getModel' )
 +                      ->method( 'getContentModel' )
                        ->will( $this->returnValue( $model ) );
  
                return $mock;
                                'ar_id',
                                'ar_page_id',
                                'ar_rev_id',
-                               'ar_text',
                                'ar_text_id',
                                'ar_timestamp',
                                'ar_user_text',
                                'ar_id',
                                'ar_page_id',
                                'ar_rev_id',
-                               'ar_text',
                                'ar_text_id',
                                'ar_timestamp',
                                'ar_user_text',
                                        'ar_namespace',
                                        'ar_title',
                                        'ar_rev_id',
-                                       'ar_text',
                                        'ar_text_id',
                                        'ar_timestamp',
                                        'ar_minor_edit',
                                        'ar_namespace',
                                        'ar_title',
                                        'ar_rev_id',
-                                       'ar_text',
                                        'ar_text_id',
                                        'ar_timestamp',
                                        'ar_minor_edit',