This page is a translated version of the page Manual:Revision table and the translation is 88% complete.
手册:索引 MediaWiki数据库布局 revision表
MediaWiki版本:
1.5

revision表保存了wiki上所有對頁面編輯的元資料。 每一笔编辑会创建一个修订版本(revision)行,其中包括如进行修改的用户、提交编辑的时间,至comment 表中版本编辑摘要的链接及其他元数据。 The slots that were edited and their corresponding revision are specified in the slots table.

从另一个wiki导入页面的最后修订版本会在revision表中产生两行,一行是导入的修订版本的日期和维基文本,另一行则有导入日期。 后者的维基文本即当前页面的维基文本,如果同名页面已经存在,则是两个页面中时间较晚的版本。

revision表非常类似于recentchanges 表。 revision表被用于页面历史用户贡献 的列出。 recentchanges 表被用于最近更改 相关更改 监视列表 ,且对于新创建的页面用于新页面列表

差异包括:

  • recentchanges表还记录了事件,例如页面移动和删除。
  • recentchanges表中的项目被定期清理,而revision表中的内容永久保留,除非页面被删除或网站站长运行deleteOldRevisions.php 维护脚本。
  • 如上所述,导入一个页面的修订版本不止添加一个带有导入日期的项到revision表,还添加一份带有原始日期的版本。

已删除的修订版本被转移到archive 表。

revision表和text表于MediaWiki 1.5 引入以取代cur 表。

欄位

rev_id

MediaWiki版本:
1.5

此欄位保存每個版本的主鍵。 page_latest 是指向此欄位的外鍵。 数字rev_id自该表于MediaWiki 1.5创建依赖,跨越删除/取消删除,保持不变,用rev_id和text_id取代了旧的cur_id。

Note that while rev_id almost always increases monotonically for successive revisions of a page, this is not strictly guaranteed as importing from another wiki can cause revisions to be created out of order.

rev_page

MediaWiki版本:
1.5

该字段引用了page 表示与此修订相关的页面。 此字段中的数字等于所涉页面的page_id 字段。 这永远不会无效;如果发生,则该修订版本不会出现在页面历史记录中。 如果page.page_latest链接到的修订版本有无效的rev_page,将导致“页面'Foo'的修订版本#0不存在”错误。 (slots或content缺失修订版本时可能发生类似的问题)

rev_text_id

MediaWiki版本:
1.5 – 1.34

这是text 表中old_id 的外键。 (text表是文本的实际存储桶。) 多个修订版本可能有相同的文本——例如仅修改元数据的修订,或者rollback 到之前的修订版本。

(在1.31版本中已弃用) 如果slots 表中有slots.slot_revision_id = rev_id存在,应忽略此字段(并可能为0),以支持slots和content的相应数据。

(在版本1.35移除) 该列已被content.content_address取代,可以通过slots表中相应版本的slot_content_id 取得。

rev_comment

MediaWiki版本:
1.5 – 1.34

该列存有编者在修订版本时留下的编辑摘要。 该文本显示于历史记录贡献记录。 (The recentchanges table contains a copy used for recent changes , related changes , watchlists , and, in the case of page creation, for the list of new pages .) 呈现时以能安全表现的wiki标记格式子集处理。

(已弃用) 应使用revision_comment_temp表的revcomment_comment_id comment 表代替!

(在版本1.35移除) 此列已被revision.rev_comment_id取代,其引用了comment.comment_id

rev_comment_id

MediaWiki版本:
1.35

这是comment 表中comment_id 的外键。

在MediaWiki 1.38或之前,如果该字段的每个记录都为0,必须从revision_comment_temp 表获取编辑摘要ID。 参见Actor migration

rev_user

MediaWiki版本:
1.5 – 1.34

这是提交编辑的用户的user_id 。 对于匿名编辑、初始化脚本和某些批量导入,该字段的值为0。

注意,存在缺陷:T112384

(在1.31版本中已弃用) 执行角色迁移的过程中,取决于$wgActorTableSchemaMigrationStage 设置,该字段可能为空,执行编辑的角色可以改为存储在rev_actor字段或revision_actor_temp 表。

(在版本1.35移除) 此列已随revision.rev_user_text移除。 此列已被revision.rev_actor取代,其引用了actor.actor_id

rev_user_text

MediaWiki版本:
1.5 – 1.34

此字段存有编辑者的用户名 文本,或IP地址(如果编辑者是未注册用户)。

UseModWiki导入的匿名修订版本或者Phase II软件的早期实现下,该字段可能包含一个最后一组被遮盖的IP地址(即\d{1,3}\.\d{1,3}\.\d{1,3}\.xxx呈现为24.150.61.xxx;另见bug 3631)。 使用UseModWiki导入的部分编辑可能含有一个反向DNS查询主机名,如ppfree165-153-bz.aknet.it或者office.bomis.com

(在1.31版本中已弃用) 执行角色迁移的过程中,取决于$wgActorTableSchemaMigrationStage 设置,该字段可能为空,执行编辑的角色可以改为存储在rev_actor字段或revision_actor_temp 表。

(在版本1.35移除) 此列已随revision.rev_user移除。 此列已被revision.rev_actor取代,其引用了actor.actor_id

rev_actor

MediaWiki版本:
1.35

这是actor 表中actor_id 的外键。 在MediaWiki 1.38或之前,如果该字段的每个记录都为0,必须从revision_actor_temp 表获取演员ID。 参见Actor migration

rev_timestamp

MediaWiki版本:
1.5

存有编辑的timestamp Looks like, for example, 20080326231614 (MW_TS time format). Corresponds to recentchanges.rc_timestamp (and logging.log_timestamp for page creations).

Unlike image.img_timestamp, this value is not fudged to be unique for a given page, so edits happening in quick succession can have the same timestamp.

rev_minor_edit

MediaWiki版本:
1.5

记录用户是否标记为小修改。 标记为小修改则该值为1,否则该值为0。 许多自动化编辑被标记为小修改。

rev_deleted

MediaWiki版本:
1.5

此字段为手册:修订版本删除 系统保留。 这是一个位元字段(bitfield),值表示方法是:DELETED_TEXT = 1(删除文本);DELETED_COMMENT = 2(删除编辑摘要);DELETED_USER = 4(删除用户名);DELETED_RESTRICTED = 8。 因此,如果该修订版本没有任何删除,则该值为0;如果编辑摘要和用户名被删除,该值为6。 DELETED_RESTRICTED indicates suppression; when this flag is set content hidden by the other DELETED_* flags is only visible to suppressors (i.e. oversighters) instead of admins.

rev_len

MediaWiki版本:
1.10

该字段包含此修订后页面的长度,字节为单位。 用于历史记录页面。 对应rc_new_len

rev_parent_id

MediaWiki版本:
1.10

此页面的上一个修订版本的rev_id。 对应rc_last_oldid 。 对于创建页面的编辑,rev_parent_id = 0。

用法

此字段用于增加树结构的支持。 此字段用于如页面历史记录界面中的某个修订版本与先前修订版本大小的计算。 如果父ID指向另一个页面相关联的修订版本,MediaWiki仍将使用该父修订版本作为比较基础来计算大小差异。 如果一个修订版本已从数据库中删除,并且另一个修订版本的父ID仍指向该修订,那么MediaWiki采取的行为与没有父修订版本相同,即假设之前的大小为0。

转移修订版本

When revisions are imported from another wiki, the imported revisions' parent ID tree structure from the source wiki is retained (this is implemented by each revision', other than the tail revision, having a ‎<parentid> XML element that is used to populate rev_parent_id), and the destination wiki's revisions' parent IDs are not updated. Likewise, when page histories are merged, the parent IDs of the revisions from the source and destination pages are not updated. populateParentId.php 可以用于填充rev_parent_id,基于修订版本时间戳和修订版本ID。 In the case of an edit conflict, the revision ID of the edit that is saved first (causing the conflict) will be used as the parent ID of the edit that is saved second (after resolving the conflict).

rev_sha1

MediaWiki版本:
1.19

此字段用于添加base-36格式的SHA-1文本(由Wikimedia\base_convert()生成)。 自1.32版本起,它是content_sha1 所有修订版本slots的嵌套散列值。 If the revision only has one slot, the values of the rev_sha1 and content_sha1 fields are identical. 嵌套散列算法于RevisionSlots::computeSha1()实现。 可以概括为:

 rev_sha1 = hash_n;
 hash_n = sha1( hash_n-1, content_sha1_n );
 hash_1 = content_sha1_1;

rev_content_model

MediaWiki版本:
1.21 – 1.34

内容模型见Defines.php 中的CONTENT_MODEL_XXX常量。 这些ID会在API和XML转储中披露。 定义自用的内容模型ID的扩展应注意避免冲突。 推荐使用扩展名称作前缀,例如'myextension-somecontent'。 可能的值例如: 'wikitext', 'javascript', 'css', 'text', and 'json'

(在1.31版本中已弃用) 如果slots表中的行有slot_revision_id = rev_id,应忽略此字段(并可能为NULL),以支持slots和content的相应数据。

(在版本1.35移除) 此列已被content.content_model取代,其引用了content_models.model_id

rev_content_format

MediaWiki版本:
1.21 – 1.34

内容格式,见Defines.php 中的CONTENT_FORMAT_XXX常量。 这些应该为MIME类型,且将在API和XML转储中披露。 扩展可随意使用下列格式或自己定义格式。 推荐遵守MIME类型公约。 可能的值例如: 'text/x-wiki', 'text/javascript', 'text/css', 'text/plain', 'text/html', 'application/vnd.php.serialized', 'application/json', 'application/xml'

(在1.31版本中已弃用) If rows in the slots table with slot_revision_id = rev_id exist, this field should be ignored (and may be NULL).

(在版本1.35移除)

This column was removed. The ContentHandler class is able to automatically detect the content format, and replaces this column.

架构摘要

MediaWiki版本:
1.37
Gerrit change 5954

DESCRIBE revision;

+----------------+---------------------+------+-----+---------+----------------+
| Field          | Type                | Null | Key | Default | Extra          |
+----------------+---------------------+------+-----+---------+----------------+
| rev_id         | int(10) unsigned    | NO   | PRI | NULL    | auto_increment |
| rev_page       | int(10) unsigned    | NO   | MUL | NULL    |                |
| rev_comment_id | bigint(20) unsigned | NO   |     | 0       |                |
| rev_actor      | bigint(20) unsigned | NO   | MUL | 0       |                |
| rev_timestamp  | binary(14)          | NO   | MUL | NULL    |                |
| rev_minor_edit | tinyint(3) unsigned | NO   |     | 0       |                |
| rev_deleted    | tinyint(3) unsigned | NO   |     | 0       |                |
| rev_len        | int(10) unsigned    | YES  |     | NULL    |                |
| rev_parent_id  | int(10) unsigned    | YES  |     | NULL    |                |
| rev_sha1       | varbinary(32)       | NO   |     |         |                |
+----------------+---------------------+------+-----+---------+----------------+
MediaWiki版本:
1.35 – 1.36

DESCRIBE revision;

+----------------+---------------------+------+-----+----------------+----------------+
| Field          | Type                | Null | Key | Default        | Extra          |
+----------------+---------------------+------+-----+----------------+----------------+
| rev_id         | int(10) unsigned    | NO   | PRI | NULL           | auto_increment |
| rev_page       | int(10) unsigned    | NO   | MUL | NULL           |                |
| rev_comment_id | bigint(20) unsigned | NO   |     | 0              |                |
| rev_actor      | bigint(20) unsigned | NO   | MUL | 0              |                |
| rev_timestamp  | binary(14)          | NO   | MUL |                |                |
| rev_minor_edit | tinyint(3) unsigned | NO   |     | 0              |                |
| rev_deleted    | tinyint(3) unsigned | NO   |     | 0              |                |
| rev_len        | int(10) unsigned    | YES  |     | NULL           |                |
| rev_parent_id  | int(10) unsigned    | YES  |     | NULL           |                |
| rev_sha1       | varbinary(32)       | NO   |     |                |                |
+----------------+---------------------+------+-----+----------------+----------------+
MediaWiki版本:
1.31 – 1.34

DESCRIBE revision;

+--------------------+---------------------+------+-----+----------------+----------------+
| Field              | Type                | Null | Key | Default        | Extra          |
+--------------------+---------------------+------+-----+----------------+----------------+
| rev_id             | int(10) unsigned    | NO   | PRI | NULL           | auto_increment |
| rev_page           | int(10) unsigned    | NO   | MUL | NULL           |                |
| rev_text_id        | int(10) unsigned    | NO   |     | 0              |                |
| rev_comment        | varbinary(767)      | NO   |     |                |                |
| rev_user           | int(10) unsigned    | NO   | MUL | 0              |                |
| rev_user_text      | varbinary(255)      | NO   | MUL |                |                |
| rev_timestamp      | binary(14)          | NO   | MUL |                |                |
| rev_minor_edit     | tinyint(3) unsigned | NO   |     | 0              |                |
| rev_deleted        | tinyint(3) unsigned | NO   |     | 0              |                |
| rev_len            | int(10) unsigned    | YES  |     | NULL           |                |
| rev_parent_id      | int(10) unsigned    | YES  |     | NULL           |                |
| rev_sha1           | varbinary(32)       | NO   |     |                |                |
| rev_content_model  | varbinary(32)       | YES  |     | NULL           |                |
| rev_content_format | varbinary(64)       | YES  |     | NULL           |                |
+--------------------+---------------------+------+-----+----------------+----------------+
MediaWiki版本:
1.30

DESCRIBE revision;

+--------------------+---------------------+------+-----+----------------+----------------+
| Field              | Type                | Null | Key | Default        | Extra          |
+--------------------+---------------------+------+-----+----------------+----------------+
| rev_id             | int(10) unsigned    | NO   | PRI | NULL           | auto_increment |
| rev_page           | int(10) unsigned    | NO   | MUL | NULL           |                |
| rev_text_id        | int(10) unsigned    | NO   |     | NULL           |                |
| rev_comment        | varbinary(767)      | NO   |     |                |                |
| rev_user           | int(10) unsigned    | NO   | MUL | 0              |                |
| rev_user_text      | varbinary(255)      | NO   | MUL |                |                |
| rev_timestamp      | binary(14)          | NO   | MUL |                |                |
| rev_minor_edit     | tinyint(3) unsigned | NO   |     | 0              |                |
| rev_deleted        | tinyint(3) unsigned | NO   |     | 0              |                |
| rev_len            | int(10) unsigned    | YES  |     | NULL           |                |
| rev_parent_id      | int(10) unsigned    | YES  |     | NULL           |                |
| rev_sha1           | varbinary(32)       | NO   |     |                |                |
| rev_content_model  | varbinary(32)       | YES  |     | NULL           |                |
| rev_content_format | varbinary(64)       | YES  |     | NULL           |                |
+--------------------+---------------------+------+-----+----------------+----------------+
MediaWiki版本:
1.25 – 1.29

DESCRIBE revision;

+--------------------+---------------------+------+-----+----------------+----------------+
| Field              | Type                | Null | Key | Default        | Extra          |
+--------------------+---------------------+------+-----+----------------+----------------+
| rev_id             | int(10) unsigned    | NO   | PRI | NULL           | auto_increment |
| rev_page           | int(10) unsigned    | NO   | MUL | NULL           |                |
| rev_text_id        | int(10) unsigned    | NO   |     | NULL           |                |
| rev_comment        | varbinary(767)      | NO   |     | NULL           |                |
| rev_user           | int(10) unsigned    | NO   | MUL | 0              |                |
| rev_user_text      | varbinary(255)      | NO   | MUL |                |                |
| rev_timestamp      | binary(14)          | NO   | MUL |                |                |
| rev_minor_edit     | tinyint(3) unsigned | NO   |     | 0              |                |
| rev_deleted        | tinyint(3) unsigned | NO   |     | 0              |                |
| rev_len            | int(10) unsigned    | YES  |     | NULL           |                |
| rev_parent_id      | int(10) unsigned    | YES  |     | NULL           |                |
| rev_sha1           | varbinary(32)       | NO   |     |                |                |
| rev_content_model  | varbinary(32)       | YES  |     | NULL           |                |
| rev_content_format | varbinary(64)       | YES  |     | NULL           |                |
+--------------------+---------------------+------+-----+----------------+----------------+
MediaWiki版本:
1.21 – 1.24

DESCRIBE revision;

+--------------------+---------------------+------+-----+---------+----------------+
| Field              | Type                | Null | Key | Default | Extra          |
+--------------------+---------------------+------+-----+---------+----------------+
| rev_id             | int(10) unsigned    | NO   | PRI | NULL    | AUTO_INCREMENT |
| rev_page           | int(10) unsigned    | NO   | PRI | NULL    |                |
| rev_text_id        | int(10) unsigned    | NO   |     | NULL    |                |
| rev_comment        | tinyblob            | NO   |     | NULL    |                |
| rev_user           | int(10) unsigned    | NO   | MUL | 0       |                |
| rev_user_text      | varchar(255) binary | NO   | MUL | NULL    |                |
| rev_timestamp      | binary(14)          | NO   | MUL | NULL    |                |
| rev_minor_edit     | tinyint(3) unsigned | NO   |     | 0       |                |
| rev_deleted        | tinyint(3) unsigned | NO   |     | 0       |                |
| rev_len            | int(10) unsigned    | YES  |     | NULL    |                |
| rev_parent_id      | int(10) unsigned    | YES  |     | NULL    |                |
| rev_sha1           | varbinary(32)       | NO   |     | NULL    |                |
| rev_content_model  | varbinary(32)       | YES  |     | NULL    |                |
| rev_content_format | varbinary(64)       | YES  |     | NULL    |                |
+--------------------+---------------------+------+-----+---------+----------------+
MediaWiki版本:
1.19 – 1.20

DESCRIBE revision;

+----------------+---------------------+------+-----+---------+----------------+
| Field          | Type                | Null | Key | Default | Extra          |
+----------------+---------------------+------+-----+---------+----------------+
| rev_id         | int(10) unsigned    | NO   | PRI | NULL    | AUTO_INCREMENT |
| rev_page       | int(10) unsigned    | NO   | PRI | NULL    |                |
| rev_text_id    | int(10) unsigned    | NO   |     | NULL    |                |
| rev_comment    | tinyblob            | NO   |     | NULL    |                |
| rev_user       | int(10) unsigned    | NO   | MUL | 0       |                |
| rev_user_text  | varchar(255) binary | NO   | MUL | NULL    |                |
| rev_timestamp  | binary(14)          | NO   | MUL | NULL    |                |
| rev_minor_edit | tinyint(3) unsigned | NO   |     | 0       |                |
| rev_deleted    | tinyint(3) unsigned | NO   |     | 0       |                |
| rev_len        | int(10) unsigned    | YES  |     | NULL    |                |
| rev_parent_id  | int(10) unsigned    | YES  |     | NULL    |                |
| rev_sha1       | varbinary(32)       | NO   |     | NULL    |                |
+----------------+---------------------+------+-----+---------+----------------+
MediaWiki版本:
1.9 – 1.18

DESCRIBE revision;

+----------------+---------------------+------+-----+---------+----------------+
| Field          | Type                | Null | Key | Default | Extra          |
+----------------+---------------------+------+-----+---------+----------------+
| rev_id         | int(10) unsigned    | NO   | PRI | NULL    | AUTO_INCREMENT |
| rev_page       | int(10) unsigned    | NO   | PRI | NULL    |                |
| rev_text_id    | int(10) unsigned    | NO   |     | NULL    |                |
| rev_comment    | tinyblob            | NO   |     | NULL    |                |
| rev_user       | int(10) unsigned    | NO   | MUL | 0       |                |
| rev_user_text  | varchar(255) binary | NO   | MUL | NULL    |                |
| rev_timestamp  | binary(14)          | NO   | MUL | NULL    |                |
| rev_minor_edit | tinyint(3) unsigned | NO   |     | 0       |                |
| rev_deleted    | tinyint(3) unsigned | NO   |     | 0       |                |
| rev_len        | int(10) unsigned    | YES  |     | NULL    |                |
| rev_parent_id  | int(10) unsigned    | YES  |     | NULL    |                |
+----------------+---------------------+------+-----+---------+----------------+
MediaWiki版本:
1.5 – 1.8

DESCRIBE revision;

+----------------+---------------------+------+-----+---------+----------------+
| Field          | Type                | Null | Key | Default | Extra          |
+----------------+---------------------+------+-----+---------+----------------+
| rev_id         | int(8) unsigned     | NO   | PRI | NULL    | AUTO_INCREMENT |
| rev_page       | int(8) unsigned     | NO   | PRI | NULL    |                |
| rev_text_id    | int(8) unsigned     | NO   |     | NULL    |                |
| rev_comment    | tinyblob            | NO   |     | NULL    |                |
| rev_user       | int(5) unsigned     | NO   | MUL | 0       |                |
| rev_user_text  | varchar(255) binary | NO   | MUL | NULL    |                |
| rev_timestamp  | char(14) binary     | NO   | MUL | NULL    |                |
| rev_minor_edit | tinyint(1) unsigned | NO   |     | 0       |                |
| rev_deleted    | tinyint(1) unsigned | NO   |     | 0       |                |
+----------------+---------------------+------+-----+---------+----------------+


索引

MediaWiki版本:
1.38

SHOW INDEX IN revision;

+----------+------------+--------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table    | Non_unique | Key_name                 | Seq_in_index | Column_name   | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+----------+------------+--------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| revision |          0 | PRIMARY                  |            1 | rev_id        | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| revision |          1 | rev_timestamp            |            1 | rev_timestamp | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| revision |          1 | rev_page_timestamp       |            1 | rev_page      | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| revision |          1 | rev_page_timestamp       |            2 | rev_timestamp | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| revision |          1 | rev_actor_timestamp      |            1 | rev_actor     | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| revision |          1 | rev_actor_timestamp      |            2 | rev_timestamp | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| revision |          1 | rev_actor_timestamp      |            3 | rev_id        | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| revision |          1 | rev_page_actor_timestamp |            1 | rev_page      | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| revision |          1 | rev_page_actor_timestamp |            2 | rev_actor     | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| revision |          1 | rev_page_actor_timestamp |            3 | rev_timestamp | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
+----------+------------+--------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

参见