Руководство:Таблица Revision
↑ Manual:Содержание | MediaWiki database layout | revision таблица |
Версия MediaWiki: | ≥ 1.5 |
В таблице revision хранятся метаданные о каждой правке, сделанной на странице в википроекте. Каждая правка одного или нескольких слотов страницы создает строку ревизии, которая содержит такую информацию, как: пользователь внесший правку, время внесения правки, ссылку на комментарий к этой правке в таблице comment и другие метаданные. Отредактированные слоты и соответствующая им ревизия указаны в таблица slots .
При импорте последней ревизии страницы из другой вики создаются две записи в таблице revision
: одна с датой и викитекстом импортированной ревизии, другая - с датой импорта.
Если страница с таким названием уже существовала, то викитекст последней становится викитекстом текущей страницы, а если страница с таким названием уже существовала, то викитекстом более поздней из двух страниц.
Таблица revision
очень похожа на таблицу recentchanges .
Таблица revision
используется для списков история страницы и вклад пользователя .
Таблица recentchanges используется для свежих правок , связанных изменениях , списка наблюдения и, в случае создания страницы, для списка новых страниц .
Различия включают:
- В таблице
recentchanges
также регистрируются такие события, как перемещение и удаление страниц. - Элементы в таблице
recentchanges
периодически удаляются; элементы в таблицеrevision
сохраняются навсегда, если только страница не будет удалена или владелец сайта не запустит скрипт обслуживания deleteOldRevisions.php . - Как уже было сказано, импорт ревизии страницы добавляет в таблицу
revision
не только запись с датой импорта, но и запись с исходной датой.
Удаленные изменения переносятся в таблицу archive .
Таблица ревизии и таблица text
были введены в MediaWiki 1.5 , чтобы заменить таблицу cur .
Поля
rev_id
Версия MediaWiki: | ≥ 1.5 |
В этом поле хранится первичный ключ для каждой ревизии.
page_latest является внешним ключом к этому полю.
Номера rev_id
сохраняются при удалении/неудалении с момента появления таблицы в MediaWiki 1.5, когда rev_id
и text_id
заменили старые cur_id
.
Заметим, что хотя rev_id
почти всегда монотонно возрастает для последовательных ревизий страницы, это не является строго гарантированным, поскольку при импорте из другой вики ревизии могут быть созданы не по порядку.
rev_page
Версия MediaWiki: | ≥ 1.5 |
В этом поле хранится ссылка на page , к которому относится данная ревизия. Число в этом поле равно полю page_id указанной страницы. Поле никогда не должна быть недействительным; если она недействительна, то эта ревизия не будет отображаться в истории страницы. Если page.page_latest ссылается на ревизию с недопустимой rev_page, то это приведет к ошибке "Ревизия #0 страницы с именем 'Foo' не существует". (аналогичная проблема может возникнуть, если для ревизии отсутствуют слоты и содержимое)
rev_text_id
Версии MediaWiki: | 1.5 – 1.34 |
Это внешний ключ к old_id в таблице text .
(Таблица 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 .) It is rendered in a sanitized subset of wiki markup.
(устарело)
revcomment_comment_id of the revision_comment_temp
table and the comment table should be used instead!
(удалено в 1.35) This column was replaced by revision.rev_comment_id, which references comment.comment_id.
rev_comment_id
Версия MediaWiki: | ≥ 1.35 |
This is a foreign key to comment_id in the comment table.
In MediaWiki 1.38 and older, if this field contains zero in each record, the comment id must be retrieved from the revision_comment_temp table. See Перенос баз данных на систему исполнителей .
rev_user
Версии MediaWiki: | 1.5 – 1.34 |
This is equal to the user_id of the user who made this edit. The value for this field is 0 for anonymous edits, initializations scripts, and for some mass imports.
Note, there are bugs: T112384.
(устарело в 1.31)
While actor migration is being done, and depending on the configuration setting $wgActorTableSchemaMigrationStage
, this field may be empty and the actor performing the edit can be stored in the rev_actor field or the revision_actor_temp table instead.
(удалено в 1.35) This column was removed along with revision.rev_user_text. This column is replaced by revision.rev_actor, which references actor.actor_id.
rev_user_text
Версии MediaWiki: | 1.5 – 1.34 |
This field holds the text of the editor's username , or the IP address of the editor if the revision was done by an unregistered user.
In anonymous revisions imported from UseModWiki or early incarnations of the Phase II software, this field may contain an IP address with the final octet obscured (i.e. \d{1,3}\.\d{1,3}\.\d{1,3}\.xxx
such as 24.150.61.xxx; see T5631).
Some edits imported from UseModWiki may contain a Reverse DNS lookup hostname like ppfree165-153-bz.aknet.it
or office.bomis.com
.
(устарело в 1.31) While actor migration is being done, and depending on the configuration setting $wgActorTableSchemaMigrationStage
, this field may be empty and the actor performing the edit can be stored in the rev_actor field or the revision_actor_temp table instead.
(удалено в 1.35) This column was removed along with revision.rev_user. This column is replaced by revision.rev_actor, which references actor.actor_id.
rev_actor
Версия MediaWiki: | ≥ 1.35 |
This is a foreign key to actor_id in the actor table. In MediaWiki 1.38 and older versions, if this field contains zero in each record, the actor ID must be retrieved from the revision_actor_temp table. See Перенос баз данных на систему исполнителей .
rev_timestamp
Версия MediaWiki: | ≥ 1.5 |
Holds the timestamp of the edit.
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 |
Records whether the user marked the 'minor edit' checkbox. If the value for this field is 1, then the edit was declared as 'minor'; it is 0 otherwise. Many automated edits are marked as minor.
rev_deleted
Версия MediaWiki: | ≥ 1.5 |
This field is reserved for RevisionDelete system.
It's a bitfield in which the values are DELETED_TEXT = 1; DELETED_COMMENT = 2; DELETED_USER = 4; and DELETED_RESTRICTED = 8.
So, for example, if nothing has been deleted from that revision, then the value is 0; if both the comment and user have been deleted, then the value is 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 |
This field contains the length of the article after the revision, in bytes. Used in history pages. Corresponds to rc_new_len .
rev_parent_id
Версия MediaWiki: | ≥ 1.10 |
The revision ID of the previous revision to the page.
Corresponds to rc_last_oldid .
For edits which are new page creations, rev_parent_id
= 0.
Usage
This field is used to add support for a tree structure. This field is e.g. used to calculate the size difference of a certain revision with the previous revision in the page history view. If a parent ID points to a revision that's associated with a different page, MediaWiki will still use that parent revision as a basis of comparison for purposes of calculating size difference. If a revision is deleted from the database, and another revision's parent ID still points to it, then MediaWiki will behave the same as if there were no parent revision; i.e. it will assume the previous size was 0.
Transferred revisions
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 can be used to populate rev_parent_id
based on revision timestamps and revision IDs.
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 |
This field is used to add the SHA-1 text content hash in base-36 (generated by Wikimedia\base_convert()
.)
Since 1.32, it's a nested hash of hashes of content_sha1 across all slots of the revision.
If the revision only has one slot, the values of the rev_sha1
and content_sha1
fields are identical.
The nested hash algorithm is implemented in RevisionSlots::computeSha1()
.
It can be outlined as:
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 |
Content model, see CONTENT_MODEL_XXX
constants in Defines.php .
These IDs will be exposed in the API and XML dumps.
Extensions that define their own content model IDs should take care to avoid conflicts.
Using the extension name as a prefix is recommended, for example 'myextension-somecontent'.
Possible values are, e.g.: 'wikitext', 'javascript', 'css', 'text', and 'json'
(устарело в 1.31)
If rows in the slots
table with slot_revision_id = rev_id this field should be ignored (and may be NULL) in favor of the corresponding data from the slots
and content
tables.
(удалено в 1.35) This column was replaced by content.content_model, which references content_models.model_id.
rev_content_format
Версии MediaWiki: | 1.21 – 1.34 |
Content format, see CONTENT_FORMAT_XXX
constants in Defines.php .
These should be MIME types, and will be exposed in the API and XML dumps.
Extensions are free to use the below formats, or define their own.
It is recommended to stick with the conventions for MIME types.
Possible values are, e.g.: '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.
Schema summary
Версия MediaWiki: | ≥ 1.43 |
DESCRIBE revision;
+----------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------------+------+-----+---------+----------------+ | rev_id | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | rev_page | int(10) unsigned | NO | MUL | NULL | | | rev_comment_id | bigint(20) unsigned | NO | | NULL | | | rev_actor | bigint(20) unsigned | 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 | bigint(20) unsigned | YES | | NULL | | | rev_sha1 | varbinary(32) | NO | | | | +----------------+---------------------+------+-----+---------+----------------+
Версии MediaWiki: | 1.37 – 1.42 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 | | +----------------+---------------------+------+-----+---------+----------------+
Indexes
Версия 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 | | | +----------+------------+--------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+