aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Jorsch <bjorsch@wikimedia.org>2017-11-28 17:32:05 -0500
committerJforrester <jforrester@wikimedia.org>2018-05-03 18:12:42 +0000
commitbb8c060128a79532e1b6885fb3ebd6174d3f4d4d (patch)
tree76cc0db285e94a291cb2adfd7ebe74eb13ed206f
parentccc3d1fc0570c6e3057562b1583bd743aef5d9fb (diff)
downloadmediawikicore-bb8c060128a79532e1b6885fb3ebd6174d3f4d4d.tar.gz
mediawikicore-bb8c060128a79532e1b6885fb3ebd6174d3f4d4d.zip
Drop archive.ar_text and ar_flags
This should have been done long ago. Now it is being done. This also changes ar_text_id to NOT NULL, since it should never be null anymore, and DEFAULT 0 in preparation for MCR stopping writing it. Bug: T33223 Change-Id: I18f1c740b7537c7dc3cfeba9b241d0a9f31caa34 (cherry picked from commit 21c6ae1163b07da7ac49938f50613c0e1cf262c3)
-rw-r--r--RELEASE-NOTES-1.318
-rw-r--r--includes/Revision.php1
-rw-r--r--includes/Storage/RevisionStore.php6
-rw-r--r--includes/api/ApiQueryAllDeletedRevisions.php7
-rw-r--r--includes/api/ApiQueryDeletedRevisions.php7
-rw-r--r--includes/api/ApiQueryDeletedrevs.php15
-rw-r--r--includes/installer/DatabaseUpdater.php13
-rw-r--r--includes/page/PageArchive.php21
-rw-r--r--includes/page/WikiPage.php2
-rw-r--r--maintenance/archives/patch-drop-ar_text.sql7
-rw-r--r--maintenance/archives/patch-nullable-ar_text.sql13
-rw-r--r--maintenance/mssql/archives/patch-drop-ar_text.sql21
-rw-r--r--maintenance/mssql/tables.sql4
-rw-r--r--maintenance/oracle/archives/patch-drop-ar_text.sql7
-rw-r--r--maintenance/oracle/tables.sql4
-rw-r--r--maintenance/postgres/archives/patch-drop-ar_text.sql8
-rw-r--r--maintenance/postgres/tables.sql4
-rw-r--r--maintenance/sqlite/archives/patch-actor-table.sql18
-rw-r--r--maintenance/sqlite/archives/patch-ar_rev_id-not-null.sql12
-rw-r--r--maintenance/sqlite/archives/patch-drop-ar_text.sql44
-rw-r--r--maintenance/storage/trackBlobs.php19
-rw-r--r--maintenance/tables.sql19
-rw-r--r--tests/phpunit/includes/PageArchiveTest.php2
-rw-r--r--tests/phpunit/includes/RevisionDbTestBase.php6
-rw-r--r--tests/phpunit/includes/RevisionTest.php4
-rw-r--r--tests/phpunit/includes/Storage/RevisionStoreTest.php1
26 files changed, 147 insertions, 126 deletions
diff --git a/RELEASE-NOTES-1.31 b/RELEASE-NOTES-1.31
index 41fc0830c6b4..8b9abee6da55 100644
--- a/RELEASE-NOTES-1.31
+++ b/RELEASE-NOTES-1.31
@@ -5,6 +5,14 @@ THIS IS NOT A RELEASE YET
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
diff --git a/includes/Revision.php b/includes/Revision.php
index 22eb1150e361..c1fa4fafe632 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -413,7 +413,6 @@ class Revision implements IDBAccessObject {
'ar_id',
'ar_page_id',
'ar_rev_id',
- 'ar_text',
'ar_text_id',
'ar_timestamp',
'ar_user_text',
diff --git a/includes/Storage/RevisionStore.php b/includes/Storage/RevisionStore.php
index 1f0afaec0cab..13aedbab7496 100644
--- a/includes/Storage/RevisionStore.php
+++ b/includes/Storage/RevisionStore.php
@@ -724,11 +724,6 @@ class RevisionStore
'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 ) ) {
@@ -1704,7 +1699,6 @@ class RevisionStore
'ar_namespace',
'ar_title',
'ar_rev_id',
- 'ar_text',
'ar_text_id',
'ar_timestamp',
'ar_minor_edit',
diff --git a/includes/api/ApiQueryAllDeletedRevisions.php b/includes/api/ApiQueryAllDeletedRevisions.php
index f885b729b153..be1297799412 100644
--- a/includes/api/ApiQueryAllDeletedRevisions.php
+++ b/includes/api/ApiQueryAllDeletedRevisions.php
@@ -136,16 +136,11 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
}
if ( $this->fetchContent ) {
- // Modern MediaWiki has the content for deleted revs in the 'text'
- // table using fields old_text and old_flags. But revisions deleted
- // pre-1.5 store the content in the 'archive' table directly using
- // fields ar_text and ar_flags, and no corresponding 'text' row. So
- // we have to LEFT JOIN and fetch all four fields.
$this->addTables( 'text' );
$this->addJoinConds(
[ 'text' => [ 'LEFT JOIN', [ 'ar_text_id=old_id' ] ] ]
);
- $this->addFields( [ 'ar_text', 'ar_flags', 'old_text', 'old_flags' ] );
+ $this->addFields( [ 'old_text', 'old_flags' ] );
// This also means stricter restrictions
$this->checkUserRightsAny( [ 'deletedtext', 'undelete' ] );
diff --git a/includes/api/ApiQueryDeletedRevisions.php b/includes/api/ApiQueryDeletedRevisions.php
index b7fd8d4ddc60..1a1e8f7ac58f 100644
--- a/includes/api/ApiQueryDeletedRevisions.php
+++ b/includes/api/ApiQueryDeletedRevisions.php
@@ -88,16 +88,11 @@ class ApiQueryDeletedRevisions extends ApiQueryRevisionsBase {
}
if ( $this->fetchContent ) {
- // Modern MediaWiki has the content for deleted revs in the 'text'
- // table using fields old_text and old_flags. But revisions deleted
- // pre-1.5 store the content in the 'archive' table directly using
- // fields ar_text and ar_flags, and no corresponding 'text' row. So
- // we have to LEFT JOIN and fetch all four fields.
$this->addTables( 'text' );
$this->addJoinConds(
[ 'text' => [ 'LEFT JOIN', [ 'ar_text_id=old_id' ] ] ]
);
- $this->addFields( [ 'ar_text', 'ar_flags', 'old_text', 'old_flags' ] );
+ $this->addFields( [ 'old_text', 'old_flags' ] );
// This also means stricter restrictions
$this->checkUserRightsAny( [ 'deletedtext', 'undelete' ] );
diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php
index 2d5074178ef6..83d00a933015 100644
--- a/includes/api/ApiQueryDeletedrevs.php
+++ b/includes/api/ApiQueryDeletedrevs.php
@@ -144,17 +144,11 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
}
if ( $fld_content ) {
- // Modern MediaWiki has the content for deleted revs in the 'text'
- // table using fields old_text and old_flags. But revisions deleted
- // pre-1.5 store the content in the 'archive' table directly using
- // fields ar_text and ar_flags, and no corresponding 'text' row. So
- // we have to LEFT JOIN and fetch all four fields, plus ar_text_id
- // to be able to tell the difference.
$this->addTables( 'text' );
$this->addJoinConds(
[ 'text' => [ 'LEFT JOIN', [ 'ar_text_id=old_id' ] ] ]
);
- $this->addFields( [ 'ar_text', 'ar_flags', 'ar_text_id', 'old_text', 'old_flags' ] );
+ $this->addFields( [ 'ar_text_id', 'old_text', 'old_flags' ] );
// This also means stricter restrictions
$this->checkUserRightsAny( [ 'deletedtext', 'undelete' ] );
@@ -370,12 +364,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_TEXT, $user ) ) {
- if ( isset( $row->ar_text ) && !$row->ar_text_id ) {
- // Pre-1.5 ar_text row (if condition from Revision::newFromArchiveRow)
- ApiResult::setContentValue( $rev, 'text', Revision::getRevisionText( $row, 'ar_' ) );
- } else {
- ApiResult::setContentValue( $rev, 'text', Revision::getRevisionText( $row ) );
- }
+ ApiResult::setContentValue( $rev, 'text', Revision::getRevisionText( $row ) );
}
}
diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php
index 04132ad57774..b56ab62dac50 100644
--- a/includes/installer/DatabaseUpdater.php
+++ b/includes/installer/DatabaseUpdater.php
@@ -1257,10 +1257,15 @@ abstract class DatabaseUpdater {
* @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' );
+ }
+ }
}
/**
diff --git a/includes/page/PageArchive.php b/includes/page/PageArchive.php
index 05247cafebb0..8b42020af230 100644
--- a/includes/page/PageArchive.php
+++ b/includes/page/PageArchive.php
@@ -315,19 +315,13 @@ class PageArchive {
}
/**
- * Get the text from an archive row containing ar_text, ar_flags and ar_text_id
+ * Get the text from an archive row containing ar_text_id
*
+ * @deprecated since 1.31
* @param object $row Database row
* @return string
*/
public function getTextFromRow( $row ) {
- if ( is_null( $row->ar_text_id ) ) {
- // An old row from MediaWiki 1.4 or previous.
- // Text is embedded in this row in classic compression format.
- return Revision::getRevisionText( $row, 'ar_' );
- }
-
- // New-style: keyed to the text storage backend.
$dbr = wfGetDB( DB_REPLICA );
$text = $dbr->selectRow( 'text',
[ 'old_text', 'old_flags' ],
@@ -347,15 +341,18 @@ class PageArchive {
*/
public function getLastRevisionText() {
$dbr = wfGetDB( DB_REPLICA );
- $row = $dbr->selectRow( 'archive',
- [ 'ar_text', 'ar_flags', 'ar_text_id' ],
+ $row = $dbr->selectRow(
+ [ 'archive', 'text' ],
+ [ 'old_text', 'old_flags' ],
[ 'ar_namespace' => $this->title->getNamespace(),
'ar_title' => $this->title->getDBkey() ],
__METHOD__,
- [ 'ORDER BY' => 'ar_timestamp DESC' ] );
+ [ 'ORDER BY' => 'ar_timestamp DESC, ar_id DESC' ],
+ [ 'text' => [ 'JOIN', 'old_id = ar_text_id' ] ]
+ );
if ( $row ) {
- return $this->getTextFromRow( $row );
+ return Revision::getRevisionText( $row );
}
return null;
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index afe266bf71d7..820df58de7e3 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -2918,8 +2918,6 @@ class WikiPage implements Page, IDBAccessObject {
'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,
diff --git a/maintenance/archives/patch-drop-ar_text.sql b/maintenance/archives/patch-drop-ar_text.sql
new file mode 100644
index 000000000000..6dae71e3296b
--- /dev/null
+++ b/maintenance/archives/patch-drop-ar_text.sql
@@ -0,0 +1,7 @@
+-- T33223: Remove obsolete ar_text and ar_flags columns
+-- (and make ar_text_id not nullable and default 0)
+
+ALTER TABLE /*_*/archive
+ DROP COLUMN ar_text,
+ DROP COLUMN ar_flags,
+ CHANGE COLUMN ar_text_id ar_text_id int unsigned NOT NULL DEFAULT 0;
diff --git a/maintenance/archives/patch-nullable-ar_text.sql b/maintenance/archives/patch-nullable-ar_text.sql
new file mode 100644
index 000000000000..b62ebfacb8d3
--- /dev/null
+++ b/maintenance/archives/patch-nullable-ar_text.sql
@@ -0,0 +1,13 @@
+--
+-- patch-nullable-ar_text.sql
+--
+-- This patch is provided as an example for people not using update.php.
+-- You need to make a change like this before running a version of MediaWiki
+-- containing Gerrit change 5ca2d4a551, then you can run maintenance/migrateArchiveText.php
+-- and apply patch-drop-ar_text.sql at your leisure.
+--
+-- See also T33223.
+
+ALTER TABLE /*_*/archive
+ MODIFY COLUMN ar_text mediumblob NULL,
+ MODIFY COLUMN ar_flags tinyblob NULL;
diff --git a/maintenance/mssql/archives/patch-drop-ar_text.sql b/maintenance/mssql/archives/patch-drop-ar_text.sql
new file mode 100644
index 000000000000..c9b975ccebc9
--- /dev/null
+++ b/maintenance/mssql/archives/patch-drop-ar_text.sql
@@ -0,0 +1,21 @@
+DECLARE @sql nvarchar(max),
+ @id sysname;--
+
+SET @sql = 'ALTER TABLE /*_*/archive DROP CONSTRAINT ';--
+
+SELECT @id = df.name
+FROM sys.default_constraints df
+JOIN sys.columns c
+ ON c.object_id = df.parent_object_id
+ AND c.column_id = df.parent_column_id
+WHERE
+ df.parent_object_id = OBJECT_ID('/*_*/archive')
+ AND ( c.name = 'ar_text' OR c.name = 'ar_flags' );--
+
+SET @sql = @sql + @id;--
+
+EXEC sp_executesql @sql;--
+
+ALTER TABLE /*_*/archive DROP COLUMN ar_text;
+ALTER TABLE /*_*/archive DROP COLUMN ar_flags;
+ALTER TABLE /*_*/archive ALTER COLUMN ar_text_id INT NOT NULL CONSTRAINT DF_ar_text_id DEFAULT 0;
diff --git a/maintenance/mssql/tables.sql b/maintenance/mssql/tables.sql
index 39a80e78ba1b..65ede90ea8d6 100644
--- a/maintenance/mssql/tables.sql
+++ b/maintenance/mssql/tables.sql
@@ -270,7 +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),
@@ -278,9 +277,8 @@ CREATE TABLE /*_*/archive (
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
diff --git a/maintenance/oracle/archives/patch-drop-ar_text.sql b/maintenance/oracle/archives/patch-drop-ar_text.sql
new file mode 100644
index 000000000000..40b047862c20
--- /dev/null
+++ b/maintenance/oracle/archives/patch-drop-ar_text.sql
@@ -0,0 +1,7 @@
+-- T33223: Remove obsolete ar_text and ar_flags columns
+-- (and make ar_text_id not nullable and default 0)
+
+define mw_prefix='{$wgDBprefix}';
+
+ALTER TABLE &mw_prefix.archive DROP (ar_text, ar_flags);
+ALTER TABLE &mw_prefix.archive MODIFY ar_text_id NUMBER DEFAULT 0 NOT NULL;
diff --git a/maintenance/oracle/tables.sql b/maintenance/oracle/tables.sql
index 8d297a79d0f3..87039fb0900a 100644
--- a/maintenance/oracle/tables.sql
+++ b/maintenance/oracle/tables.sql
@@ -248,7 +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,
@@ -256,9 +255,8 @@ CREATE TABLE &mw_prefix.archive (
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,
diff --git a/maintenance/postgres/archives/patch-drop-ar_text.sql b/maintenance/postgres/archives/patch-drop-ar_text.sql
new file mode 100644
index 000000000000..a2e8e416a993
--- /dev/null
+++ b/maintenance/postgres/archives/patch-drop-ar_text.sql
@@ -0,0 +1,8 @@
+-- T33223: Remove obsolete ar_text and ar_flags columns
+-- (and make ar_text_id not nullable and default 0)
+
+ALTER TABLE archive
+ DROP COLUMN ar_text,
+ DROP COLUMN ar_flags,
+ ALTER COLUMN ar_text_id SET DEFAULT 0;
+ ALTER COLUMN ar_text_id SET NOT NULL;
diff --git a/maintenance/postgres/tables.sql b/maintenance/postgres/tables.sql
index f3854728c2e2..53026acff9b2 100644
--- a/maintenance/postgres/tables.sql
+++ b/maintenance/postgres/tables.sql
@@ -242,7 +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 '',
@@ -253,9 +252,8 @@ CREATE TABLE archive (
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,
diff --git a/maintenance/sqlite/archives/patch-actor-table.sql b/maintenance/sqlite/archives/patch-actor-table.sql
index 19c4d3add390..d9a018ef7196 100644
--- a/maintenance/sqlite/archives/patch-actor-table.sql
+++ b/maintenance/sqlite/archives/patch-actor-table.sql
@@ -30,7 +30,6 @@ CREATE TABLE /*_*/archive_tmp (
ar_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
ar_namespace int NOT NULL default 0,
ar_title varchar(255) binary NOT NULL default '',
- ar_text mediumblob NOT NULL,
ar_comment varbinary(767) NOT NULL default '',
ar_comment_id bigint unsigned NOT NULL DEFAULT 0,
ar_user int unsigned NOT NULL default 0,
@@ -38,9 +37,8 @@ CREATE TABLE /*_*/archive_tmp (
ar_actor bigint unsigned NOT NULL DEFAULT 0,
ar_timestamp binary(14) NOT NULL default '',
ar_minor_edit tinyint NOT NULL default 0,
- ar_flags tinyblob NOT NULL,
ar_rev_id int unsigned,
- ar_text_id int unsigned,
+ ar_text_id int unsigned NOT NULL default 0,
ar_deleted tinyint unsigned NOT NULL default 0,
ar_len int unsigned,
ar_page_id int unsigned,
@@ -51,15 +49,13 @@ CREATE TABLE /*_*/archive_tmp (
) /*$wgDBTableOptions*/;
INSERT OR IGNORE INTO /*_*/archive_tmp (
- ar_id, ar_namespace, ar_title, ar_text, ar_comment, ar_user, ar_user_text,
- ar_timestamp, ar_minor_edit, ar_flags, ar_rev_id, ar_text_id, ar_deleted,
- ar_len, ar_page_id, ar_parent_id, ar_sha1, ar_content_model,
- ar_content_format)
+ ar_id, ar_namespace, ar_title, ar_comment, ar_user, ar_user_text,
+ ar_timestamp, ar_minor_edit, ar_rev_id, ar_text_id, ar_deleted, ar_len,
+ ar_page_id, ar_parent_id, ar_sha1, ar_content_model, ar_content_format)
SELECT
- ar_id, ar_namespace, ar_title, ar_text, ar_comment, ar_user, ar_user_text,
- ar_timestamp, ar_minor_edit, ar_flags, ar_rev_id, ar_text_id, ar_deleted,
- ar_len, ar_page_id, ar_parent_id, ar_sha1, ar_content_model,
- ar_content_format
+ ar_id, ar_namespace, ar_title, ar_comment, ar_user, ar_user_text,
+ ar_timestamp, ar_minor_edit, ar_rev_id, ar_text_id, ar_deleted, ar_len,
+ ar_page_id, ar_parent_id, ar_sha1, ar_content_model, ar_content_format
FROM /*_*/archive;
DROP TABLE /*_*/archive;
diff --git a/maintenance/sqlite/archives/patch-ar_rev_id-not-null.sql b/maintenance/sqlite/archives/patch-ar_rev_id-not-null.sql
index 3df205feab37..86507516a41d 100644
--- a/maintenance/sqlite/archives/patch-ar_rev_id-not-null.sql
+++ b/maintenance/sqlite/archives/patch-ar_rev_id-not-null.sql
@@ -7,7 +7,6 @@ CREATE TABLE /*_*/archive_tmp (
ar_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
ar_namespace int NOT NULL default 0,
ar_title varchar(255) binary NOT NULL default '',
- ar_text mediumblob NOT NULL,
ar_comment varbinary(767) NOT NULL default '',
ar_comment_id bigint unsigned NOT NULL DEFAULT 0,
ar_user int unsigned NOT NULL default 0,
@@ -15,9 +14,8 @@ CREATE TABLE /*_*/archive_tmp (
ar_actor bigint unsigned NOT NULL DEFAULT 0,
ar_timestamp binary(14) NOT NULL default '',
ar_minor_edit tinyint NOT NULL default 0,
- ar_flags tinyblob NOT NULL,
ar_rev_id int unsigned NOT NULL,
- ar_text_id int unsigned,
+ ar_text_id int unsigned NOT NULL default 0,
ar_deleted tinyint unsigned NOT NULL default 0,
ar_len int unsigned,
ar_page_id int unsigned,
@@ -28,13 +26,13 @@ CREATE TABLE /*_*/archive_tmp (
) /*$wgDBTableOptions*/;
INSERT OR IGNORE INTO /*_*/archive_tmp (
- ar_id, ar_namespace, ar_title, ar_text, ar_comment, ar_comment_id, ar_user,
- ar_user_text, ar_actor, ar_timestamp, ar_minor_edit, ar_flags, ar_rev_id,
+ ar_id, ar_namespace, ar_title, ar_comment, ar_comment_id, ar_user,
+ ar_user_text, ar_actor, ar_timestamp, ar_minor_edit, ar_rev_id,
ar_text_id, ar_deleted, ar_len, ar_page_id, ar_parent_id, ar_sha1,
ar_content_model, ar_content_format)
SELECT
- ar_id, ar_namespace, ar_title, ar_text, ar_comment, ar_comment_id, ar_user,
- ar_user_text, ar_actor, ar_timestamp, ar_minor_edit, ar_flags, ar_rev_id,
+ ar_id, ar_namespace, ar_title, ar_comment, ar_comment_id, ar_user,
+ ar_user_text, ar_actor, ar_timestamp, ar_minor_edit, ar_rev_id,
ar_text_id, ar_deleted, ar_len, ar_page_id, ar_parent_id, ar_sha1,
ar_content_model, ar_content_format
FROM /*_*/archive;
diff --git a/maintenance/sqlite/archives/patch-drop-ar_text.sql b/maintenance/sqlite/archives/patch-drop-ar_text.sql
new file mode 100644
index 000000000000..67bbece46bc6
--- /dev/null
+++ b/maintenance/sqlite/archives/patch-drop-ar_text.sql
@@ -0,0 +1,44 @@
+-- T33223: Remove obsolete ar_text and ar_flags columns
+-- (and make ar_text_id not nullable and default 0)
+
+BEGIN;
+
+DROP TABLE IF EXISTS /*_*/archive_tmp;
+CREATE TABLE /*_*/archive_tmp (
+ ar_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ ar_namespace int NOT NULL default 0,
+ ar_title varchar(255) binary NOT NULL default '',
+ ar_comment varbinary(767) NOT NULL default '',
+ ar_comment_id bigint unsigned NOT NULL DEFAULT 0,
+ ar_user int unsigned NOT NULL default 0,
+ ar_user_text varchar(255) binary NOT NULL,
+ ar_timestamp binary(14) NOT NULL default '',
+ ar_minor_edit tinyint NOT NULL default 0,
+ ar_rev_id int unsigned,
+ ar_text_id int unsigned NOT NULL default 0,
+ ar_deleted tinyint unsigned NOT NULL default 0,
+ ar_len int unsigned,
+ ar_page_id int unsigned,
+ ar_parent_id int unsigned default NULL,
+ ar_sha1 varbinary(32) NOT NULL default '',
+ ar_content_model varbinary(32) DEFAULT NULL,
+ ar_content_format varbinary(64) DEFAULT NULL
+) /*$wgDBTableOptions*/;
+
+INSERT OR IGNORE INTO /*_*/archive_tmp (
+ ar_id, ar_namespace, ar_title, ar_comment, ar_user, ar_user_text,
+ ar_timestamp, ar_minor_edit, ar_rev_id, ar_text_id, ar_deleted, ar_len,
+ ar_page_id, ar_parent_id, ar_sha1, ar_content_model, ar_content_format)
+ SELECT
+ ar_id, ar_namespace, ar_title, ar_comment, ar_user, ar_user_text,
+ ar_timestamp, ar_minor_edit, ar_rev_id, ar_text_id, ar_deleted, ar_len,
+ ar_page_id, ar_parent_id, ar_sha1, ar_content_model, ar_content_format
+ FROM /*_*/archive;
+
+DROP TABLE /*_*/archive;
+ALTER TABLE /*_*/archive_tmp RENAME TO /*_*/archive;
+CREATE INDEX /*i*/name_title_timestamp ON /*_*/archive (ar_namespace,ar_title,ar_timestamp);
+CREATE INDEX /*i*/ar_usertext_timestamp ON /*_*/archive (ar_user_text,ar_timestamp);
+CREATE INDEX /*i*/ar_revid ON /*_*/archive (ar_rev_id);
+
+COMMIT;
diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php
index a1e157dc8e95..36b6f5b459af 100644
--- a/maintenance/storage/trackBlobs.php
+++ b/maintenance/storage/trackBlobs.php
@@ -87,25 +87,6 @@ class TrackBlobs {
exit( 1 );
}
- // Scan the archive table for HistoryBlobStub objects or external flags (T24624)
- $flags = $dbr->selectField( 'archive', 'ar_flags',
- 'ar_flags LIKE \'%external%\' OR (' .
- 'ar_flags LIKE \'%object%\' ' .
- 'AND LOWER(CONVERT(LEFT(ar_text,22) USING latin1)) = \'o:15:"historyblobstub"\' )',
- __METHOD__
- );
-
- if ( strpos( $flags, 'external' ) !== false ) {
- echo "Integrity check failed: found external storage pointers in your archive table.\n" .
- "Run normaliseArchiveTable.php to fix this.\n";
- exit( 1 );
- } elseif ( $flags ) {
- echo "Integrity check failed: found HistoryBlobStub objects in your archive table.\n" .
- "These objects are probably already broken, continuing would make them\n" .
- "unrecoverable. Run \"normaliseArchiveTable.php --fix-cgz-bug\" to fix this.\n";
- exit( 1 );
- }
-
echo "Integrity check OK\n";
}
diff --git a/maintenance/tables.sql b/maintenance/tables.sql
index 1da651adaf0d..df3264a43cf9 100644
--- a/maintenance/tables.sql
+++ b/maintenance/tables.sql
@@ -592,14 +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)
@@ -609,11 +601,6 @@ CREATE TABLE /*_*/archive (
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
@@ -626,12 +613,10 @@ CREATE TABLE /*_*/archive (
-- 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"
diff --git a/tests/phpunit/includes/PageArchiveTest.php b/tests/phpunit/includes/PageArchiveTest.php
index 7fdc3ed8e1d6..623d4a65f173 100644
--- a/tests/phpunit/includes/PageArchiveTest.php
+++ b/tests/phpunit/includes/PageArchiveTest.php
@@ -169,7 +169,6 @@ class PageArchiveTest extends MediaWikiTestCase {
'ar_id' => '2',
'ar_namespace' => '0',
'ar_title' => 'PageArchiveTest_thePage',
- 'ar_text' => '',
'ar_text_id' => '3',
'ar_parent_id' => '2',
],
@@ -195,7 +194,6 @@ class PageArchiveTest extends MediaWikiTestCase {
'ar_id' => '1',
'ar_namespace' => '0',
'ar_title' => 'PageArchiveTest_thePage',
- 'ar_text' => '',
'ar_text_id' => '2',
'ar_parent_id' => '0',
],
diff --git a/tests/phpunit/includes/RevisionDbTestBase.php b/tests/phpunit/includes/RevisionDbTestBase.php
index 61f18021dedc..5de34d1ba652 100644
--- a/tests/phpunit/includes/RevisionDbTestBase.php
+++ b/tests/phpunit/includes/RevisionDbTestBase.php
@@ -350,12 +350,6 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
];
yield [
function ( $f ) {
- unset( $f['ar_text'] );
- return $f;
- },
- ];
- yield [
- function ( $f ) {
unset( $f['ar_text_id'] );
return $f;
},
diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php
index d928fb451213..ab067a4746b5 100644
--- a/tests/phpunit/includes/RevisionTest.php
+++ b/tests/phpunit/includes/RevisionTest.php
@@ -985,7 +985,6 @@ class RevisionTest extends MediaWikiTestCase {
'ar_id',
'ar_page_id',
'ar_rev_id',
- 'ar_text',
'ar_text_id',
'ar_timestamp',
'ar_user_text',
@@ -1007,7 +1006,6 @@ class RevisionTest extends MediaWikiTestCase {
'ar_id',
'ar_page_id',
'ar_rev_id',
- 'ar_text',
'ar_text_id',
'ar_timestamp',
'ar_user_text',
@@ -1097,7 +1095,6 @@ class RevisionTest extends MediaWikiTestCase {
'ar_namespace',
'ar_title',
'ar_rev_id',
- 'ar_text',
'ar_text_id',
'ar_timestamp',
'ar_minor_edit',
@@ -1129,7 +1126,6 @@ class RevisionTest extends MediaWikiTestCase {
'ar_namespace',
'ar_title',
'ar_rev_id',
- 'ar_text',
'ar_text_id',
'ar_timestamp',
'ar_minor_edit',
diff --git a/tests/phpunit/includes/Storage/RevisionStoreTest.php b/tests/phpunit/includes/Storage/RevisionStoreTest.php
index 849894755b3a..0bce572da12e 100644
--- a/tests/phpunit/includes/Storage/RevisionStoreTest.php
+++ b/tests/phpunit/includes/Storage/RevisionStoreTest.php
@@ -254,7 +254,6 @@ class RevisionStoreTest extends MediaWikiTestCase {
'ar_namespace',
'ar_title',
'ar_rev_id',
- 'ar_text',
'ar_text_id',
'ar_timestamp',
'ar_minor_edit',